1234567891011121314151617181920 |
- var isArray = require('./isArray')
- var arrayEach = require('./arrayEach')
- var objectEach = require('./objectEach')
- /**
- * 迭代器
- *
- * @param {Object} obj 对象/数组
- * @param {Function} iterate(item, index, obj) 回调
- * @param {Object} context 上下文
- * @return {Object}
- */
- function each (obj, iterate, context) {
- if (obj) {
- return (isArray(obj) ? arrayEach : objectEach)(obj, iterate, context)
- }
- return obj
- }
- module.exports = each
|