fluent-flags
Decorates a function with arbitrary fluent boolean flags and passes them as the first parameter.
npm i fluent-flags
|
pnpm add fluent-flags
|
yarn add fluent-flags
|
API
# NarrowHelper
src/index.ts#L11 # FluentFlags
(_flagKeys, cb, flags) – Decorates a function with fluent flags that are then passed as an object.
src/index.ts#L27
const cb = FluentFlags(
['foo', 'bar'],
flags => (arg: string) => [flags.foo, flags.bar, arg]
)
expect(cb()).toMatchObject([void 0, void 0, void 0])
expect(cb('hello')).toMatchObject([void 0, void 0, 'hello'])
expect(cb.bar('hello')).toMatchObject([void 0, true, 'hello'])
expect(cb.foo.bar('hello')).toMatchObject([true, true, 'hello'])
# _flagKeys
# flags
= {}
any
FluentFlags<K, C extends Fn<any, any>, T>(_flagKeys, cb, flags) =>
Contributing
All contributions are welcome!