MCPcopy Create free account
hub / github.com/cortex-js/compute-engine / parseBasePattern

Function parseBasePattern

src/compute-engine/sequence.ts:101–113  ·  view source on GitHub ↗

* Parse a base case key into a pattern. * * @example * parseBasePattern('0,0') → { type: 'exact', values: [0, 0] } * parseBasePattern('n,0') → { type: 'pattern', values: ['n', 0] } * parseBasePattern('n,n') → { type: 'pattern', values: ['n', 'n'] }

(key: string | number)

Source from the content-addressed store, hash-verified

99}
100
101/**
102 * Parse a base case key into a pattern.
103 *
104 * @example
105 * parseBasePattern('0,0') → { type: 'exact', values: [0, 0] }
106 * parseBasePattern('n,0') → { type: 'pattern', values: ['n', 0] }
107 * parseBasePattern('n,n') → { type: 'pattern', values: ['n', 'n'] }
108 */
109function parseBasePattern(key: string | number): ParsedPattern {
110 if (typeof key === 'number') {
111 return { type: 'exact', values: [key] };
112 }
113
114 const parts = key.split(',').map((p) => p.trim());
115 const values = parts.map((p) => {
116 const num = Number(p);

Callers 1

prepareBaseCasesFunction · 0.85

Calls 2

isNaNFunction · 0.85
mapMethod · 0.65

Tested by

no test coverage detected