{"_id":"option","_rev":"3013959","name":"option","description":"The option type, also known as the maybe type, for JavaScript","dist-tags":{"latest":"0.2.4"},"maintainers":[{"name":"mwilliamson","email":""}],"time":{"modified":"2023-09-20T03:43:06.000Z","created":"2012-08-25T21:39:34.536Z","0.2.4":"2017-06-23T10:04:02.764Z","0.2.3":"2016-02-25T19:01:12.216Z","0.2.2":"2015-06-12T21:34:16.507Z","0.2.1":"2013-04-14T11:36:32.149Z","0.2.0":"2012-08-25T21:39:34.536Z"},"users":{},"author":{"name":"Michael Williamson","email":"mike@zwobble.org"},"repository":{"type":"git","url":"https://github.com/mwilliamson/node-options.git"},"versions":{"0.2.4":{"name":"option","version":"0.2.4","author":{"name":"Michael Williamson","email":"mike@zwobble.org"},"description":"The option type, also known as the maybe type, for JavaScript","license":"BSD-2-Clause","scripts":{"test":"nodeunit test"},"repository":{"type":"git","url":"https://github.com/mwilliamson/node-options.git"},"dependencies":{},"devDependencies":{"nodeunit":"latest"},"keywords":["option","maybe"],"bugs":{"url":"https://github.com/mwilliamson/node-options/issues"},"homepage":"https://github.com/mwilliamson/node-options","_id":"option@0.2.4","dist":{"shasum":"fd475cdf98dcabb3cb397a3ba5284feb45edbfe4","size":3159,"noattachment":false,"key":"/option/-/option-0.2.4.tgz","tarball":"http://registry.cnpm.dingdandao.com/option/download/option-0.2.4.tgz"},"_from":".","_npmVersion":"1.4.3","_npmUser":{"name":"mwilliamson","email":"mike@zwobble.org"},"maintainers":[{"name":"mwilliamson","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/option-0.2.4.tgz_1498212241831_0.6175427781417966"},"directories":{},"publish_time":1498212242764,"_hasShrinkwrap":false,"_cnpm_publish_time":1498212242764,"_cnpmcore_publish_time":"2021-12-16T21:21:45.623Z"},"0.2.3":{"name":"option","version":"0.2.3","author":{"name":"Michael Williamson","email":"mike@zwobble.org"},"description":"The option type, also known as the maybe type, for JavaScript","license":"BSD","scripts":{"test":"nodeunit test"},"repository":{"type":"git","url":"https://github.com/mwilliamson/node-options.git"},"dependencies":{},"devDependencies":{"nodeunit":"latest"},"keywords":["option","maybe"],"bugs":{"url":"https://github.com/mwilliamson/node-options/issues"},"homepage":"https://github.com/mwilliamson/node-options","_id":"option@0.2.3","dist":{"shasum":"605ea40fb982522cf3fb132a6c6d9bd147cd0db4","size":2949,"noattachment":false,"key":"/option/-/option-0.2.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/option/download/option-0.2.3.tgz"},"_from":".","_npmVersion":"1.4.3","_npmUser":{"name":"mwilliamson","email":"mike@zwobble.org"},"maintainers":[{"name":"mwilliamson","email":""}],"_npmOperationalInternal":{"host":"packages-9-west.internal.npmjs.com","tmp":"tmp/option-0.2.3.tgz_1456426869491_0.7838449715636671"},"directories":{},"publish_time":1456426872216,"_hasShrinkwrap":false,"_cnpm_publish_time":1456426872216,"_cnpmcore_publish_time":"2021-12-16T21:21:45.834Z"},"0.2.2":{"name":"option","version":"0.2.2","author":{"name":"Michael Williamson","email":"mike@zwobble.org"},"description":"The option type, also known as the maybe type, for JavaScript","license":"BSD","scripts":{"test":"nodeunit test"},"repository":{"type":"git","url":"https://github.com/mwilliamson/node-options.git"},"dependencies":{},"devDependencies":{"nodeunit":"latest"},"keywords":["option","maybe"],"bugs":{"url":"https://github.com/mwilliamson/node-options/issues"},"homepage":"https://github.com/mwilliamson/node-options","_id":"option@0.2.2","dist":{"shasum":"95d0a962814d52a84787c77aae3ebd9b5e7d3f78","size":2831,"noattachment":false,"key":"/option/-/option-0.2.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/option/download/option-0.2.2.tgz"},"_from":".","_npmVersion":"1.4.3","_npmUser":{"name":"mwilliamson","email":"mike@zwobble.org"},"maintainers":[{"name":"mwilliamson","email":""}],"directories":{},"publish_time":1434144856507,"_hasShrinkwrap":false,"_cnpm_publish_time":1434144856507,"_cnpmcore_publish_time":"2021-12-16T21:21:46.042Z"},"0.2.1":{"name":"option","version":"0.2.1","author":{"name":"Michael Williamson","email":"mike@zwobble.org"},"description":"The option type, also known as the maybe type, for JavaScript","license":"BSD","repository":{"type":"git","url":"https://github.com/mwilliamson/node-options.git"},"dependencies":{},"devDependencies":{"nodeunit":"latest"},"keywords":["option","maybe"],"readmeFilename":"README.md","_id":"option@0.2.1","dist":{"shasum":"7d65ced92bd052cefe50b20d9461898dd7f17ec0","size":2480,"noattachment":false,"key":"/option/-/option-0.2.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/option/download/option-0.2.1.tgz"},"_from":".","_npmVersion":"1.2.14","_npmUser":{"name":"mwilliamson","email":"mike@zwobble.org"},"maintainers":[{"name":"mwilliamson","email":""}],"directories":{},"publish_time":1365939392149,"_hasShrinkwrap":false,"_cnpm_publish_time":1365939392149,"_cnpmcore_publish_time":"2021-12-16T21:21:46.229Z"},"0.2.0":{"name":"option","version":"0.2.0","dependencies":{},"devDependencies":{"nodeunit":"latest"},"keywords":["option","maybe"],"_id":"option@0.2.0","description":"An implementation of the option type, sometimes known as the maybe type.","dist":{"shasum":"c35a43a6f580ca775bf913fad7f2ccd36ed21c65","size":1603,"noattachment":false,"key":"/option/-/option-0.2.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/option/download/option-0.2.0.tgz"},"maintainers":[{"name":"mwilliamson","email":""}],"directories":{},"publish_time":1345930774536,"_hasShrinkwrap":false,"_cnpm_publish_time":1345930774536,"_cnpmcore_publish_time":"2021-12-16T21:21:46.465Z"}},"readme":"# options for node.js\n\nAn implementation of the option type, sometimes known as the maybe type.\n\nAn instance of an option type is an optional value. Either it's `none`, or an\ninstance of `Some`:\n\n```javascript\nvar option = require(\"option\");\n\nvar some = option.some(\"Bob\");\nvar none = option.none;\n```   \n\nA function that returns an optional string isn't that different from a function\nthat returns a string or `null`. The advantage over null is that options\nprovide a number of functions that help with manipulating optional values.\n\n```javascript\n    function greet(user) {\n        return \"Hello \" + user.name().valueOrElse(\"Anonymous\");\n    }\n```\n\n## Methods\n\n### isNone() and isSome()\n\n* `some(value).isNone()` returns `false`\n* `some(value).isSome()` returns `true`\n* `none.isNone()` returns `true`\n* `none.isSome()` returns `false`\n\n### value()\n\n* `some(value).value()` returns `value`\n* `none.value()` throws an error\n\n### map(*func*)\n\n* `some(value).map(func)` returns `some(func(value))`\n* `none.map(func)` returns `none`\n\n### flatMap(*func*)\n\nConventionally used when `func` returns another option.\n\n* `some(value).flatMap(func)` returns `func(value)`\n* `none.flatMap(func)` returns `none`\n\n### filter(*predicate*)\n\n* `some(value).filter(predicate)` returns:\n  * `some(value)` if `predicate(value) === true`\n  * `none` if `predicate(value) === false`\n* `none.filter(predicate)` returns `none`\n\n### toArray()\n\n* `some(value).toArray()` returns `[some]`\n* `none.toArray()` returns `[]`\n\n### orElse(*other*)\n\nIf `other` is a function (`other` conventionally returning another option):\n\n* `some(value).orElse(other)` returns `some(value)`\n* `none.orElse(other)` returns `other()`\n\nIf `other` is not a function (`other` conventionally being another option):\n\n* `some(value).orElse(other)` returns `some(value)`\n* `none.orElse(other)` returns `other`\n\n### valueOrElse(*other*)\n\nIf `other` is a function:\n\n* `some(value).valueOrElse(other)` returns `value`\n* `none.valueOrElse(other)` returns `other()`\n\nIf `other` is not a function:\n\n* `some(value).valueOrElse(other)` returns `value`\n* `none.valueOrElse(other)` returns `other`\n\n## Functions\n\n### option.isOption(*value*)\n\n* `option.isOption(value)` returns `true` if `value` is `option.none` or `option.some(x)`.\n\n### option.fromNullable(*value*)\n\n* If `value` is `null` or `undefined`, `option.fromNullable(value)` returns `option.none`.\n* Otherwise, returns `option.some(value)`.\n  For instance, `option.fromNullable(5)` returns `option.some(5)`.\n\n## Installation\n\n    npm install option\n","_attachments":{},"homepage":"https://github.com/mwilliamson/node-options","bugs":{"url":"https://github.com/mwilliamson/node-options/issues"},"license":"BSD-2-Clause"}