(holder, key, isTopLevel)
| 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 === '$'; |
no test coverage detected