{"_id":"option-chain","_rev":"12-fb228e017870b1882f70873772f0b066","name":"option-chain","description":"Use fluent property chains in lieu of options objects","dist-tags":{"latest":"1.0.0"},"versions":{"0.1.0":{"name":"option-chain","version":"0.1.0","description":"Use fluent property chains in lieu of options objects","license":"MIT","repository":{"type":"git","url":"git+https://github.com/jamestalmage/option-chain.git"},"author":{"name":"James Talmage","email":"james@talmage.io","url":"github.com/jamestalmage"},"engines":{"node":">=0.10.0"},"scripts":{"test":"xo && nyc --cache --reporter=lcov --reporter=text ava"},"files":["index.js"],"keywords":["option","options","chain","chains","chainable","fluent"],"devDependencies":{"ava":"^0.10.0","coveralls":"^2.11.6","nyc":"^5.3.0","xo":"^0.12.1"},"dependencies":{"object-assign":"^4.0.1"},"gitHead":"c28ac0359248441bee8b701f5a81e85b739f4deb","bugs":{"url":"https://github.com/jamestalmage/option-chain/issues"},"homepage":"https://github.com/jamestalmage/option-chain#readme","_id":"option-chain@0.1.0","_shasum":"6519de2e01f2dfa76e7c5f3bb2b2755af785d5bf","_from":".","_npmVersion":"3.5.3","_nodeVersion":"5.3.0","_npmUser":{"name":"jamestalmage","email":"james@talmage.io"},"dist":{"shasum":"6519de2e01f2dfa76e7c5f3bb2b2755af785d5bf","tarball":"https://registry.npmjs.org/option-chain/-/option-chain-0.1.0.tgz","integrity":"sha512-IYitr+umwQ7iSWzJe+KL5ul5w/Dz0jiZDUz5SLWYp/2cjj2+wop9cjwknbweUVTQzJl+mR4HaGzN8D4WbCuK7w==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFnOvUyOS6HM98kjJxz8E0iWMzCZ/nVAxXHuVnCZ1zZXAiEAhTTTNJtuoaUHSm5fNiT+vVZg3x6BziNAkEpMzCqm45U="}]},"maintainers":[{"name":"jamestalmage","email":"james@talmage.io"}],"directories":{}},"0.1.1":{"name":"option-chain","version":"0.1.1","description":"Use fluent property chains in lieu of options objects","license":"MIT","repository":{"type":"git","url":"git+https://github.com/jamestalmage/option-chain.git"},"author":{"name":"James Talmage","email":"james@talmage.io","url":"github.com/jamestalmage"},"engines":{"node":">=0.10.0"},"scripts":{"test":"xo && nyc --cache --reporter=lcov --reporter=text ava"},"files":["index.js"],"keywords":["option","options","chain","chains","chainable","fluent"],"devDependencies":{"ava":"^0.10.0","coveralls":"^2.11.6","nyc":"^5.3.0","xo":"^0.12.1"},"dependencies":{"object-assign":"^4.0.1"},"gitHead":"69666a183f9145095459562d47f5d8d5f31d1296","bugs":{"url":"https://github.com/jamestalmage/option-chain/issues"},"homepage":"https://github.com/jamestalmage/option-chain#readme","_id":"option-chain@0.1.1","_shasum":"e9b811e006f1c0f54802f28295bfc8970f8dcfbd","_from":".","_npmVersion":"3.5.3","_nodeVersion":"5.4.1","_npmUser":{"name":"jamestalmage","email":"james@talmage.io"},"dist":{"shasum":"e9b811e006f1c0f54802f28295bfc8970f8dcfbd","tarball":"https://registry.npmjs.org/option-chain/-/option-chain-0.1.1.tgz","integrity":"sha512-UsON6bnN9BuNmFV7odYf9XSKmUoaRfq/5ru5zCPK5vIzo23dtyhoWnHUBQ3cra8/W8+D33hkn/9OgKcWi2F+yg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCOo3wteuVv5UhT5Rcgyk2AZQ7tGeT6y9tQK0s0t0V4ogIgS949hMwpu+GGtNqrY+l/f6JOAUedm2apcU8QYpkpuhM="}]},"maintainers":[{"name":"jamestalmage","email":"james@talmage.io"}],"directories":{}},"1.0.0":{"name":"option-chain","version":"1.0.0","description":"Use fluent property chains in lieu of options objects","license":"MIT","repository":{"type":"git","url":"git+https://github.com/avajs/option-chain.git"},"author":{"name":"James Talmage","email":"james@talmage.io","url":"github.com/jamestalmage"},"engines":{"node":">=4"},"scripts":{"test":"xo && nyc ava"},"files":["index.js"],"keywords":["option","options","chain","chains","chainable","fluent"],"devDependencies":{"ava":"^0.19.1","coveralls":"^2.11.6","nyc":"^10.3.2","xo":"^0.18.2"},"nyc":{"reporter":["lcov","text"]},"gitHead":"c0c10c4b405594cf80d8801afb0d8f7d941b4242","bugs":{"url":"https://github.com/avajs/option-chain/issues"},"homepage":"https://github.com/avajs/option-chain#readme","_id":"option-chain@1.0.0","_shasum":"938d73bd4e1783f948d34023644ada23669e30f2","_from":".","_npmVersion":"2.15.11","_nodeVersion":"4.8.3","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"938d73bd4e1783f948d34023644ada23669e30f2","tarball":"https://registry.npmjs.org/option-chain/-/option-chain-1.0.0.tgz","integrity":"sha512-IUhG7PlO/bKThfrJE5MhhUPfVpRlbKVx42VM1oG3UWeaVvjcf0/52VKp6uQEgvr5/ThLMPWkGwPE0PJ1DSDc0A==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAq7DOJtNDymEaGPuaeirZcVeuE+vyy/ZaPoTJH2N4WJAiEA+Wg5x54ziaJAYUfXfhH/Syf8B5wSfGAnuyVJOP2mNiY="}]},"maintainers":[{"name":"jamestalmage","email":"james@talmage.io"},{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/option-chain-1.0.0.tgz_1494602408211_0.3149425445590168"},"directories":{}}},"readme":"# 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)\n\n> Use fluent property chains in lieu of options objects\n\n\n## Install\n\n```\n$ npm install --save option-chain\n```\n\n\n## Usage\n\n```js\nconst optionChain = require('option-chain');\n\nconst optionDefinition = {\n\tdefaults: {\n\t\tbar: false\n\t},\n\tchainableMethods: {\n\t\tfoo: {foo: true},\n\t\tnotFoo: {foo: false},\n\t\tbar: {bar: true}\n\t}\n};\n\nfunction printOptionsAndArgs(options, args) {\n\tconsole.log(options);\n\n\tif (args.length) {\n\t\tconsole.log(args);\n\t}\n}\n\nconst fn = optionChain(optionDefinition, printOptionsAndArgs);\n\nfn();\n//=> [{bar: false}]\nfn.bar();\n//=> [{bar: true}]\nfn.foo.bar();\n//=> [{foo: true, bar: false}]\n\nfn.foo('a', 'b');\n//=> [{foo: true, bar: false}]\n//=> ['a', 'b']\n```\n\n\n## API\n\n### optionChain(options, callback, [target])\n\n#### options\n\n##### chainableMethods\n\n*Required*<br>\nType: `Object`\n\nA map of chainable property names to the options set by adding property to the chain.\n\nGiven the following:\n\n```js\nconst chainableMethods = {\n\tfoo: {foo: true},\n\tnotFoo: {foo: false},\n\tbar: {bar: true},\n\tboth: {foo: true, bar: true}\n}\n```\n\nThen:\n\n- `fn.foo` would set `foo` to `true`.\n- `fn.bar` would set `bar` to `true`.\n- `fn.both` sets both `foo` and `bar` to `true`.\n- The last property in the chain takes precedence, so `fn.foo.notFoo` would result in `foo` being `false`.\n\n\n##### defaults\n\nType: `Object`<br>\nDefault: `{}`\n\nA set of default starting properties.\n\n##### spread\n\nType: `boolean`<br>\nDefault: `false`\n\nBy 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:\n\n```js\nfunction withoutSpread(opts, args) {\n\tlet foo = args[0];\n\tlet bar = args[1];\n\t// ...\n}\n\nfunction withSpread(opts, foo, bar) {\n\t// ...\n}\n```\n\n#### callback\n\nType: `Function`\n\nThis 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.\n\n#### target\n\nIf 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.\n\n*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:\n\n```js\nconst chainableMethods = {\n\tdefaultMethodName: {}\n}\n```\n\n\n## License\n\nMIT © [James Talmage](https://github.com/jamestalmage)\n","maintainers":[{"email":"sindresorhus@gmail.com","name":"sindresorhus"},{"email":"mark@novemberborn.net","name":"novemberborn"}],"time":{"modified":"2023-06-17T00:09:54.881Z","created":"2016-01-15T20:34:10.888Z","0.1.0":"2016-01-15T20:34:10.888Z","0.1.1":"2016-01-24T04:14:30.430Z","1.0.0":"2017-05-12T15:20:08.453Z"},"homepage":"https://github.com/avajs/option-chain#readme","keywords":["option","options","chain","chains","chainable","fluent"],"repository":{"type":"git","url":"git+https://github.com/avajs/option-chain.git"},"author":{"name":"James Talmage","email":"james@talmage.io","url":"github.com/jamestalmage"},"bugs":{"url":"https://github.com/avajs/option-chain/issues"},"license":"MIT","readmeFilename":"readme.md","users":{"wheelo":true,"flumpus-dev":true}}