Gathering detailed insights and metrics for pop-iterate
Gathering detailed insights and metrics for pop-iterate
Gathering detailed insights and metrics for pop-iterate
Gathering detailed insights and metrics for pop-iterate
npm install pop-iterate
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
3 Stars
4 Commits
2 Watching
1 Branches
1 Contributors
Updated on 19 Aug 2024
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
-12.3%
89,112
Compared to previous day
Last week
5.2%
555,663
Compared to previous week
Last month
8.6%
2,234,017
Compared to previous month
Last year
-32%
28,363,887
Compared to previous year
1
This JavaScript package exports an iterator operator that accepts arrays and any object that implements iterate.
$ npm install --save pop-iterate
The iterate operator accepts an array, or object that implements iterate, and returns an iterator, as described by the iterator protocol, with some extensions. The iterations have an index property with the index corresponding to the value.
1var iterator = iterate([1, 2, 3]); 2expect(iterator.next()).toEqual({value: 1, done: false, index: 0}); 3expect(iterator.next()).toEqual({value: 2, done: false, index: 1}); 4expect(iterator.next()).toEqual({value: 3, done: false, index: 2}); 5expect(iterator.next()).toEqual({done: true});
Iterating on an array, the iterate method accepts optional start, stop, and step arguments.
1var array = [1, 2, 3, 4, 5, 6, 7, 8]; 2var iterator = iterate(array, 1, 6, 2); 3expect(iterator.next()).toEqual({value: 2, done: false, index: 1}); 4expect(iterator.next()).toEqual({value: 4, done: false, index: 3}); 5expect(iterator.next()).toEqual({value: 6, done: false, index: 5}); 6expect(iterator.next()).toEqual({done: true});
The iterate operator also iterates the owned properties of an object.
1var object = {a: 10, b: 20, c: 30};
2var iterator = iterate(object);
3expect(iterator.next()).toEqual({value: 10, done: false, index: "a"});
4expect(iterator.next()).toEqual({value: 20, done: false, index: "b"});
5expect(iterator.next()).toEqual({value: 30, done: false, index: "c"});
6expect(iterator.next()).toEqual({done: true});
A well-planned system of objects is beautiful: a system where every meaningful method for an object has been anticipated in the design. Inevitably, another layer of architecture introduces a new concept and with it the temptation to monkey-patch, dunk-punch, or otherwise cover-up the omission. But reaching backward in time, up through the layers of architecture doesn't always compose well, when different levels introduce concepts of the same name but distinct behavior.
A polymorphic operator is a function that accepts as its first argument an object and varies its behavior depending on its type. Such an operator has the benefit of covering for the types from higher layers of architecture, but defers to the eponymous method name of types yet to be defined.
The iterate operator works for arrays and objects.
Any other object can be iterable by implementing the iterate
method, and the
iterate operator will defer to it.
1function Collection() {}
2Collection.prototype.iterate = function (start, stop, step) {
3};
This package also exports the individual parts form which it makes iterators.
1var Iteration = require("pop-iterate/iteration"); 2var ArrayIterator = require("pop-iterate/array-iterator"); 3var ObjectIterator = require("pop-iterate/object-iterator");
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
Found 0/4 approved changesets -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
license file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More