pax_global_header00006660000000000000000000000064134503451150014513gustar00rootroot0000000000000052 comment=992f4fff58bfb1a63645f319834e6191510296b9 concat-iterator-2.0.1/000077500000000000000000000000001345034511500146115ustar00rootroot00000000000000concat-iterator-2.0.1/.gitignore000066400000000000000000000000371345034511500166010ustar00rootroot00000000000000node_modules/ DB/ .nyc_output/ concat-iterator-2.0.1/.travis.yml000066400000000000000000000001351345034511500167210ustar00rootroot00000000000000sudo: false language: node_js node_js: - 6 - 8 - 10 after_success: npm run coverage concat-iterator-2.0.1/CHANGELOG.md000066400000000000000000000035221345034511500164240ustar00rootroot00000000000000# Changelog ## [Unreleased][unreleased] ## [2.0.1] - 2019-04-01 ### Changed - Upgrade `standard` devDependency from `^11.0.1` to `^12.0.1` ([`6b957cf`](https://github.com/Level/concat-iterator/commit/6b957cf)) ([**@vweevers**](https://github.com/vweevers)) - Apply common project tweaks ([#12](https://github.com/Level/concat-iterator/issues/12), [#13](https://github.com/Level/concat-iterator/issues/13), [`0c1d4e0`](https://github.com/Level/concat-iterator/commit/0c1d4e0)) ([**@vweevers**](https://github.com/vweevers)) ### Added - Add `nyc` and `coveralls` ([#11](https://github.com/Level/concat-iterator/issues/11), [`a3e312a`](https://github.com/Level/concat-iterator/commit/a3e312a)) ([**@ralphtheninja**](https://github.com/ralphtheninja), [**@vweevers**](https://github.com/vweevers)) ### Removed - Remove node 9 from travis ([`0347b82`](https://github.com/Level/concat-iterator/commit/0347b82)) ([**@ralphtheninja**](https://github.com/ralphtheninja)) ## [2.0.0] - 2018-06-27 ### Changed - Detect end by checking key and value ([**@vweevers**](https://github.com/vweevers)) - Use `level` in example instead of `leveldown` ([**@ralphtheninja**](https://github.com/ralphtheninja)) - End iterator if next errors ([**@ralphtheninja**](https://github.com/ralphtheninja)) ### Removed - Remove custom `nextTick` parameter ([**@ralphtheninja**](https://github.com/ralphtheninja)) ### Added - Add `homepage` and `repository` to `package.json` ([**@ralphtheninja**](https://github.com/ralphtheninja)) - Add `UPGRADING.md` ([**@ralphtheninja**](https://github.com/ralphtheninja)) ## 1.0.0 - 2018-06-24 :seedling: Initial release. [unreleased]: https://github.com/Level/concat-iterator/compare/v2.0.1...HEAD [2.0.1]: https://github.com/Level/concat-iterator/compare/v2.0.0...v2.0.1 [2.0.0]: https://github.com/Level/concat-iterator/compare/v1.0.0...v2.0.0 concat-iterator-2.0.1/CONTRIBUTORS.md000066400000000000000000000011141345034511500170650ustar00rootroot00000000000000# Contributors | Name | GitHub | Social | | :------------------- | :----------------------------------------------------- | :--------------------------------------------------------- | | **Lars-Magnus Skog** | [**@ralphtheninja**](https://github.com/ralphtheninja) | [**@ralph@social.weho.st**](https://social.weho.st/@ralph) | | **Vincent Weevers** | [**@vweevers**](https://github.com/vweevers) | [**@vweevers@twitter**](https://twitter.com/vweevers) | concat-iterator-2.0.1/LICENSE.md000066400000000000000000000021301345034511500162110ustar00rootroot00000000000000# The MIT License (MIT) **Copyright © 2018-present [Contributors](CONTRIBUTORS.md).** Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. concat-iterator-2.0.1/README.md000066400000000000000000000055441345034511500161000ustar00rootroot00000000000000# level-concat-iterator > Concatenate items from an iterator into an array. [![level badge][level-badge]](https://github.com/Level/awesome) [![npm](https://img.shields.io/npm/v/level-concat-iterator.svg?label=&logo=npm)](https://www.npmjs.com/package/level-concat-iterator) [![Node version](https://img.shields.io/node/v/level-concat-iterator.svg)](https://www.npmjs.com/package/level-concat-iterator) [![Travis](https://img.shields.io/travis/Level/concat-iterator.svg?logo=travis&label=)](https://travis-ci.org/Level/concat-iterator) [![Coverage Status](https://coveralls.io/repos/github/Level/concat-iterator/badge.svg)](https://coveralls.io/github/Level/concat-iterator) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com) [![npm](https://img.shields.io/npm/dm/level-concat-iterator.svg?label=dl)](https://www.npmjs.com/package/level-concat-iterator) [![Backers on Open Collective](https://opencollective.com/level/backers/badge.svg?color=orange)](#backers) [![Sponsors on Open Collective](https://opencollective.com/level/sponsors/badge.svg?color=orange)](#sponsors) ## Usage ```js var concat = require('level-concat-iterator') var level = require('level') level('DB', function (err, db) { db.put('foo', 'bar', function (err) { concat(db.iterator(), function (err, data) { console.log(data) }) }) }) ``` **If you are upgrading:** please see [`UPGRADING.md`](UPGRADING.md). ## API ### `concat(iterator, cb)` Takes an `abstract-leveldown` compatible `iterator` as first parameter and calls back with an array of keys and values. Calls back with an error if `iterator.next(cb)` or `iterator.end(cb)` errors. ## Contributing [`Level/concat-iterator`](https://github.com/Level/concat-iterator) is an **OPEN Open Source Project**. This means that: > Individuals making significant and valuable contributions are given commit-access to the project to contribute as they see fit. This project is more like an open wiki than a standard guarded open source project. See the [Contribution Guide](https://github.com/Level/community/blob/master/CONTRIBUTING.md) for more details. ## Donate To sustain [`Level`](https://github.com/Level) and its activities, become a backer or sponsor on [Open Collective](https://opencollective.com/level). Your logo or avatar will be displayed on our 28+ [GitHub repositories](https://github.com/Level), [npm](https://www.npmjs.com/) packages and (soon) [our website](http://leveldb.org). 💖 ### Backers [![Open Collective backers](https://opencollective.com/level/backers.svg?width=890)](https://opencollective.com/level) ### Sponsors [![Open Collective sponsors](https://opencollective.com/level/sponsors.svg?width=890)](https://opencollective.com/level) ## License [MIT](LICENSE.md) © 2018-present [Contributors](CONTRIBUTORS.md). [level-badge]: http://leveldb.org/img/badge.svg concat-iterator-2.0.1/UPGRADING.md000066400000000000000000000003561345034511500164570ustar00rootroot00000000000000# Upgrade Guide This document describes breaking changes and how to upgrade. For a complete list of changes including minor and patch releases, please refer to the [changelog](CHANGELOG.md). ## v2 The `nextTick` parameter was removed. concat-iterator-2.0.1/example.js000066400000000000000000000004361345034511500166050ustar00rootroot00000000000000var level = require('level') var concat = require('.') level('DB', function (err, db) { if (err) throw err db.put('foo', 'bar', function (err) { if (err) throw err concat(db.iterator(), function (err, data) { if (err) throw err console.log(data) }) }) }) concat-iterator-2.0.1/index.js000066400000000000000000000005641345034511500162630ustar00rootroot00000000000000module.exports = function (iterator, cb) { var data = [] var next = function () { iterator.next(function (err, key, value) { if (err || (key === undefined && value === undefined)) { return iterator.end(function (err2) { cb(err || err2, data) }) } data.push({ key: key, value: value }) next() }) } next() } concat-iterator-2.0.1/package.json000066400000000000000000000020371345034511500171010ustar00rootroot00000000000000{ "name": "level-concat-iterator", "version": "2.0.1", "description": "Concatenate items from an iterator into an array.", "author": "Lars-Magnus Skog ", "license": "MIT", "main": "index.js", "scripts": { "test": "standard && hallmark && nyc node test", "coverage": "nyc report --reporter=text-lcov | coveralls", "hallmark": "hallmark --fix", "dependency-check": "dependency-check . test.js", "prepublishOnly": "npm run dependency-check" }, "devDependencies": { "coveralls": "^3.0.2", "dependency-check": "^3.3.0", "hallmark": "^0.1.0", "level-community": "^3.0.0", "nyc": "^13.3.0", "standard": "^12.0.1", "tape": "^4.9.1" }, "hallmark": { "community": "level-community" }, "repository": { "type": "git", "url": "https://github.com/Level/concat-iterator.git" }, "homepage": "https://github.com/Level/concat-iterator", "keywords": [ "level", "concatenate", "iterator", "array" ], "engines": { "node": ">=6" } } concat-iterator-2.0.1/test.js000066400000000000000000000047201345034511500161310ustar00rootroot00000000000000var test = require('tape') var collect = require('.') test('calls back with error if iterator.next errors', function (t) { t.plan(3) var iterator = { next: function (cb) { t.pass('iterator.next called') process.nextTick(cb, new Error('iterator.next')) }, end: function (cb) { t.pass('iterator.end called') process.nextTick(cb) } } collect(iterator, function (err) { t.is(err.message, 'iterator.next', 'correct error') }) }) test('happy path calls back with an array', function (t) { t.plan(6) var i = 0 var data = [ { key: 'key1', value: 'value1' }, { key: 'key2', value: 'value2' } ] var iterator = { next: function (cb) { t.pass('iterator.next called') if (i < data.length) { process.nextTick(cb, null, data[i].key, data[i].value) ++i } else { process.nextTick(cb) } }, end: function (cb) { t.pass('iterator.end called') process.nextTick(cb) } } collect(iterator, function (err, result) { t.error(err, 'no error') t.same(result, data) }) }) test('calls back with error and data if iterator.end errors', function (t) { t.plan(6) var i = 0 var data = [ { key: 'key1', value: 'value1' }, { key: 'key2', value: 'value2' } ] var iterator = { next: function (cb) { t.pass('iterator.next called') if (i < data.length) { process.nextTick(cb, null, data[i].key, data[i].value) ++i } else { process.nextTick(cb) } }, end: function (cb) { t.pass('iterator.end called') process.nextTick(cb, new Error('iterator.end')) } } collect(iterator, function (err, result) { t.is(err.message, 'iterator.end', 'correct error') t.same(result, data) }) }) test('calls back with error and partial data if iterator.end errors', function (t) { t.plan(5) var i = 0 var data = [ { key: 'key1', value: 'value1' }, { key: 'key2', value: 'value2' } ] var iterator = { next: function (cb) { t.pass('iterator.next called') if (i === 0) { process.nextTick(cb, null, data[i].key, data[i].value) i++ } else { process.nextTick(cb) } }, end: function (cb) { t.pass('iterator.end called') process.nextTick(cb, new Error('foo')) } } collect(iterator, function (err, result) { t.is(err.message, 'foo', 'correct error') t.same(result, [].concat(data[0])) }) })