diff options
Diffstat (limited to 'node_modules/option-chain/index.js')
-rw-r--r-- | node_modules/option-chain/index.js | 55 |
1 files changed, 0 insertions, 55 deletions
diff --git a/node_modules/option-chain/index.js b/node_modules/option-chain/index.js deleted file mode 100644 index 99798bbea..000000000 --- a/node_modules/option-chain/index.js +++ /dev/null @@ -1,55 +0,0 @@ -'use strict'; -module.exports = (options, fn, target) => { - const chainables = options.chainableMethods || {}; - const spread = options.spread; - const defaults = Object.assign({}, options.defaults); - - function extend(target, getter, ctx) { - for (const key of Object.keys(chainables)) { - Object.defineProperty(target, key, { - enumerable: true, - configurable: true, - get() { - return wrap(getter, chainables[key], ctx || this); - } - }); - } - } - - function wrap(createOpts, extensionOpts, ctx) { - function wrappedOpts() { - return Object.assign(createOpts(), extensionOpts); - } - - function wrappedFn() { - let args = new Array(arguments.length); - - for (let i = 0; i < args.length; i++) { - args[i] = arguments[i]; - } - - if (spread) { - args.unshift(wrappedOpts()); - } else { - args = [wrappedOpts(), args]; - } - - return fn.apply(ctx || this, args); - } - - extend(wrappedFn, wrappedOpts, ctx); - - return wrappedFn; - } - - function copyDefaults() { - return Object.assign({}, defaults); - } - - if (target) { - extend(target, copyDefaults); - return target; - } - - return wrap(copyDefaults); -}; |