MCPcopy Create free account
hub / github.com/babel/babel / cloneIfNodeOrArray

Function cloneIfNodeOrArray

packages/babel-types/src/clone/cloneNode.ts:22–32  ·  view source on GitHub ↗
(
  obj: t.Node | undefined | null | (t.Node | undefined | null)[],
  deep: boolean,
  withoutLoc: boolean,
  commentsCache: CommentCache,
)

Source from the content-addressed store, hash-verified

20}
21
22function cloneIfNodeOrArray(
23 obj: t.Node | undefined | null | (t.Node | undefined | null)[],
24 deep: boolean,
25 withoutLoc: boolean,
26 commentsCache: CommentCache,
27) {
28 if (Array.isArray(obj)) {
29 return obj.map(node => cloneIfNode(node, deep, withoutLoc, commentsCache));
30 }
31 return cloneIfNode(obj, deep, withoutLoc, commentsCache);
32}
33
34/**
35 * Create a clone of a `node` including only properties belonging to the node.

Callers 1

cloneNodeInternalFunction · 0.85

Calls 2

cloneIfNodeFunction · 0.85
mapMethod · 0.80

Tested by

no test coverage detected