12345678910111213141516171819202122232425262728 |
- 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
|