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

Function strip

test/utils.ts:281–309  ·  view source on GitHub ↗
(expr: Expression)

Source from the content-addressed store, hash-verified

279 if (typeof expr === 'number') return expr;
280 if (typeof expr === 'string') {
281 if (expr[0] === "'" && expr[expr.length - 1] === "'") {
282 return { str: expr.slice(1, -1) };
283 }
284 return expr;
285 }
286 if (Array.isArray(expr))
287 return expr.map(
288 (x) => strip(x ?? 'Nothing') ?? 'Nothing'
289 ) as any as Expression;
290
291 if (typeof expr === 'object') {
292 if ('num' in expr) return validJSONNumber(expr.num);
293 if ('sym' in expr) return expr.sym;
294 if ('fn' in expr) {
295 return expr.fn.map(
296 (x) => strip(x ?? 'Nothing') ?? 'Nothing'
297 ) as any as Expression;
298 }
299
300 if ('str' in expr) return { str: expr.str };
301
302 console.log('Unexpected object literal as an Expression');
303 }
304
305 return null;
306}
307
308function formatError(errors: ParsingDiagnostic[]): Expression {
309 return [
310 'Error',
311 [
312 'String',

Callers 2

validCortexFunction · 0.85
invalidCortexFunction · 0.85

Calls 4

validJSONNumberFunction · 0.85
sliceMethod · 0.65
mapMethod · 0.65
logMethod · 0.65

Tested by

no test coverage detected