{"_id":"pull-window","_rev":"21-b17260e4bc6be2047d8bf1d775573120","name":"pull-window","description":"Aggregate a pull-stream into windows.","dist-tags":{"latest":"2.1.4"},"versions":{"1.0.0":{"name":"pull-window","description":"group pull-stream chunks into length or time windows.","version":"1.0.0","homepage":"https://github.com/dominictarr/pull-window","repository":{"type":"git","url":"git://github.com/dominictarr/pull-window.git"},"dependencies":{"pull-stream":"~2.9.0"},"devDependencies":{},"scripts":{"test":"set -e; for t in test/*.js; do node $t; done"},"author":{"name":"Dominic Tarr","email":"dominic.tarr@gmail.com","url":"http://dominictarr.com"},"license":"MIT","_id":"pull-window@1.0.0","dist":{"shasum":"d5676127e193e1e6ce0cf696c309e57daedf218d","tarball":"https://registry.npmjs.org/pull-window/-/pull-window-1.0.0.tgz","integrity":"sha512-d2hl0UXoKi0eFF6Y7N5HzfHewh/0HH52lYDt+I1tJi409JdTwTWlVlj5AW2H2UpiVyOrI6wKAG4yp69nZtD5dQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCK5n6nYqIIzkXhEV/YG8UCwSliRhEst724R6m75Q02kQIhAIAFQprxZ6P2dIkE9r5B5X6+esRd3hgBhXxm/G7AkFhG"}]},"_from":".","_npmVersion":"1.2.3","_npmUser":{"name":"dominictarr","email":"dominic.tarr@gmail.com"},"maintainers":[{"name":"dominictarr","email":"dominic.tarr@gmail.com"}]},"1.0.1":{"name":"pull-window","description":"group pull-stream chunks into length or time windows.","version":"1.0.1","homepage":"https://github.com/dominictarr/pull-window","repository":{"type":"git","url":"git://github.com/dominictarr/pull-window.git"},"dependencies":{"pull-stream":"~2.9.0"},"devDependencies":{},"scripts":{"test":"set -e; for t in test/*.js; do node $t; done"},"author":{"name":"Dominic Tarr","email":"dominic.tarr@gmail.com","url":"http://dominictarr.com"},"license":"MIT","_id":"pull-window@1.0.1","dist":{"shasum":"8c6249756c6f5ed801a82f32843093362c9a9dea","tarball":"https://registry.npmjs.org/pull-window/-/pull-window-1.0.1.tgz","integrity":"sha512-OPx6UjN8N4CYXdIKiZa2+9x8Zeh49sq/dHT/GUsYR22Ipe4mM2rsEibwGfXsOgOb9U0JIqg7EZLynyebbtZkjg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBIbWXRD1nSfH+DCvpXwUfKLH+5zHaU5EhPyaguzzxlLAiAlpsZj1P736IksXd8kBJ5fJCHjWx0OCnxsVwcA8wwP5g=="}]},"_from":".","_npmVersion":"1.2.3","_npmUser":{"name":"dominictarr","email":"dominic.tarr@gmail.com"},"maintainers":[{"name":"dominictarr","email":"dominic.tarr@gmail.com"}]},"1.0.2":{"name":"pull-window","description":"group pull-stream chunks into length or time windows.","version":"1.0.2","homepage":"https://github.com/dominictarr/pull-window","repository":{"type":"git","url":"git://github.com/dominictarr/pull-window.git"},"dependencies":{"pull-stream":"~2.10"},"devDependencies":{},"scripts":{"test":"set -e; for t in test/*.js; do node $t; done"},"author":{"name":"Dominic Tarr","email":"dominic.tarr@gmail.com","url":"http://dominictarr.com"},"license":"MIT","_id":"pull-window@1.0.2","dist":{"shasum":"5995b9982a061fede4afd291737be46d2d752b07","tarball":"https://registry.npmjs.org/pull-window/-/pull-window-1.0.2.tgz","integrity":"sha512-aBBSjHJSxqeMBgu9cknMw2+5+/hisv51N1gIGuaWyFCH6JLqEktHbrw8W01Al+/XP1MBPhGHrtBi6RZa26MX9A==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCK22HZ9C7+kDUFP34yXPMM5O/C8+B7UL0TKySIgLbenAIgFmtR9jkVR7KJQfx8VDmH0/DZATwzucfKqqjOXH05svw="}]},"_from":".","_npmVersion":"1.2.3","_npmUser":{"name":"dominictarr","email":"dominic.tarr@gmail.com"},"maintainers":[{"name":"dominictarr","email":"dominic.tarr@gmail.com"}]},"1.0.3":{"name":"pull-window","description":"group pull-stream chunks into length or time windows.","version":"1.0.3","homepage":"https://github.com/dominictarr/pull-window","repository":{"type":"git","url":"git://github.com/dominictarr/pull-window.git"},"dependencies":{"pull-core":"~1.0.0"},"devDependencies":{"pull-stream":"~2.18","tape":"~1.0.2"},"scripts":{"test":"set -e; for t in test/*.js; do node $t; done"},"author":{"name":"Dominic Tarr","email":"dominic.tarr@gmail.com","url":"http://dominictarr.com"},"license":"MIT","_id":"pull-window@1.0.3","dist":{"shasum":"b1a116b2dbd56448824778314b2fd832f6811f0e","tarball":"https://registry.npmjs.org/pull-window/-/pull-window-1.0.3.tgz","integrity":"sha512-MD1yOcTdnpLjsdsQJ+RE24Ls1xHB7cN32aML+6sB8csywbXIbfC5mRHnSO5bgDZGJn/3756rtvj4e0ZInUex0g==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCdxaFCM9jSo2ZhePTwKTb8EL5SnLGKfhKm3WFSiyd9YQIgLk6b9sAvdM+e/ip+t0WAEfENDgrxMhcKeZ7DC8BMNC4="}]},"_from":".","_npmVersion":"1.2.18","_npmUser":{"name":"dominictarr","email":"dominic.tarr@gmail.com"},"maintainers":[{"name":"dominictarr","email":"dominic.tarr@gmail.com"}]},"2.0.0":{"name":"pull-window","description":"Aggregate a pull-stream into windows.","version":"2.0.0","homepage":"https://github.com/dominictarr/pull-window","repository":{"type":"git","url":"git://github.com/dominictarr/pull-window.git"},"dependencies":{"pull-core":"~1.0.0"},"devDependencies":{"pull-stream":"~2.18","tape":"~1.0.2"},"scripts":{"test":"set -e; for t in test/*.js; do node $t; done"},"author":{"name":"Dominic Tarr","email":"dominic.tarr@gmail.com","url":"http://dominictarr.com"},"license":"MIT","_id":"pull-window@2.0.0","dist":{"shasum":"37c98afa5d16ff167f629676f389116b896fea46","tarball":"https://registry.npmjs.org/pull-window/-/pull-window-2.0.0.tgz","integrity":"sha512-awNcQvgZ7rpXikfQLvoqFTB0xfo/Gz9LJfvoKL+wWFGC4QoFtlF6/AUE7H12ggxXcvIeeQSzSolmcC3hAQ3dBg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCf/d0HZ/c/SU3du0WOhUWXai+LmZtcQO8Yko4LmosaQwIgMznAvvLSiDsRbeGjWKhBX7peqATlDRkyMhR12FZxE0c="}]},"_from":".","_npmVersion":"1.2.18","_npmUser":{"name":"dominictarr","email":"dominic.tarr@gmail.com"},"maintainers":[{"name":"dominictarr","email":"dominic.tarr@gmail.com"}]},"2.1.0":{"name":"pull-window","description":"Aggregate a pull-stream into windows.","version":"2.1.0","homepage":"https://github.com/dominictarr/pull-window","repository":{"type":"git","url":"git://github.com/dominictarr/pull-window.git"},"dependencies":{"pull-core":"~1.0.0"},"devDependencies":{"pull-stream":"~2.19","tape":"~1.0.2"},"scripts":{"test":"set -e; for t in test/*.js; do node $t; done"},"author":{"name":"Dominic Tarr","email":"dominic.tarr@gmail.com","url":"http://dominictarr.com"},"license":"MIT","_id":"pull-window@2.1.0","dist":{"shasum":"99f8112df9c861a72f73cc3c7bec5237f323f35f","tarball":"https://registry.npmjs.org/pull-window/-/pull-window-2.1.0.tgz","integrity":"sha512-Z+HqmozQ7zeO9U/P/HOswiCZnXgWzLrp+LbhmlTI+zf4TC0hlHdSH5M1naMSsxKUH3MseZlcI3m/8b0dyQ390g==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIAhdqJIbd/3vme4eS+VXZKFT19a/uOJs/57kTtBwLFnHAiAlsaqRh9FyTi5yqsywxvOWyXMo38jOk4Xb0vl3qUyv3Q=="}]},"_from":".","_npmVersion":"1.2.18","_npmUser":{"name":"dominictarr","email":"dominic.tarr@gmail.com"},"maintainers":[{"name":"dominictarr","email":"dominic.tarr@gmail.com"}]},"2.1.1":{"name":"pull-window","description":"Aggregate a pull-stream into windows.","version":"2.1.1","homepage":"https://github.com/dominictarr/pull-window","repository":{"type":"git","url":"git://github.com/dominictarr/pull-window.git"},"dependencies":{"pull-core":"~1.0.0","looper":"2.0.0"},"devDependencies":{"pull-stream":"~2.20","tape":"~1.0.4"},"scripts":{"test":"set -e; for t in test/*.js; do node $t; done"},"author":{"name":"Dominic Tarr","email":"dominic.tarr@gmail.com","url":"http://dominictarr.com"},"license":"MIT","bugs":{"url":"https://github.com/dominictarr/pull-window/issues"},"_id":"pull-window@2.1.1","dist":{"shasum":"643220eb25fa720fbcaf7a4e35cef84bd0aa7934","tarball":"https://registry.npmjs.org/pull-window/-/pull-window-2.1.1.tgz","integrity":"sha512-4BomRmxvOI1kc7R/5FUnivgO9LxlFbBHbFWepVoxDl4QKZm6h5x2vVyt1LKxGn1LiCT0e5j/zGp6vmtnyTqKZg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAlUKtuBfC9Zgmd0VLkRvY05i0CLHmqbWZBtKbTIPpjpAiEAzGHHF88wFbc3oKzUSN3tEwsuGHVE2+ewj+YOqY4Ja+M="}]},"_from":".","_npmVersion":"1.3.0","_npmUser":{"name":"dominictarr","email":"dominic.tarr@gmail.com"},"maintainers":[{"name":"dominictarr","email":"dominic.tarr@gmail.com"}]},"2.1.2":{"name":"pull-window","description":"Aggregate a pull-stream into windows.","version":"2.1.2","homepage":"https://github.com/dominictarr/pull-window","repository":{"type":"git","url":"git://github.com/dominictarr/pull-window.git"},"dependencies":{"pull-core":"~1.0.0","looper":"2.0.0"},"devDependencies":{"pull-stream":"~2.20","tape":"~1.0.4"},"scripts":{"test":"set -e; for t in test/*.js; do node $t; done"},"author":{"name":"Dominic Tarr","email":"dominic.tarr@gmail.com","url":"http://dominictarr.com"},"license":"MIT","bugs":{"url":"https://github.com/dominictarr/pull-window/issues"},"_id":"pull-window@2.1.2","dist":{"shasum":"9aee40e13d5b88550f7f0db16213b0940d8d7b06","tarball":"https://registry.npmjs.org/pull-window/-/pull-window-2.1.2.tgz","integrity":"sha512-Zbc0QdTM97YR3pizoshWzeti7J9tU0z0QthOGAQ8gEOyXdqkYiCDAcFJ2qZq0EceaYiewaJK2toY+rMJWkkADQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAgr74HRnW2deyeJ3YD+w5OUvIMMVbJq8LB3Xx1KssllAiEAmcnMckzl6qDHMteGCjnyt78lZSIbtcjdixfVsgOLfEM="}]},"_from":".","_npmVersion":"1.3.0","_npmUser":{"name":"dominictarr","email":"dominic.tarr@gmail.com"},"maintainers":[{"name":"dominictarr","email":"dominic.tarr@gmail.com"}]},"2.1.3":{"name":"pull-window","description":"Aggregate a pull-stream into windows.","version":"2.1.3","homepage":"https://github.com/dominictarr/pull-window","repository":{"type":"git","url":"git://github.com/dominictarr/pull-window.git"},"dependencies":{"pull-core":"~1.0.0","looper":"2.0.0"},"devDependencies":{"pull-stream":"~2.20","tape":"~1.0.4"},"scripts":{"test":"set -e; for t in test/*.js; do node $t; done"},"author":{"name":"Dominic Tarr","email":"dominic.tarr@gmail.com","url":"http://dominictarr.com"},"license":"MIT","gitHead":"d37baaa2ea9078ca59669af97ecec3069be5ce8c","bugs":{"url":"https://github.com/dominictarr/pull-window/issues"},"_id":"pull-window@2.1.3","_shasum":"8beac25ef9d375ae46b1da1acfc3df46c0c9565c","_from":".","_npmVersion":"3.3.1","_nodeVersion":"2.3.1","_npmUser":{"name":"dominictarr","email":"dominic.tarr@gmail.com"},"maintainers":[{"name":"dominictarr","email":"dominic.tarr@gmail.com"}],"dist":{"shasum":"8beac25ef9d375ae46b1da1acfc3df46c0c9565c","tarball":"https://registry.npmjs.org/pull-window/-/pull-window-2.1.3.tgz","integrity":"sha512-fwFITFA6JBYJSbbbPSLVpzNnwZckbsl8XRNsNKN3ljIT20pp12kpjOzjxbMKUM588yK/JxKewFXqwKYlaa0QwQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIG4AfUcCkbBRepKzu+2FabHUP7o+lHkfBug+VdnvGaNRAiAkBrFj5+viGH+7DiNc/JHOqSMJqUg16m7qHVm9D6Fpvg=="}]}},"2.1.4":{"name":"pull-window","description":"Aggregate a pull-stream into windows.","version":"2.1.4","homepage":"https://github.com/dominictarr/pull-window","repository":{"type":"git","url":"git://github.com/dominictarr/pull-window.git"},"dependencies":{"looper":"^2.0.0"},"devDependencies":{"pull-stream":"^3.4.0","tape":"~1.0.4"},"scripts":{"test":"set -e; for t in test/*.js; do node $t; done"},"author":{"name":"Dominic Tarr","email":"dominic.tarr@gmail.com","url":"http://dominictarr.com"},"license":"MIT","gitHead":"19a35633f19ddf6597e0c91da36459dae862de5c","bugs":{"url":"https://github.com/dominictarr/pull-window/issues"},"_id":"pull-window@2.1.4","_shasum":"fc3b86feebd1920c7ae297691e23f705f88552f0","_from":".","_npmVersion":"3.8.6","_nodeVersion":"5.11.1","_npmUser":{"name":"dominictarr","email":"dominic.tarr@gmail.com"},"dist":{"shasum":"fc3b86feebd1920c7ae297691e23f705f88552f0","tarball":"https://registry.npmjs.org/pull-window/-/pull-window-2.1.4.tgz","integrity":"sha512-cbDzN76BMlcGG46OImrgpkMf/VkCnupj8JhsrpBw3aWBM9ye345aYnqitmZCgauBkc0HbbRRn9hCnsa3k2FNUg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBnVYhqWLnE4Ct27JnTxqKvMnKSzDIXvU91aIkm5bdLyAiBD/xnPj07y9xImWs6J/rjLNyVEF4ByxsuPL+0FLpsu4A=="}]},"maintainers":[{"name":"dominictarr","email":"dominic.tarr@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/pull-window-2.1.4.tgz_1463951602798_0.8949018174316734"}}},"readme":"# pull-window\n\nAggregate a pull-stream into windows.\n\nSeveral helpers are provided for particular types of windows,\nsliding, tumbling, etc.\n\nAnd also, a low level \n\n## Example: \"tumbling\" window\n\nsum every 10 items.\n\n``` js\nvar pull   = require('pull-stream')\nvar window = require('pull-window')\n\nfunction everyTen () {\n  var i = 0\n  //window calls init with each data item,\n  //and a callback to close that window.\n  return window(function (data, cb) {\n    //if you don't want to start a window here,\n    //return undefined\n    if(i != 0) return\n    var sum = 0\n\n    //else return a function.\n    //this will be called all data\n    //until you callback.\n    return function (end, data) {\n      if(end) return cb(null, sum)\n      sum += data\n      if(++i >= 10) {\n        i = 0\n        cb(null, sum)\n      }\n    }\n  }\n}\n\npull(\n  pull.count(1000),\n  everyTen(),\n  pull.log()\n)\n```\n\n## Example: variable sized window\n\nEach window doesn't have to be the same size...\n\n``` js\nvar pull   = require('pull-stream')\nvar window = require('pull-window')\n\nfunction groupTo100 () {\n  var sum = null\n  return window(function (_, cb) {\n    if(sum != null) return\n\n    //sum stuff together until you have 100 or more\n    return function (end, data) {\n      if(end) return cb(null, sum)\n      sum += data\n      if(sum >= 100) {\n        //copy sum like this, incase the next item\n        //comes through sync\n        var _sum = sum; sum = null\n        cb(null, _sum)\n      }\n    }\n  })\n}\n\npull(\n  pull.count(1000)\n  groupTo100(),\n  pull.log()\n)\n```\n\n## Example: sliding window\n\nto make more over lapping windows\njust return the window function more often.\n\n``` js\nvar pull   = require('pull-stream')\nvar window = require('pull-window')\n\nfunction sliding () {\n  return window(function (_, cb) {\n    var sum = 0, i = 0\n\n    //sum stuff together until you have 100 or more\n    return function (end, data) {\n      if(end) return cb(null, sum)\n      sum += data\n      if(++i >= 10) {\n        //in this example, each window gets it's own sum,\n        //so we don't need to copy it.\n        cb(null, sum)\n      }\n    }\n  })\n}\n\npull(\n  pull.count(100)\n  sliding(),\n  pull.log()\n)\n```\n\n\n## API\n\n\n### window (start, map)\n``` js\n\nwindow(function startWindow (data, cb) {\n\n  //called on each chunk\n  //including the first one\n  return function addToWindow (end, data) {\n    //cb(null, aggregate) when done.\n  }\n}, function mapWindow (start, data) {\n  //(optional)\n  //map the window to something that tracks start, also\n})\n```\n\nBy default, windows are mapped to `{start: firstData, data: aggregate}`.\nunless you pass in an different `mapWindow` function.\n\n\n### window.sliding(reduce, size)\n\nreduce every `size` items into a single value, in a sliding window\n\n### window.recent(size, time)\n\ntumbling window that groups items onto an array,\neither every `size` items, or within `time` ms,\nwhich ever occurs earliest. \n\n## License\n\nMIT\n","maintainers":[{"name":"dominictarr","email":"dominic.tarr@gmail.com"}],"time":{"modified":"2022-06-25T00:50:17.764Z","created":"2013-04-03T14:32:29.615Z","1.0.0":"2013-04-03T14:32:34.209Z","1.0.1":"2013-04-04T15:22:40.403Z","1.0.2":"2013-04-05T00:17:18.401Z","1.0.3":"2013-05-30T17:59:24.842Z","2.0.0":"2013-05-31T18:50:19.343Z","2.1.0":"2013-06-10T14:44:10.381Z","2.1.1":"2013-07-09T07:34:08.061Z","2.1.2":"2013-07-09T08:05:09.806Z","2.1.3":"2015-09-27T22:04:11.542Z","2.1.4":"2016-05-22T21:13:23.236Z"},"author":{"name":"Dominic Tarr","email":"dominic.tarr@gmail.com","url":"http://dominictarr.com"},"repository":{"type":"git","url":"git://github.com/dominictarr/pull-window.git"},"homepage":"https://github.com/dominictarr/pull-window","bugs":{"url":"https://github.com/dominictarr/pull-window/issues"},"license":"MIT","readmeFilename":"README.md"}