(holder, key, isTopLevel)
| 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') || |
no test coverage detected
searching dependent graphs…