MCPcopy Create free account
hub / github.com/formkit/formkit / trap

Function trap

packages/core/src/node.ts:1756–1770  ·  view source on GitHub ↗

* Creates a getter/setter trap and curries the context/node pair * * @param getter - The getter function * @param setter - The setter function * @param curryGetter - Indicates if the getter should be curried or not * * @returns A FormKitTrap | FormKitTrap

(
  getter?: TrapGetter,
  setter?: TrapSetter,
  curryGetter = true
)

Source from the content-addressed store, hash-verified

1754 * @returns A {@link FormKitTrap | FormKitTrap}
1755 */
1756function trap(
1757 getter?: TrapGetter,
1758 setter?: TrapSetter,
1759 curryGetter = true
1760): FormKitTrap {
1761 return {
1762 get: getter
1763 ? (node, context) =>
1764 curryGetter
1765 ? (...args: any[]) => getter(node, context, ...args)
1766 : getter(node, context)
1767 : false,
1768 set: setter !== undefined ? setter : invalidSetter.bind(null),
1769 }
1770}
1771
1772/**
1773 * Create all of the node's hook dispatchers.

Callers 1

node.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected