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

Function cloneIfNode

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

Source from the content-addressed store, hash-verified

7
8// This function will never be called for comments, only for real nodes.
9function cloneIfNode(
10 obj: t.Node | undefined | null,
11 deep: boolean,
12 withoutLoc: boolean,
13 commentsCache: CommentCache,
14) {
15 if (obj && typeof obj.type === "string") {
16 return cloneNodeInternal(obj, deep, withoutLoc, commentsCache);
17 }
18
19 return obj;
20}
21
22function cloneIfNodeOrArray(
23 obj: t.Node | undefined | null | (t.Node | undefined | null)[],

Callers 1

cloneIfNodeOrArrayFunction · 0.85

Calls 1

cloneNodeInternalFunction · 0.85

Tested by

no test coverage detected