From 363723fc84f7b8477592e0105aeb331ec9a017af Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Mon, 14 Aug 2017 05:01:11 +0200 Subject: node_modules --- node_modules/option-chain/index.js | 27 +++++++------- node_modules/option-chain/package.json | 21 ++++++----- node_modules/option-chain/readme.md | 64 ++++++++++++++++++---------------- 3 files changed, 59 insertions(+), 53 deletions(-) (limited to 'node_modules/option-chain') diff --git a/node_modules/option-chain/index.js b/node_modules/option-chain/index.js index cf0d484b4..99798bbea 100644 --- a/node_modules/option-chain/index.js +++ b/node_modules/option-chain/index.js @@ -1,38 +1,39 @@ 'use strict'; -var objectAssign = require('object-assign'); - -module.exports = function (options, fn, target) { - var chainables = options.chainableMethods || {}; - var spread = options.spread; - var defaults = objectAssign({}, options.defaults); +module.exports = (options, fn, target) => { + const chainables = options.chainableMethods || {}; + const spread = options.spread; + const defaults = Object.assign({}, options.defaults); function extend(target, getter, ctx) { - Object.keys(chainables).forEach(function (key) { + for (const key of Object.keys(chainables)) { Object.defineProperty(target, key, { enumerable: true, configurable: true, - get: function () { + get() { return wrap(getter, chainables[key], ctx || this); } }); - }); + } } function wrap(createOpts, extensionOpts, ctx) { function wrappedOpts() { - return objectAssign(createOpts(), extensionOpts); + return Object.assign(createOpts(), extensionOpts); } function wrappedFn() { - var args = new Array(arguments.length); - for (var i = 0; i < args.length; i++) { + 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); } @@ -42,7 +43,7 @@ module.exports = function (options, fn, target) { } function copyDefaults() { - return objectAssign({}, defaults); + return Object.assign({}, defaults); } if (target) { diff --git a/node_modules/option-chain/package.json b/node_modules/option-chain/package.json index 2c58dd932..30149f0f4 100644 --- a/node_modules/option-chain/package.json +++ b/node_modules/option-chain/package.json @@ -1,19 +1,19 @@ { "name": "option-chain", - "version": "0.1.1", + "version": "1.0.0", "description": "Use fluent property chains in lieu of options objects", "license": "MIT", - "repository": "jamestalmage/option-chain", + "repository": "avajs/option-chain", "author": { "name": "James Talmage", "email": "james@talmage.io", "url": "github.com/jamestalmage" }, "engines": { - "node": ">=0.10.0" + "node": ">=4" }, "scripts": { - "test": "xo && nyc --cache --reporter=lcov --reporter=text ava" + "test": "xo && nyc ava" }, "files": [ "index.js" @@ -27,12 +27,15 @@ "fluent" ], "devDependencies": { - "ava": "^0.10.0", + "ava": "^0.19.1", "coveralls": "^2.11.6", - "nyc": "^5.3.0", - "xo": "^0.12.1" + "nyc": "^10.3.2", + "xo": "^0.18.2" }, - "dependencies": { - "object-assign": "^4.0.1" + "nyc": { + "reporter": [ + "lcov", + "text" + ] } } diff --git a/node_modules/option-chain/readme.md b/node_modules/option-chain/readme.md index efa9af4cc..a2f976b70 100644 --- a/node_modules/option-chain/readme.md +++ b/node_modules/option-chain/readme.md @@ -1,6 +1,6 @@ -# option-chain [![Build Status](https://travis-ci.org/jamestalmage/option-chain.svg?branch=master)](https://travis-ci.org/jamestalmage/option-chain) [![Coverage Status](https://coveralls.io/repos/jamestalmage/option-chain/badge.svg?branch=master&service=github)](https://coveralls.io/github/jamestalmage/option-chain?branch=master) +# option-chain [![Build Status](https://travis-ci.org/avajs/option-chain.svg?branch=master)](https://travis-ci.org/avajs/option-chain) [![Coverage Status](https://coveralls.io/repos/github/avajs/option-chain/badge.svg?branch=master)](https://coveralls.io/github/avajs/option-chain?branch=master) -> Use fluent property chains in lieu of options objects. +> Use fluent property chains in lieu of options objects ## Install @@ -16,21 +16,22 @@ $ npm install --save option-chain const optionChain = require('option-chain'); const optionDefinition = { - defaults: { - bar: false - }, - chainableMethods: { - foo: {foo: true}, - notFoo: {foo: false}, - bar: {bar: true} - } + defaults: { + bar: false + }, + chainableMethods: { + foo: {foo: true}, + notFoo: {foo: false}, + bar: {bar: true} + } }; function printOptionsAndArgs(options, args) { - console.log(options); - if (args.length) { - console.log(args); - } + console.log(options); + + if (args.length) { + console.log(args); + } } const fn = optionChain(optionDefinition, printOptionsAndArgs); @@ -56,8 +57,8 @@ fn.foo('a', 'b'); ##### chainableMethods -Type: `Object` -*Required* +*Required*
+Type: `Object` A map of chainable property names to the options set by adding property to the chain. @@ -65,10 +66,10 @@ Given the following: ```js const chainableMethods = { - foo: {foo: true}, - notFoo: {foo: false}, - bar: {bar: true}, - both: {foo: true, bar: true} + foo: {foo: true}, + notFoo: {foo: false}, + bar: {bar: true}, + both: {foo: true, bar: true} } ``` @@ -77,38 +78,38 @@ Then: - `fn.foo` would set `foo` to `true`. - `fn.bar` would set `bar` to `true`. - `fn.both` sets both `foo` and `bar` to `true`. -- The last property in the chain takes precedence, so `fn.foo.notFoo` would result in `foo` being `false`. +- The last property in the chain takes precedence, so `fn.foo.notFoo` would result in `foo` being `false`. ##### defaults -Type: `Object` +Type: `Object`
Default: `{}` A set of default starting properties. ##### spread -Type: `boolean` +Type: `boolean`
Default: `false` By default, any arguments passed to the wrapper are passed as an array to the second argument of the wrapped function. When this is `true`, additional arguments will be spread out as additional arguments: ```js function withoutSpread(opts, args) { - let foo = args[0]; - let bar = args[1]; - // ... + let foo = args[0]; + let bar = args[1]; + // ... } function withSpread(opts, foo, bar) { - // ... + // ... } ``` #### callback -Type: `function` +Type: `Function` This callback is called with the accumulated options as the first argument. Depending on the value of `options.spread`, arguments passed to the wrapper will either be an array as the second argument or spread out as the 2nd, 3rd, 4th... arguments. @@ -116,14 +117,15 @@ This callback is called with the accumulated options as the first argument. Depe If supplied, the `target` object is extended with the property getters and returned. Otherwise a wrapper function is created for `options.defaults`, then that wrapper is extended and returned. -*Hint:* If you want to extend a `target` and add a method that simply uses the defaults, add a chainable method definition with an empty spec: +*Hint:* If you want to extend a `target` and add a method that simply uses the defaults, add a chainable method definition with an empty spec: ```js const chainableMethods = { - defaultMethodName: {} + defaultMethodName: {} } ``` + ## License -MIT © [James Talmage](http://github.com/jamestalmage) +MIT © [James Talmage](https://github.com/jamestalmage) -- cgit v1.2.3