You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
623 B
29 lines
623 B
5 months ago
|
var isArray = require('./isArray')
|
||
|
var hasOwnProp = require('./hasOwnProp')
|
||
|
|
||
|
/**
|
||
|
* 已废弃,被 some, every 替换
|
||
|
* @deprecated
|
||
|
*/
|
||
|
function forOf (obj, iterate, context) {
|
||
|
if (obj) {
|
||
|
if (isArray(obj)) {
|
||
|
for (var index = 0, len = obj.length; index < len; index++) {
|
||
|
if (iterate.call(context, obj[index], index, obj) === false) {
|
||
|
break
|
||
|
}
|
||
|
}
|
||
|
} else {
|
||
|
for (var key in obj) {
|
||
|
if (hasOwnProp(obj, key)) {
|
||
|
if (iterate.call(context, obj[key], key, obj) === false) {
|
||
|
break
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
module.exports = forOf
|