
Security News
OpenGrep Restores Fingerprinting in JSON and SARIF Outputs
OpenGrep has restored fingerprint and metavariable support in JSON and SARIF outputs, making static analysis more effective for CI/CD security automation.
Lazy iteration in JavaScript.
Based heavily on the Rust iterator trait.
Lazyer allows for lazy iteration.
It can be used for working with finite sequences:
const lazy = require('lazyer');
lazy.for(people)
.filter(person => person.age >= 65)
.map(person => `${person.firstName} ${person.lastName}`)
.map(name => name.toUpperCase())
.forEach(name => console.log(name));
// That was all one iteration!
And infinite sequences:
const lazy = require('lazyer');
const fibonacci = lazy.range(0, Infinity)
.scan(([a, b]) => [b, a + b], [0, 1])
.map(([a]) => a)
.take(10)
.collect();
console.log(fibonacci);
// → [1, 1, 2, 3, 5, 8, 13, 21, 34, 55]
Works with anything iterable:
const lazy = require('lazyer');
const string = 'Hello World!';
const set = new Set(string);
const map = lazy.range(0)
.zip(set)
.collectMap();
console.log(map);
/* → Map {
0 => 'H',
1 => 'e',
2 => 'l',
3 => 'o',
4 => ' ',
5 => 'W',
6 => 'r',
7 => 'd',
8 => '!' } */
And does a bunch of useful things:
const lazy = require('lazyer');
const longest = lazy.for(listOfListOfNodes)
.flatten()
.flatMap(node => node.children)
.max(node => node.data.length);
console.log(longest);
// Simple!
Functions that create a lazy iterator.
for
of
range
repeat
repeatWith
iterate
Methods that adapt the iterator.
A consumer needs to be called before any of these will be executed.
stepBy
skip
take
skipWhile
takeWhile
chunk
enumerate
concat
cycle
map
filter
scan
zip
flatten
flatMap
join
joinWith
each
Methods that consume the iterator.
These methods start the iteration.
next
peek
at
count
last
forEach
reduce
sum
product
find
findIndex
every
some
max
min
maxBy
minBy
collect
partition
unzip
group
categorize
clone
cloneMany
See the documented source code.
And for examples, see the test file.
FAQs
Lazy iteration in JavaScript.
The npm package lazyer receives a total of 3 weekly downloads. As such, lazyer popularity was classified as not popular.
We found that lazyer demonstrated a not healthy version release cadence and project activity because the last version was released 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
OpenGrep has restored fingerprint and metavariable support in JSON and SARIF outputs, making static analysis more effective for CI/CD security automation.
Security News
Security experts warn that recent classification changes obscure the true scope of the NVD backlog as CVE volume hits all-time highs.
Security Fundamentals
Attackers use obfuscation to hide malware in open source packages. Learn how to spot these techniques across npm, PyPI, Maven, and more.