{"_id":"@astronomer/partitioned-buffer","_rev":"10-cba7c556913435a0310f9e7c6c56129a","name":"@astronomer/partitioned-buffer","description":"A class that encapsulates several sub-buffers that are partitioned by a specified key","dist-tags":{"latest":"3.0.0"},"versions":{"2.0.0":{"name":"@astronomer/partitioned-buffer","version":"2.0.0","description":"A class that encapsulates several sub-buffers that are partitioned by a specified key","main":"lib/index.js","scripts":{"test":"mocha test/test.js","test-watch":"mocha -w test/test.js"},"author":{"name":"Alois Barreras"},"license":"MIT","dependencies":{},"devDependencies":{"chai":"^3.5.0","eslint":"^3.19.0","eslint-config-airbnb":"^14.1.0","eslint-plugin-import":"^2.2.0","eslint-plugin-jsx-a11y":"^4.0.0","eslint-plugin-react":"^6.10.3","mocha":"^3.0.2","sinon":"^1.17.5"},"gitHead":"c6f8856e7dcb2bd1603f3ff3b41ddc861389e35a","_id":"@astronomer/partitioned-buffer@2.0.0","_shasum":"c8d3558dd8d5bfa44dbc0f850533b12cbb758642","_from":".","_npmVersion":"4.2.0","_nodeVersion":"7.9.0","_npmUser":{"name":"aloisatastronomer","email":"alois@astronomer.io"},"dist":{"shasum":"c8d3558dd8d5bfa44dbc0f850533b12cbb758642","tarball":"https://registry.npmjs.org/@astronomer/partitioned-buffer/-/partitioned-buffer-2.0.0.tgz","integrity":"sha512-wQPvvWDlvPfvCDowZtl98IF4+WHNwcKn5NngIupndOgAK10zSXZHOWXQN+Sr/s1A6YDgL366hl1FX4aWQf9iww==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDcKCt4t8qBMg38iZTj+HB/CVaARAYYZ/UJFwe5d0DRYAiEAxWfAUJt5aiUMySIlWTtArtaqjbUpgg8juOYzyuiHSyI="}]},"maintainers":[{"name":"aloisatastronomer","email":"alois@astronomer.io"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/partitioned-buffer-2.0.0.tgz_1493061949374_0.6705800415948033"},"directories":{}},"3.0.0":{"name":"@astronomer/partitioned-buffer","version":"3.0.0","description":"A class that encapsulates several sub-buffers that are partitioned by a specified key","main":"lib/index.js","scripts":{"lint":"eslint lib","test":"mocha test/test.js","test-watch":"mocha -w test/test.js","prepublish":"npm run lint && npm test"},"author":{"name":"Alois Barreras"},"license":"MIT","dependencies":{},"devDependencies":{"chai":"^4.0.2","eslint":"^3.19.0","eslint-config-airbnb":"^15.0.1","eslint-config-import":"^0.13.0","eslint-plugin-import":"^2.3.0","eslint-plugin-jsx-a11y":"^5.0.3","eslint-plugin-react":"^7.0.1","mocha":"^3.4.2","sinon":"^2.3.2"},"gitHead":"3b497543e4fd7a267b0953e158cadcedc3583d8f","_id":"@astronomer/partitioned-buffer@3.0.0","_npmVersion":"5.0.3","_nodeVersion":"8.0.0","_npmUser":{"name":"aloisatastronomer","email":"alois@astronomer.io"},"dist":{"integrity":"sha512-lbvGf1hTnwfsL1+IAHxBCUnudV7ndN4MgH9Irw68HRLD50niT5zmn2qBELNEbXVy3+3/PMpybRjbcbehdh/9Tw==","shasum":"346093f5f9b292441bbc3640808eea8a792d0f0c","tarball":"https://registry.npmjs.org/@astronomer/partitioned-buffer/-/partitioned-buffer-3.0.0.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIAfyFaxOPFJnBNsjduEBrplvhORuahwLAwZsPZu2Ld8UAiAlO9KafOQeg4/4ycnjA4/kaSHmONM0WzMchLEFtCAH7A=="}]},"maintainers":[{"name":"aloisatastronomer","email":"alois@astronomer.io"},{"name":"gregatastronomer","email":"greg@astronomer.io"},{"name":"mikeperry","email":"mike@astronomer.io"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/partitioned-buffer-3.0.0.tgz_1496776483526_0.3609019909054041"},"directories":{}}},"readme":"[![CircleCI](https://circleci.com/gh/astronomerio/partitioned-buffer.svg?style=svg)](https://circleci.com/gh/astronomerio/partitioned-buffer)\n\n# partitioned-buffer\n\n### Description\nPartitioned buffer is an object that maintains an internal list of sub buffers partitioned by a key you specify. Each sub buffer can store its own separate data and emit the data according to criteria you specify.\n\n### Installation\n\n```javascript\nnpm install astronomerio/partitioned-buffer#1.0.0\n```\n\n### Usage\n\n#### Creating a partitioned buffer\n\nImport the main class from 'partitioned-buffer' and instantiate it with a \"flush\" callback that will be invoked any time an internal buffer emits its data.\nThe callback function is fit to handle returning a Promise or be marked as 'async'.\n\n```javascript\nimport PartitionedBuffer from '@astronomerio/partitioned-buffer';\n\nconst partitionedBuffer = new PartitionedBuffer(function (data, key) {\n  // do something with data, such as put to s3\n  // data is the array of all the records you pushed onto the buffer\n  // key is the key by which this buffer was partitioned\n});\n```\n\nYou can optionally pass in an options object as the second parameter in the constructor. The options specify the criteria for when an internal buffer will emit its data.\n\n```javascript\nconst options = {\n  maxBytesPerFlush: 500000,\n  maxRecordsPerFlush: 500,\n  maxMillisPerFlush = 300000 // 5 minutes\n};\n```\n\n#### Pushing data onto the buffer\n\nSimply call ```partitionedBuffer.push(key, data)``` and supply a key that will reference the internal buffer which stores the data. The partitioned buffer does not perform any transormations on the data, it will emit the exact data you passed in.\n\n```javascript\npartitionedBuffer.push('h2jkl345hl', { event_name: 'track', timestamp: '09/22/2016' });\n```\n\n### License\n\n&copy; Copyright Astronomer, Inc 2016\n\nYou may use, copy and redistribute this library under the [MIT license](http://www.opensource.org/licenses/MIT).\n","maintainers":[{"email":"ryan@ryanahamilton.com","name":"ryanahamilton"},{"email":"sam@sam.black","name":"samblackk"},{"email":"greg@astronomer.io","name":"gregatastronomer"}],"time":{"modified":"2022-06-12T14:49:35.192Z","created":"2017-04-24T19:25:49.595Z","2.0.0":"2017-04-24T19:25:49.595Z","3.0.0":"2017-06-06T19:14:43.598Z"},"author":{"name":"Alois Barreras"},"license":"MIT","readmeFilename":"README.md"}