UNPKG

@cashfarm/plow

Version:

Library for validating input data and parameters

45 lines 1.39 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); function CopyPropsToUnderscoreProp(aggt, event) { Reflect.ownKeys(event).forEach(k => { if ('_id' === `_${k}`) return; aggt[`_${k}`] = event[k]; }); } exports.CopyPropsToUnderscoreProp = CopyPropsToUnderscoreProp; function CopyProps(aggt, event) { Reflect.ownKeys(event).forEach(k => { if ('id' === k) return; aggt[k] = event[k]; }); } exports.CopyProps = CopyProps; const _config = { requireApplyForEachEvent: false, defaultApplyFn: CopyPropsToUnderscoreProp }; const PLOW_CONFIG = Symbol.for('cashfarm.plow.config'); // check if the global object has this symbol // add it if it does not have the symbol, yet // ------------------------------------------ const globalSymbols = Object.getOwnPropertySymbols(global); if (!(globalSymbols.indexOf(PLOW_CONFIG) > -1)) { global[PLOW_CONFIG] = _config; } // define the singleton API // ------------------------ const singleton = {}; Object.defineProperty(singleton, 'instance', { get: () => { return global[PLOW_CONFIG]; } }); // ensure the API is never changed // ------------------------------- Object.freeze(singleton); // export the singleton API only // ----------------------------- exports.PlowConfig = singleton.instance; //# sourceMappingURL=config.js.map