MCPcopy
hub / github.com/Unitech/pm2 / getReplacedValueOrUndefined

Function getReplacedValueOrUndefined

lib/tools/json5.js:525–546  ·  view source on GitHub ↗
(holder, key, isTopLevel)

Source from the content-addressed store, hash-verified

523 throw new Error('Replacer must be a function or an array');
524 }
525 var getReplacedValueOrUndefined = function(holder, key, isTopLevel) {
526 var value = holder[key];
527
528 // Replace the value with its toJSON value first, if possible
529 if (value && value.toJSON && typeof value.toJSON === "function") {
530 value = value.toJSON();
531 }
532
533 // If the user-supplied replacer if a function, call it. If it's an array, check objects' string keys for
534 // presence in the array (removing the key/value pair from the resulting JSON if the key is missing).
535 if (typeof(replacer) === "function") {
536 return replacer.call(holder, key, value);
537 } else if(replacer) {
538 if (isTopLevel || isArray(holder) || replacer.indexOf(key) >= 0) {
539 return value;
540 } else {
541 return undefined;
542 }
543 } else {
544 return value;
545 }
546 };
547
548 function isWordChar(char) {
549 return (char >= 'a' && char <= 'z') ||

Callers 2

internalStringifyFunction · 0.85
json5.jsFile · 0.85

Calls 3

isArrayFunction · 0.85
toJSONMethod · 0.80
indexOfMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…