MCPcopy
hub / github.com/clauderic/dnd-kit / derived

Function derived

packages/state/src/decorators.ts:29–46  ·  view source on GitHub ↗
(
  target: (this: This) => Return,
  _: ClassGetterDecoratorContext<This, Return>
)

Source from the content-addressed store, hash-verified

27}
28
29export function derived<This, Return>(
30 target: (this: This) => Return,
31 _: ClassGetterDecoratorContext<This, Return>
32) {
33 const map: WeakMap<any, Signal<Return>> = new WeakMap();
34
35 return function (this: This): Return {
36 let result = map.get(this);
37
38 if (!result) {
39 result = computed(target.bind(this));
40
41 map.set(this, result);
42 }
43
44 return result.value;
45 };
46}
47
48/**
49 * Make a field enumerable (or non‑enumerable) on every instance.

Callers

nothing calls this directly

Calls 4

computedFunction · 0.90
getMethod · 0.45
bindMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected