{"name":"data.maybe","version":"1.2.0","description":"A structure for values that may not be available or computations that may fail.","main":"lib/index.js","scripts":{"test":"make test"},"repository":{"type":"git","url":"https://github.com/folktale/data.maybe"},"keywords":["monads","maybe","fantasy-land","option","folktale"],"author":{"name":"Quildreen Motta"},"license":"MIT","bugs":{"url":"https://github.com/folktale/data.maybe/issues"},"dependencies":{},"devDependencies":{"browserify":"^3.38.0","LiveScript":"~1.2.0","hifive-tap":"~0.1.0","hifive":"~0.1.0","uglify-js":"~2.4.3","laws":"~0.2.0","claire":"~0.4.1","ink-docstrap":"git://github.com/robotlolita/docstrap","jsdoc":"^3.3.0-alpha5"},"_id":"data.maybe@1.2.0","dist":{"shasum":"98b3b2220516c5837b341f3dc5b8c484e14b0451","tarball":"http://registry-npm.ywwl.com/data.maybe/download/data.maybe-1.2.0.tgz","integrity":"sha512-tj71/KP5kkOBSVMggjbeoQmqRKCl2QWdiD75bRm2i8QJfB9Gp8H57T9Gn7pnQ/kZzD/BtOnV+z2vWdefZjdtsQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD/A81ZFs5JWMmLD+2QihVn0RqaMTyd+51JILXCmhKpfAIhAJt1XzJbhvTt9HinWIFGbGdKZ5cXEICLrLN9fNmPMHR2"}],"size":8893,"noattachment":false,"key":"/data.maybe/-/data.maybe-1.2.0.tgz"},"_from":".","_npmVersion":"1.3.10","_npmUser":{"name":"killdream","email":"quildreen@gmail.com"},"maintainers":[{"name":"killdream","email":"quildreen@gmail.com"}],"directories":{},"deprecated":"This package is no longer supported. Consider switching to fp-ts","readme":"Data.Maybe\n==========\n\n[![Build Status](https://secure.travis-ci.org/folktale/data.maybe.png?branch=master)](https://travis-ci.org/folktale/data.maybe)\n[![NPM version](https://badge.fury.io/js/data.maybe.png)](http://badge.fury.io/js/data.maybe)\n[![Dependencies Status](https://david-dm.org/folktale/data.maybe.png)](https://david-dm.org/folktale/data.maybe)\n[![stable](http://hughsk.github.io/stability-badges/dist/stable.svg)](http://github.com/hughsk/stability-badges)\n\n\nA structure for values that may not be present, or computations that may\nfail. `Maybe(a)` explicitly models the effects that implicit in `Nullable`\ntypes, thus has none of the problems associated with using `null` or\n`undefined` — like `NullPointerException` or `TypeError`.\n\nFurthermore, being a Monad, `Maybe(a)` can be composed in manners similar to\nother monads, by using the generic sequencing and composition operations\nprovided for the common interface in\n[Fantasy Land](https://github.com/fantasyland/fantasy-land).\n\n\n## Example\n\n```js\nvar Maybe = require('data.maybe')\n\n// :: [a], (a -> Bool) -> Maybe(a)\nfunction find(collection, predicate) {\n  for (var i = 0; i < collection.length; ++i) {\n    var item = collection[i]\n    if (predicate(item))  return Maybe.Just(item)\n  }\n  return Maybe.Nothing()\n}\n\nvar numbers = [-2, -1, 0, 1, 2]\nvar a = find(numbers, function(a){ return a > 5 })\nvar b = find(numbers, function(a){ return a === 0 })\n\n// Call a function only if both a and b\n// have values (sequencing)\na.chain(function(x) {\n  return b.chain(function(y) {\n    doSomething(x, y)\n  })\n})\n\n// Transform values only if they're available:\na.map(function(x){ return x + 1 })\n// => Maybe.Nothing\nb.map(function(x){ return x + 1 })\n// => Maybe.Just(1)\n\n// Use a default value if no value is present\na.orElse(function(){ return Maybe.Just(-1) })\n// => Maybe.Just(-1)\nb.orElse(function(){ return Maybe.Just(-1) })\n// => Maybe.Just(0)\n```\n\n\n## Installing\n\nThe easiest way is to grab it from NPM. If you're running in a Browser\nenvironment, you can use [Browserify][]:\n\n    $ npm install data.maybe\n\n\n### Using with CommonJS\n\nIf you're not using NPM, [Download the latest release][release], and require\nthe `data.maybe.umd.js` file:\n\n```js\nvar Maybe = require('data.maybe')\n```\n\n\n### Using with AMD\n\n[Download the latest release][release], and require the `data.maybe.umd.js`\nfile:\n\n```js\nrequire(['data.maybe'], function(Maybe) {\n  ( ... )\n})\n```\n\n\n### Using without modules\n\n[Download the latest release][release], and load the `data.maybe.umd.js`\nfile. The properties are exposed in the global `folktale.data.Maybe` object:\n\n```html\n<script src=\"/path/to/data.maybe.umd.js\"></script>\n```\n\n\n### Compiling from source\n\nIf you want to compile this library from the source, you'll need [Git][],\n[Make][], [Node.js][], and run the following commands:\n\n    $ git clone git://github.com/folktale/data.maybe.git\n    $ cd data.maybe\n    $ npm install\n    $ make bundle\n\nThis will generate the `dist/data.maybe.umd.js` file, which you can load in\nany JavaScript environment.\n\n\n## Documentation\n\nYou can [read the documentation online][docs] or build it yourself:\n\n    $ git clone git://github.com/folktale/data.maybe.git\n    $ cd data.maybe\n    $ npm install\n    $ make documentation\n\nThen open the file `docs/index.html` in your browser.\n\n\n## Platform support\n\nThis library assumes an ES5 environment, but can be easily supported in ES3\nplatforms by the use of shims. Just include [es5-shim][] :)\n\n\n## Licence\n\nCopyright (c) 2013 Quildreen Motta.\n\nReleased under the [MIT licence](https://github.com/folktale/data.maybe/blob/master/LICENCE).\n\n<!-- links -->\n[Fantasy Land]: https://github.com/fantasyland/fantasy-land\n[Browserify]: http://browserify.org/\n[Git]: http://git-scm.com/\n[Make]: http://www.gnu.org/software/make/\n[Node.js]: http://nodejs.org/\n[es5-shim]: https://github.com/kriskowal/es5-shim\n[docs]: http://folktalegithubio.readthedocs.io/en/latest/api/data/maybe/index.html\n<!-- [release: https://github.com/folktale/data.maybe/releases/download/v$VERSION/data.maybe-$VERSION.tar.gz] -->\n[release]: https://github.com/folktale/data.maybe/releases/download/v1.2.1/data.maybe-1.2.1.tar.gz\n<!-- [/release] -->\n","publish_time":1418515173038,"_cnpm_publish_time":1418515173038,"dist-tags":{"latest":"1.2.3"}}