{"_id":"checkpoint-stream","_rev":"2991362","name":"checkpoint-stream","description":"Queue data from a stream until a checkpoint is hit","dist-tags":{"latest":"0.1.2"},"maintainers":[{"name":"stephenplusplus","email":""}],"time":{"modified":"2023-08-28T09:17:53.000Z","created":"2016-12-22T17:02:10.166Z","0.1.2":"2019-01-18T14:32:21.772Z","0.1.1":"2017-01-06T17:30:10.971Z","0.1.0":"2016-12-22T17:02:10.166Z"},"users":{},"author":{"name":"Stephen Sawchuk","email":"sawchuk@gmail.com"},"versions":{"0.1.2":{"name":"checkpoint-stream","version":"0.1.2","description":"Queue data from a stream until a checkpoint is hit","main":"index.js","scripts":{"lint":"standard","test":"mocha *.test.js"},"keywords":["queue","stream","checkpoint"],"author":{"name":"Stephen Sawchuk","email":"sawchuk@gmail.com"},"license":"MIT","devDependencies":{"async":"^2.1.4","mocha":"^3.2.0","standard":"^8.6.0"},"dependencies":{"@types/pumpify":"^1.4.1","events-intercept":"^2.0.0","pumpify":"^1.3.5","split-array-stream":"^1.0.0","through2":"^2.0.3"},"standard":{"global":["after","before","beforeEach","describe","it"]},"gitHead":"e386253b4f5ffc8bad870bcd5e2fbddc6822976d","_id":"checkpoint-stream@0.1.2","_npmVersion":"6.4.1","_nodeVersion":"10.11.0","_npmUser":{"name":"stephenplusplus","email":"stephenplusplusplus@gmail.com"},"dist":{"shasum":"5e2359456e5df4f3ec34c62bf1573e07df6e5039","size":3092,"noattachment":false,"key":"/checkpoint-stream/-/checkpoint-stream-0.1.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/checkpoint-stream/download/checkpoint-stream-0.1.2.tgz"},"maintainers":[{"name":"stephenplusplus","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/checkpoint-stream_0.1.2_1547821941681_0.29584743806523717"},"_hasShrinkwrap":false,"publish_time":1547821941772,"_cnpm_publish_time":1547821941772,"_cnpmcore_publish_time":"2021-12-16T20:57:27.605Z"},"0.1.1":{"name":"checkpoint-stream","version":"0.1.1","description":"Queue data from a stream until a checkpoint is hit","main":"index.js","scripts":{"lint":"standard","test":"mocha *.test.js"},"keywords":["queue","stream","checkpoint"],"files":["index.js"],"author":{"name":"Stephen Sawchuk","email":"sawchuk@gmail.com"},"license":"MIT","devDependencies":{"async":"^2.1.4","mocha":"^3.2.0","standard":"^8.6.0"},"dependencies":{"events-intercept":"^2.0.0","pumpify":"^1.3.5","split-array-stream":"^1.0.0","through2":"^2.0.3"},"standard":{"global":["after","before","beforeEach","describe","it"]},"gitHead":"bf2f7ca35981d764462f1c696e10a24f271301b4","_id":"checkpoint-stream@0.1.1","_shasum":"59088511fbe23b6d2c1e82eaf02f28459667f637","_from":".","_npmVersion":"3.10.8","_nodeVersion":"6.9.1","_npmUser":{"name":"stephenplusplus","email":"sawchuk@gmail.com"},"dist":{"shasum":"59088511fbe23b6d2c1e82eaf02f28459667f637","size":2809,"noattachment":false,"key":"/checkpoint-stream/-/checkpoint-stream-0.1.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/checkpoint-stream/download/checkpoint-stream-0.1.1.tgz"},"maintainers":[{"name":"stephenplusplus","email":""}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/checkpoint-stream-0.1.1.tgz_1483723810362_0.5433475042227656"},"directories":{},"publish_time":1483723810971,"_hasShrinkwrap":false,"_cnpm_publish_time":1483723810971,"_cnpmcore_publish_time":"2021-12-16T20:57:27.831Z"},"0.1.0":{"name":"checkpoint-stream","version":"0.1.0","description":"Queue data from a stream until a checkpoint is hit","main":"index.js","scripts":{"lint":"standard","test":"mocha *.test.js"},"keywords":["queue","stream","checkpoint"],"files":["index.js"],"author":{"name":"Stephen Sawchuk","email":"sawchuk@gmail.com"},"license":"MIT","devDependencies":{"async":"^2.1.4","mocha":"^3.2.0","standard":"^8.6.0"},"dependencies":{"events-intercept":"^2.0.0","pumpify":"^1.3.5","split-array-stream":"^1.0.0","through2":"^2.0.3"},"standard":{"global":["after","before","beforeEach","describe","it"]},"gitHead":"c8e50b5ccb3c5a42548865c6f63db9ef657a01e2","_id":"checkpoint-stream@0.1.0","_shasum":"4669c7b0ec659931a1ea8b720f9f30e5a832906a","_from":".","_npmVersion":"3.10.8","_nodeVersion":"6.9.1","_npmUser":{"name":"stephenplusplus","email":"sawchuk@gmail.com"},"dist":{"shasum":"4669c7b0ec659931a1ea8b720f9f30e5a832906a","size":2824,"noattachment":false,"key":"/checkpoint-stream/-/checkpoint-stream-0.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/checkpoint-stream/download/checkpoint-stream-0.1.0.tgz"},"maintainers":[{"name":"stephenplusplus","email":""}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/checkpoint-stream-0.1.0.tgz_1482426129550_0.6830837407615036"},"directories":{},"publish_time":1482426130166,"_hasShrinkwrap":false,"_cnpm_publish_time":1482426130166,"_cnpmcore_publish_time":"2021-12-16T20:57:28.062Z"}},"readme":"# checkpoint-stream\n> Queue data from a stream until a checkpoint is hit\n\n```sh\n$ npm install --save checkpoint-stream\n```\n```js\nvar checkpoint = require('checkpoint-stream')\n\n// getObjectsStream() returns a stream that emits multiple objects\n// this will queue up those objects until we reach a checkpoint\n// once the `isCheckpointFn` test passes, the queue is flushed\n\ngetObjectsStream()\n  .on('error', function() {...})\n  .pipe(checkpoint.obj(function(obj) {\n    return typeof obj.token !== 'undefined'\n  }))\n  .on('checkpoint', function(obj) {\n    // the obj from `getObjectsStream()` that passed the `isCheckpointFn` test\n  })\n  .on('data', function(obj) {\n    // emitted for each object\n  })\n```\n\n### Why would I want this?\n\nSay you're working with a streaming API that returns many results. Anywhere during transmission, the API call could fail. The API knows this, so it periodically returns a token you can use when you retry the request.\n\nWhen you get a result that has that token, that's kind of like a \"checkpoint\". It means, release all the results we've received up until now, because we know we'll be able to pick up from here when we go to retry the request.\n\n## API\n\n### checkpointStream(config)\n\n- Returns `TransformStream` (via [`through2`](http://gitnpm.com/through2))\n\n### checkpointStream.obj(config)\n\n- Returns `TransformStream` (via [`through2`](http://gitnpm.com/through2))\n\n#### config\n\n- **Required**\n- Type: `Object` or `Function`\n\nA configuration object. If a function is provided, it is treated as `config.isCheckpointFn`.\n\n##### config.isCheckpointFn\n\n- **Required**\n- Type: `Function`\n\nThis function will receive each data event that is emitted from the source stream. Return a boolean to indicate if this is a checkpoint or not. If it is a checkpoint, this event, and any previously queued events before it will be passed through to the next stream in your pipeline. If it is not a checkpoint, this event will be queued until you return `true` in a future data event.\n\n##### config.maxQueued\n\n- *Optional*\n- Type: `Number`\n- Default: `10`\n\nConfigure how many results will be queued before they are released, regardless of if a checkpoint has been reached.\n\n##### config.objectMode\n\n- *Optional*\n- Type: `Boolean`\n- Default: `false`\n\nEnable `objectMode` when dealing with streams in object mode.\n","_attachments":{},"license":"MIT"}