UNPKG

@jswork/next-deep-each

Version:

Deep each for next.

33 lines (26 loc) 873 B
/*! * name: @jswork/next-deep-each * description: Deep each for next. * homepage: https://js.work * version: 1.0.6 * date: 2026-05-04 16:49:22 * license: MIT */ import nx from '@jswork/next'; // const MSG_ERROR_MUST_TARGET = 'Target must be an array or an object.'; nx.deepEach = function (inTarget, inCallback, inContext) { if (!inTarget || typeof inTarget !== 'object') return; const each = function (target, paths = []) { nx.each(target, function (key, value) { const newPath = paths.concat(key); const args = [...arguments, newPath]; inCallback.apply(inContext, args); if (value && typeof value === 'object') each(value, newPath); }); }; each(inTarget, []); }; // if (typeof module !== 'undefined' && module.exports && typeof wx === 'undefined') { // module.exports = nx.deepEach; // } export default nx.deepEach;