UNPKG

@jswork/next-deep-each

Version:

Deep each for next.

58 lines (54 loc) 1.75 kB
/*! * 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 */ 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); exports['default'] = void 0; var _next = _interopRequireDefault(require('@jswork/next')); function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } function _typeof(o) { '@babel/helpers - typeof'; return ( (_typeof = 'function' == typeof Symbol && 'symbol' == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && 'function' == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? 'symbol' : typeof o; }), _typeof(o) ); } // const MSG_ERROR_MUST_TARGET = 'Target must be an array or an object.'; _next['default'].deepEach = function (inTarget, inCallback, inContext) { if (!inTarget || _typeof(inTarget) !== 'object') return; var _each = function each(target) { var paths = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; _next['default'].each(target, function (key, value) { var newPath = paths.concat(key); var args = [].concat(Array.prototype.slice.call(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; // } var _default = (exports['default'] = _next['default'].deepEach);