MCPcopy
hub / github.com/serverless/serverless / flattenDeep

Function flattenDeep

packages/util/src/logger/index.js:432–441  ·  view source on GitHub ↗
(array)

Source from the content-addressed store, hash-verified

430const joinTextTokens = (textTokens) => {
431 // Function to deeply flatten an array
432 const flattenDeep = (array) => {
433 // Make sure the input is actually an array; otherwise, wrap it in one
434 if (!Array.isArray(array)) return [array]
435
436 return array.reduce(
437 (acc, val) =>
438 Array.isArray(val) ? acc.concat(flattenDeep(val)) : acc.concat(val),
439 [],
440 )
441 }
442
443 // Make sure the initial input is treated as an array if it is not
444 const flattened = flattenDeep(

Callers 1

joinTextTokensFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…