1 |
|
2 |
|
3 | "use strict"
|
4 |
|
5 | var has = require("./hasOwn")
|
6 |
|
7 | var 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 |
|
12 | if (!({valueOf: 0}).propertyIsEnumerable("valueOf")){
|
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 |
|
28 | module.exports = forIn
|