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

Function walk

test/json3.js:863–880  ·  view source on GitHub ↗
(source, property, callback)

Source from the content-addressed store, hash-verified

861 // `callback` function for each value. This is an implementation of the
862 // `Walk(holder, name)` operation defined in ES 5.1 section 15.12.2.
863 var walk = function (source, property, callback) {
864 var value = source[property], length;
865 if (typeof value == "object" && value) {
866 // `forOwn` can't be used to traverse an array in Opera <= 8.54
867 // because its `Object#hasOwnProperty` implementation returns `false`
868 // for array indices (e.g., `![1, 2, 3].hasOwnProperty("0")`).
869 if (getClass.call(value) == arrayClass) {
870 for (length = value.length; length--;) {
871 update(getClass, forOwn, value, length, callback);
872 }
873 } else {
874 forOwn(value, function (property) {
875 update(value, property, callback);
876 });
877 }
878 }
879 return callback.call(source, property, value);
880 };
881
882 // Public: `JSON.parse`. See ES 5.1 section 15.12.2.
883 exports.parse = function (source, callback) {

Callers 3

updateFunction · 0.85
runInContextFunction · 0.85
babel.jsFile · 0.85

Calls 2

updateFunction · 0.70
forOwnFunction · 0.70

Tested by

no test coverage detected