{
  "_args": [
    [
      "thunky@^0.1.0",
      "D:\\Downloads\\Programas\\NodeJS\\node_modules\\peerflix\\node_modules\\multicast-dns"
    ]
  ],
  "_from": "thunky@>=0.1.0 <0.2.0",
  "_id": "thunky@0.1.0",
  "_inCache": true,
  "_installable": true,
  "_location": "/peerflix/thunky",
  "_npmUser": {
    "email": "mathiasbuus@gmail.com",
    "name": "mafintosh"
  },
  "_npmVersion": "1.2.11",
  "_phantomChildren": {},
  "_requested": {
    "name": "thunky",
    "raw": "thunky@^0.1.0",
    "rawSpec": "^0.1.0",
    "scope": null,
    "spec": ">=0.1.0 <0.2.0",
    "type": "range"
  },
  "_requiredBy": [
    "/peerflix/fs-chunk-store",
    "/peerflix/multicast-dns",
    "/peerflix/random-access-file"
  ],
  "_resolved": "https://registry.npmjs.org/thunky/-/thunky-0.1.0.tgz",
  "_shasum": "bf30146824e2b6e67b0f2d7a4ac8beb26908684e",
  "_shrinkwrap": null,
  "_spec": "thunky@^0.1.0",
  "_where": "D:\\Downloads\\Programas\\NodeJS\\node_modules\\peerflix\\node_modules\\multicast-dns",
  "author": {
    "email": "mathiasbuus@gmail.com",
    "name": "Mathias Buus Madsen"
  },
  "bugs": {
    "url": "https://github.com/mafintosh/thunky/issues"
  },
  "dependencies": {},
  "description": "delay the evaluation of a paramless async function and cache the result",
  "devDependencies": {},
  "directories": {},
  "dist": {
    "shasum": "bf30146824e2b6e67b0f2d7a4ac8beb26908684e",
    "tarball": "https://registry.npmjs.org/thunky/-/thunky-0.1.0.tgz"
  },
  "homepage": "https://github.com/mafintosh/thunky#readme",
  "keywords": [
    "async",
    "cache",
    "control",
    "flow",
    "lazy",
    "memo",
    "thunk"
  ],
  "maintainers": [
    {
      "name": "mafintosh",
      "email": "mathiasbuus@gmail.com"
    }
  ],
  "name": "thunky",
  "optionalDependencies": {},
  "readme": "# thunky\n\nDelay the evaluation of a paramless async function and cache the result (see [thunk](http://en.wikipedia.org/wiki/Thunk_%28functional_programming%29)).\n\n\tnpm install thunky\n\n## Example\n\nLet's make a simple function that returns a random number 1 second after it is called for the first time\n\n``` js\nvar thunky = require('thunky');\n\nvar test = thunky(function(callback) { // the inner function should only accept a callback\n\tconsole.log('waiting 1s and returning random number');\n\tsetTimeout(function() {\n\t\tcallback(Math.random());\n\t}, 1000);\n});\n\ntest(function(num) {  // inner function is called the first time we call test\n\tconsole.log(num); // prints random number\n});\n\ntest(function(num) {  // subsequent calls waits for the first call to finish and return the same value\n\tconsole.log(num); // prints the same random number as above\n});\n```\n\n## Lazy evaluation\n\nThunky makes it easy to implement a lazy evaluation pattern.\n\n``` js\nvar getDb = thunky(function(callback) {\n\tdb.open(myConnectionString, callback);\n});\n\nvar queryDb = function(query, callback) {\n\tgetDb(function(err, db) {\n\t\tif (err) return callback(err);\n\t\tdb.query(query, callback);\n\t});\n};\n\nqueryDb('some query', function(err, result) { ... } );\n\nqueryDb('some other query', function(err, result) { ... } );\n```\n\nThe first time `getDb` is called it will try do open a connection to the database.\nAny subsequent calls will just wait for the first call to complete and then call your callback.\n\nA nice property of this pattern is that it *easily* allows us to pass any error caused by `getDb` to the `queryDb` callback.\n\n## Error → No caching\n\nIf the thunk callback is called with an `Error` object as the first argument it will not cache the result\n\n``` js\nvar fails = thunky(function(callback) {\n\tconsole.log('returning an error');\n\tcallback(new Error('bad stuff'));\n});\n\nfails(function(err) { // inner function is called\n\tconsole.log(err);\n});\n\nfails(function(err) { // inner function is called again as it returned an error before\n\tconsole.log(err);\n});\n```\n\n## License\n\nMIT",
  "readmeFilename": "README.md",
  "repository": {
    "type": "git",
    "url": "git://github.com/mafintosh/thunky.git"
  },
  "version": "0.1.0"
}
