MCPcopy Index your code
hub / github.com/nodejs/node / addKeyVal

Function addKeyVal

lib/querystring.js:286–304  ·  view source on GitHub ↗
(obj, key, value, keyEncoded, valEncoded, decode)

Source from the content-addressed store, hash-verified

284const defEqCodes = [61]; // =
285
286function addKeyVal(obj, key, value, keyEncoded, valEncoded, decode) {
287 if (key.length > 0 && keyEncoded)
288 key = decodeStr(key, decode);
289 if (value.length > 0 && valEncoded)
290 value = decodeStr(value, decode);
291
292 if (obj[key] === undefined) {
293 obj[key] = value;
294 } else {
295 const curValue = obj[key];
296 // A simple Array-specific property check is enough here to
297 // distinguish from a string value and is faster and still safe
298 // since we are generating all of the values being assigned.
299 if (curValue.pop)
300 curValue[curValue.length] = value;
301 else
302 obj[key] = [curValue, value];
303 }
304}
305
306/**
307 * Parse a key/val string.

Callers 1

parseFunction · 0.85

Calls 1

decodeStrFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…