Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Implements common array methods in a lazy manner. Nothing more.
There's an async version of this library as well, called lazily-async. See https://github.com/isotropy/lazily-async
npm install lazily
import { Seq } from "lazily";
const seq = Seq.of([1, 2, 3])
for (const i of seq) {
console.log(i)
}
Sequences are lazy. For example, in the following example only one map() action is performed irrespective of the length of the sequence.
const seq = Seq.of([1, 2, 3])
.map(x => x * 2)
.first();
Seq.of([1, 2, 3]).toArray()
// [1, 2, 3]
Seq.of([1, 2, 3])
.map(x => x * 2)
.toArray()
// [2, 4, 6]
Seq.of([1, 2, 3, 4])
.filter(x => x > 2)
.toArray()
//[3, 4]
Seq.of([1, 2, 3, 4, 5])
.exit(x => x > 3)
.toArray()
// [1, 2, 3]
Similar to exit(), but includes the last item as well.
Seq.of([1, 2, 3, 4, 5])
.exitAfter(x => x > 3)
.toArray()
// [1, 2, 3, 4]
Seq.of([1, 2, 3, 4, 5]).find(x => x * 10 === 30)
// 3
Seq.of([1, 2, 3, 4, 5])
.reduce((acc, x) => acc + x, 0)
// 15
Seq.of([1, 2, 3, 4, 5])
.reduce((acc, x) => acc + x, 0, acc => acc > 6)
// 10
Seq.of([1, 2, 3, 4, 5]).first();
// 1
Seq.of([1, 2, 3, 4, 5]).first(x => x > 3);
// 4
Seq.of([1, 2, 3, 4, 5]).last();
// 5
Seq.of([1, 2, 3, 4, 5]).last(x => x < 3);
// 2
Seq.of([1, 2, 3, 4, 5]).every(x => x <= 5);
// true
Seq.of([1, 2, 3, 4, 5]).some(x => x === 3);
// true
Seq.of([1, 2, 3, 4, 5]).includes(3);
// true
Seq.of([1, 2, 3, 4, 5]).concat(Seq.of([6, 7, 8])).toArray();
// [1, 2, 3, 4, 5, 6, 7, 8]
Seq.of([1, 2, 3]).reverse().toArray();
// [3, 2, 1]
Seq.of([1, 2, 3, 4, 5, 6]).slice(2, 4).toArray();
// [3, 4, 5]
FAQs
Implements common array methods in a lazy manner. Nothing more.
The npm package lazily receives a total of 3 weekly downloads. As such, lazily popularity was classified as not popular.
We found that lazily 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
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.