UNPKG

870 BJavaScriptView Raw
1/*
2object:forIn
3*/"use strict"
4
5var has = require("./hasOwn")
6
7var forIn = function(self, method, context){
8 for (var key in self) if (method.call(context, self[key], key, self) === false) break
9 return self
10}
11
12if (!({valueOf: 0}).propertyIsEnumerable("valueOf")){ // fix for stupid IE enumeration bug
13
14 var buggy = "constructor,toString,valueOf,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString".split(",")
15 var proto = Object.prototype
16
17 forIn = function(self, method, context){
18 for (var key in self) if (method.call(context, self[key], key, self) === false) return self
19 for (var i = 0; key = buggy[i]; i++){
20 var value = self[key]
21 if ((value !== proto[key] || has(self, key)) && method.call(context, value, key, self) === false) break
22 }
23 return self
24 }
25
26}
27
28module.exports = forIn