@fourlights/mapper
Version:
A simple data mapper written in typescript
2 lines • 1.87 kB
JavaScript
;Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunk2FHHGQ5Xcjs = require('./chunk-2FHHGQ5X.cjs');var _chunkFUJCL7EJcjs = require('./chunk-FUJCL7EJ.cjs');var _chunkYFP5IOXGcjs = require('./chunk-YFP5IOXG.cjs');var _setvalue = require('set-value'); var _setvalue2 = _interopRequireDefault(_setvalue);function d(c,o,i){let p={};_optionalChain([i, 'optionalAccess', _ => _.plugins])&&i.plugins.forEach(e=>{o=e.config(o,i)});for(let e in o){let r=_chunkFUJCL7EJcjs.a.call(void 0, o[e]);if(!r)continue;_optionalChain([r, 'access', _2 => _2.options, 'optionalAccess', _3 => _3.init])&&(p[e]=r.options.init(c,e));let t=r.value(c);if(Array.isArray(t)||_chunkYFP5IOXGcjs.a.call(void 0, t)){let a=typeof t=="object"?Object.keys(t):t,b=_nullishCoalesce(_optionalChain([r, 'access', _4 => _4.options, 'optionalAccess', _5 => _5.structure]), () => (_chunk2FHHGQ5Xcjs.b));for(let n=0;n<a.length;n+=1){let f=typeof t=="object"?a[n]:n,s=t[f],u=b(s,e,f),j=r.apply?r.apply(s,e,u):s;_setvalue2.default.call(void 0, p,u,j,{merge:!0})}}else _setvalue2.default.call(void 0, p,e,t)}return p}exports.a = d;
//# sourceMappingURL=chunk-QLI2AVPS.cjs.map