Sha256: b0d2e25b7a3b44f9c2575a4fe8172b7cba07316e8580500af9cb6e0331e72525
Contents?: true
Size: 1.09 KB
Versions: 46
Compression:
Stored size: 1.09 KB
Contents
// Internal method, used by iteration functions. // Calls a function for each key-value pair found in object // Optionally takes compareFn to iterate object in specific order "use strict"; var callable = require("./valid-callable") , value = require("./valid-value") , bind = Function.prototype.bind , call = Function.prototype.call , keys = Object.keys , objPropertyIsEnumerable = Object.prototype.propertyIsEnumerable; module.exports = function (method, defVal) { return function (obj, cb /*, thisArg, compareFn*/) { var list, thisArg = arguments[2], compareFn = arguments[3]; obj = Object(value(obj)); callable(cb); list = keys(obj); if (compareFn) { list.sort(typeof compareFn === "function" ? bind.call(compareFn, obj) : undefined); } if (typeof method !== "function") method = list[method]; return call.call(method, list, function (key, index) { if (!objPropertyIsEnumerable.call(obj, key)) return defVal; return call.call(cb, thisArg, obj[key], key, obj, index); }); }; };
Version data entries
46 entries across 46 versions & 3 rubygems