0.0.3 • Published 3 years ago

no-stream v0.0.3

Weekly downloads
-
License
BSD-3-Clause
Repository
github
Last release
3 years ago

no-stream

Like stream, but no stream.

English | 中文

feature

  • Similar to array, easy to use.
  • Support async.
  • Efficient.

install

npm install no-stream

usage

import { ns } from "no-stream";

const s = ns(function* () {
  let x = 0;
  while (true) {
    yield x++;
  }
}); // ns([0, 1, 2...])

const result = s
  .map((x) => x * 2)
  .filter((x) => x % 4 === 0)
  .take(10)
  .reduce((r, x) => r + x, 0);

console.log(result); // 180

benchmark

Benchmark which map n times and reduce once. from benchmark.ts

array

map times \ ops/sec \ array length100100010000100000
21159961230412462184
3184536190751947140
4151335133331561114
512772012334135990.35

no-stream

map times \ ops/sec \ array length100100010000100000
2400500452954820481
3276977343943599349
4216729265272751265
5180349225852199224

no-stream is more efficient!

document