MCPcopy Create free account
hub / github.com/RubyLouvre/anu / getReplacedValueOrUndefined

Function getReplacedValueOrUndefined

test/babel.js:50432–50453  ·  view source on GitHub ↗
(holder, key, isTopLevel)

Source from the content-addressed store, hash-verified

50430 throw new Error('Replacer must be a function or an array');
50431 }
50432 var getReplacedValueOrUndefined = function getReplacedValueOrUndefined(holder, key, isTopLevel) {
50433 var value = holder[key];
50434
50435 // Replace the value with its toJSON value first, if possible
50436 if (value && value.toJSON && typeof value.toJSON === "function") {
50437 value = value.toJSON();
50438 }
50439
50440 // If the user-supplied replacer if a function, call it. If it's an array, check objects' string keys for
50441 // presence in the array (removing the key/value pair from the resulting JSON if the key is missing).
50442 if (typeof replacer === "function") {
50443 return replacer.call(holder, key, value);
50444 } else if (replacer) {
50445 if (isTopLevel || isArray(holder) || replacer.indexOf(key) >= 0) {
50446 return value;
50447 } else {
50448 return undefined;
50449 }
50450 } else {
50451 return value;
50452 }
50453 };
50454
50455 function isWordChar(c) {
50456 return c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c >= '0' && c <= '9' || c === '_' || c === '$';

Callers 2

internalStringifyFunction · 0.85
babel.jsFile · 0.85

Calls 1

isArrayFunction · 0.85

Tested by

no test coverage detected