Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
obliterator
Advanced tools
The 'obliterator' npm package provides a set of utilities for working with iterables and iterators in JavaScript. It offers a variety of functions to manipulate, transform, and handle iterables efficiently.
Iterate
The 'iterate' function allows you to create an iterator from an iterable object like an array. This example demonstrates how to iterate over an array using the iterator's next() method.
const iterate = require('obliterator/iterate');
const array = [1, 2, 3, 4];
const iterator = iterate(array);
let result = iterator.next();
while (!result.done) {
console.log(result.value);
result = iterator.next();
}
Range
The 'range' function generates an iterator that produces numbers within a specified range. This example shows how to create an iterator that yields numbers from 1 to 4.
const range = require('obliterator/range');
const iterator = range(1, 5);
let result = iterator.next();
while (!result.done) {
console.log(result.value);
result = iterator.next();
}
Take
The 'take' function allows you to take a specified number of elements from an iterable. This example demonstrates how to take the first 3 elements from an array.
const take = require('obliterator/take');
const array = [1, 2, 3, 4, 5];
const result = take(array, 3);
console.log(result); // [1, 2, 3]
Filter
The 'filter' function creates an iterator that yields only the elements that satisfy a given predicate. This example shows how to filter out odd numbers from an array.
const filter = require('obliterator/filter');
const array = [1, 2, 3, 4, 5];
const iterator = filter(array, x => x % 2 === 0);
let result = iterator.next();
while (!result.done) {
console.log(result.value);
result = iterator.next();
}
The 'iter-tools' package provides a comprehensive set of utilities for working with iterables and iterators. It offers a wide range of functions for transforming, filtering, and combining iterables, similar to 'obliterator'. However, 'iter-tools' has a larger set of features and more extensive documentation.
The 'lazy.js' package is a utility library for working with lazy sequences. It allows you to create and manipulate sequences in a lazy manner, meaning computations are deferred until necessary. While 'lazy.js' offers similar functionalities to 'obliterator', it focuses more on lazy evaluation and chaining operations.
The 'lodash' package is a popular utility library that provides a wide range of functions for manipulating arrays, objects, and other data structures. Although 'lodash' is not specifically focused on iterables and iterators, it offers many similar functions for transforming and filtering data.
Obliterator is a dead simple JavaScript library providing miscellaneous higher-order iterator functions such as combining two or more iterators into a single one.
npm install --save obliterator
Variadic function chaining all the given iterators.
import chain from 'obliterator/chain';
// Or
import {chain} from 'obliterator';
const set1 = new Set('a');
const set2 = new Set('bc');
const chained = chain(set1.values(), set2.values());
chained.next();
>>> {done: false, value: 'a'}
chained.next();
>>> {done: false, value: 'b'}
Function consuming the given iterator and returning its values in an array.
import consume from 'obliterator/consume';
// Or
import {consume} from 'obliterator';
const set = new Set([1, 2, 3]);
consume(set.values());
>>> [1, 2, 3]
Contributions are obviously welcome. Please be sure to lint the code & add the relevant unit tests before submitting any PR.
git clone git@github.com:Yomguithereal/obliterator.git
cd obliterator
npm install
# To lint the code
npm run lint
# To run the unit tests
npm test
FAQs
Higher order iterator library for JavaScript/TypeScript.
The npm package obliterator receives a total of 2,343,908 weekly downloads. As such, obliterator popularity was classified as popular.
We found that obliterator 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
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.