Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
The 'it-all' npm package is a utility that collects all items from an async iterable into an array. It is particularly useful when working with streams or other asynchronous data sources where you need to gather all the data into a single array for further processing.
Collecting async iterable into an array
This feature allows you to collect all items from an async iterable into an array. The code sample demonstrates how to use 'it-all' to gather values from an async generator function into a single array.
const itAll = require('it-all');
async function example() {
const asyncIterable = async function* () {
yield 1;
yield 2;
yield 3;
};
const result = await itAll(asyncIterable());
console.log(result); // [1, 2, 3]
}
example();
'stream-to-array' is a package that converts a stream into an array. It is similar to 'it-all' but is specifically designed for Node.js streams. While 'it-all' works with any async iterable, 'stream-to-array' is more specialized for stream objects.
'concat-stream' is another package that collects all data from a stream and concatenates it into a single buffer or string. It is similar to 'it-all' in that it gathers data into a single entity, but it is more focused on streams and can handle different types of data (buffers, strings, etc.).
'bl' (Buffer List) is a package that collects data from a stream into a single buffer. It is similar to 'it-all' in that it aggregates data, but it is specifically designed for handling binary data in streams.
Collects all values from an (async) iterable and returns them as an array
$ npm i it-all
For when you need a one-liner to collect iterable values.
import all from 'it-all'
// This can also be an iterator, async iterator, generator, etc
const values = [0, 1, 2, 3, 4]
const arr = await all(values)
console.info(arr) // 0, 1, 2, 3, 4
Licensed under either of
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
FAQs
Collects all values from an (async) iterable and returns them as an array
We found that it-all demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.