MCPcopy Create free account
hub / github.com/nodejs/node / replaceAppendSymbols

Function replaceAppendSymbols

deps/npm/lib/utils/queryable.js:11–20  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9// replaces any occurrence of an empty-brackets (e.g: []) with a special Symbol(append) to represent it
10// this is going to be useful for the setter method that will push values to the end of the array when finding these
11const replaceAppendSymbols = str => {
12 const matchEmptyBracket = str.match(/^(.*)\[\]\.?(.*)$/)
13
14 if (matchEmptyBracket) {
15 const [, pre, post] = matchEmptyBracket
16 return [...replaceAppendSymbols(pre), _append, post].filter(Boolean)
17 }
18
19 return [str]
20}
21
22const parseKeys = key => {
23 const sqBracketItems = new Set()

Callers 1

parseSqBracketsFunction · 0.85

Calls 2

matchMethod · 0.65
filterMethod · 0.65

Tested by

no test coverage detected