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.
21 lines
464 B
21 lines
464 B
5 months ago
|
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
|