• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

slikts / tuplerone / 5732492970

pending completion
5732492970

push

github

slikts
chore: update pre-push hook

39 of 40 branches covered (97.5%)

Branch coverage included in aggregate %.

94 of 95 relevant lines covered (98.95%)

125.48 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

93.1
/src/ValueObject.ts
1
import { getNode, registry } from './graph.ts';
2
import { isRef, cache as shallowCache } from './shallow.ts'
3

4
export function ValueObject<A extends object>(source: A): DeepReadonly<A> {
5
  if (new.target) {
1,961!
6
    throw new TypeError('ValueObject is not a constructor');
×
7
  }
8
  
9
  if (shallowCache.has(source) || source?.[isRef]) {
1,961✔
10
    return source
2✔
11
  }
12

13
  const entries = Object.entries(source).map(([key, value]) => {
1,959✔
14
    if (typeof value === 'object' && value !== null) {
1,966✔
15
      return [key, ValueObject(value)];
1,936✔
16
    }
17
    return [key, value];
30✔
18
  });
19
  const path = entries.flat();
27✔
20
  const node = getNode(path);
27✔
21
  const object = node.object?.deref();
27✔
22
  if (!object) {
27✔
23
    const object = Object.freeze(Object.fromEntries(entries)) as DeepReadonly<A>;
13✔
24
    node.object = new WeakRef(object);
13✔
25
    registry.register(object, path);
13✔
26
    return object;
13✔
27
  }
28
  return object as DeepReadonly<A>;
14✔
29
}
30

31
type DeepReadonly<A> = {
32
  readonly [P in keyof A]: A[P] extends object ? DeepReadonly<A[P]> : A[P];
33
};
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc