Socket
Socket
Sign inDemoInstall

obliterator

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

obliterator

Higher order iterator library for JavaScript/TypeScript.


Version published
Maintainers
1
Created

What is obliterator?

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.

What are obliterator's main functionalities?

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();
}

Other packages similar to obliterator

Keywords

FAQs

Package last updated on 03 May 2022

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc