• 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

100.0
/src/Tuple.ts
1
import { getNode, registry } from './graph.ts';
2

3
const TupleConstructor = class Tuple<A extends readonly unknown[]> extends Array {
1✔
4
  constructor(values: A) {
5
    super();
13✔
6
    this.push(...values);
13✔
7
    Object.freeze(this);
13✔
8
  }
9
};
10

11
export function Tuple<A extends unknown[]>(...path: A): Readonly<A> {
12
  if (new.target) {
25✔
13
    throw new TypeError('Tuple is not a constructor');
1✔
14
  }
15

16
  if (path.length === 0) {
24✔
17
    // Shortcut for 0-tuples
18
    return tuple0 as any;
6✔
19
  }
20

21
  const node = getNode(path);
18✔
22
  const derefed = node.tuple?.deref();
18✔
23
  if (derefed) {
18✔
24
    return derefed as A;
6✔
25
  }
26
  const tuple = new TupleConstructor<A>(path);
12✔
27
  node.tuple = new WeakRef(tuple);
12✔
28
  registry.register(tuple, path);
12✔
29

30
  return tuple as A;
12✔
31
}
32

33
// Allow `instanceof` checks with the helper function as if it were a constructor
34
Object.defineProperty(Tuple, Symbol.hasInstance, {
1✔
35
  value: (instance: unknown) => instance instanceof TupleConstructor,
1✔
36
  writable: false,
37
  configurable: false,
38
});
39

40
// 0-tuple singleton
41
const tuple0 = new TupleConstructor([]);
1✔
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