MCPcopy Create free account
hub / github.com/arktypeio/arktype / flatDepthOf

Function flatDepthOf

ark/aot/readers.ts:2228–2237  ·  view source on GitHub ↗
(
	call: Extract<Node, { type: "CallExpression" }>
)

Source from the content-addressed store, hash-verified

2226
2227// .flat()'s depth, 1 by default, or any where the build can't name it
2228const flatDepthOf = (
2229 call: Extract<Node, { type: "CallExpression" }>
2230): number => {
2231 const [arg] = call.arguments
2232 if (!arg) return 1
2233 const depth = unwrapExpression(arg)
2234 return depth.type === "Literal" && typeof depth.value === "number" ?
2235 depth.value
2236 : Infinity
2237}
2238
2239// a flatMap() callback returning an array holds it one level shallower than
2240// its wrap, as the same call's entry without one does

Callers 1

arrayMethodMethod · 0.85

Calls 1

unwrapExpressionFunction · 0.90

Tested by

no test coverage detected