Refactoring Guru: Facade Notes: facade Facade is nothing special, all libraries are essentially using facade-design-pattern .

For example, in Kunkun’s API package @kksh/api, I expose a function for Deno to expose functions for the main extension process to call. See code

This is how it’s used.

import { expose } from "@kksh/api/runtime/deno"
expose(apiMethods)

While in the background, it does some extra work, like creating Deno stdio and setting up the bidirectional channel.

import { DenoIo, RPCChannel } from "kkrpc"
 
// deno-lint-ignore no-explicit-any
export function expose(api: Record<string, any>) {
	const stdio = new DenoIo(Deno.stdin.readable)
	const channel = new RPCChannel(stdio, { expose: api })
	return channel
}
 
export { DenoIo, RPCChannel } from "kkrpc"

The library acts as a facade, hiding logic behind the scenes, and let user deal with a single, simple expose() function.