New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

it-al

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

it-al

A TypeScript iterable utility library providing functional programming utilities for working with iterables as well as a class based interface with an easy chainable and typed API.

latest
npmnpm
Version
1.3.11
Version published
Weekly downloads
70
94.44%
Maintainers
1
Weekly downloads
 
Created
Source

It-al

A TypeScript iterable utility library providing functional programming utilities for working with iterables as well as a class based interface with an easy chainable and typed API.

Installation

npm install it-al

Features

  • 🔄 Lazy Evaluation - Iterator-based operations are efficient and composable
  • 🍛 Currying Support - Most functions support both direct and curried forms
  • 🔗 Method Chaining - Fluent API via Iter and PeekableIter classes
  • 🏷️ Type Safe - Full TypeScript support with proper type inference
  • 🧩 Functional - Supports composition via pipe and apply

Quick Start

import { Iter, map, filter, take } from 'it-al';

// Functional style
const result = pipe([
  map((x: number) => x * 2),
  filter((x: number) => x > 5),
  take(3)
])([1, 2, 3, 4, 5, 6]);

// Method chaining style
const result2 = Iter.from([1, 2, 3, 4, 5, 6])
  .map(x => x * 2)
  .filter(x => x > 5)
  .take(3)
  .toArray();

API Reference

Transformation Functions

FunctionDescriptionSignature
mapTransform each item in an iterable<T, U>(iter: Iterable<T>, fn: IterFn<T, U>) => IterableIterator<U>
filterFilter items based on a predicate<T>(iter: Iterable<T>, fn: IterFn<T>) => IterableIterator<T>
flatFlatten nested iterables by depth<T, D>(iter: Iterable<T>, depth?: D) => IterableIterator<FlatItem<T, D>>
enumerateReturn index-value pairs<T>(iter: Iterable<T>) => IterableIterator<[number, T]>
pluckExtract a property from each item<T, K>(iter: Iterable<T>, key: K) => IterableIterator<T[K]>
tapRun side effects without modifying items<T>(iter: Iterable<T>, fn: IterFn<T>) => IterableIterator<T>
scanLike reduce but yields intermediate values<T, U>(iter: Iterable<T>, fn, start?: U) => IterableIterator<U>

Slicing & Limiting

FunctionDescriptionSignature
takeTake first n items<T>(iter: Iterable<T>, n: number) => IterableIterator<T>
skipSkip first n items<T>(iter: Iterable<T>, n: number) => IterableIterator<T>
takeWhileTake items while predicate is true<T>(iter: Iterable<T>, fn: IterFn<T>) => IterableIterator<T>
skipWhileSkip items while predicate is true<T>(iter: Iterable<T>, fn: IterFn<T>) => IterableIterator<T>
untilTake items until predicate is true<T>(iter: Iterable<T>, fn: IterFn<T>) => IterableIterator<T>
chunkSplit into chunks of size n<T>(iter: Iterable<T>, n: number) => IterableIterator<T[]>
windowsCreate sliding windows of size n<T>(iter: Iterable<T>, n: number) => IterableIterator<T[]>

Aggregation & Reduction

FunctionDescriptionSignature
reduceReduce to a single value<T, U>(iter: Iterable<T>, fn, start: U) => U
sumSum all numbers(iter: Iterable<number>) => number
productMultiply all numbers(iter: Iterable<number>) => number
averageAverage all numbers(iter: Iterable<number>) => number
countCount items<T>(iter: Iterable<T>) => number
joinJoin items into string<T>(iter: Iterable<T>, delimiter?: string) => string
groupByGroup items by key<T, U>(iter: Iterable<T>, fn) => Map<U, T[]>

Searching & Testing

FunctionDescriptionSignature
findFind first matching item<T>(iter: Iterable<T>, fn: IterFn<T>) => T | null
findIndexFind index of first match<T>(iter: Iterable<T>, fn: IterFn<T>) => number
includesCheck if value exists<T>(iter: Iterable<T>, value: T) => boolean
someTest if any item matches<T>(iter: Iterable<T>, fn: IterFn<T>) => boolean
everyTest if all items match<T>(iter: Iterable<T>, fn: IterFn<T>) => boolean
firstGet first item<T>(iter: Iterable<T>) => T
lastGet last item<T>(iter: Iterable<T>) => T | undefined
isEmptyCheck if empty(iter: Iterable<unknown>) => boolean
searchRecursively search object<U>(obj: unknown, fn) => IterableIterator<KeyValuePair<U>>

Uniqueness & Filtering

FunctionDescriptionSignature
uniqueByGet unique items by selector<T>(iter: Iterable<T>, fn: IterFn<T>) => IterableIterator<T>
partitionSplit into passed/failed arrays<T>(iter: Iterable<T>, fn: IterFn<T>) => [T[], T[]]

Combining & Zipping

FunctionDescriptionSignature
zipCombine multiple iterables<I>(...iters: I, stopOnMin?: boolean) => ZipOutput<I>
unzipTranspose iterable of arrays<T>(iter: Iterable<T>) => UnzipOutput<T>

Generation & Repetition

FunctionDescriptionSignature
rangeGenerate range of numbers(stop: number, start?: number, step?: number) => IterableIterator<number>
repeatRepeat iterable n times<T>(iter: Iterable<T>, n: number) => IterableIterator<T>
cycleCycle through iterable infinitely<T>(iter: Iterable<T>) => IterableIterator<T>
genCreate infinite generator<T>(fn: (n: number) => T) => () => IterableIterator<T>

Object/Entry Operations

FunctionDescriptionSignature
entriesGet key-value pairs<T>(input: T) => IterableIterator<Entry<T>>
allEntriesGet entries including Symbols<T>(input: T) => IterableIterator<Entry<T>>
fromEntriesCreate object from entries<K, V>(iter: Iterable<[K, V]>) => Record<K, V>

Utilities

FunctionDescriptionSignature
pipeCompose functions left-to-right<I, O>(fns: Function[]) => (item: I) => O
applyApply functions in order<I, O>(input: I, fns: Function[]) => O
peekableCreate peekable iterable<T>(iter: Iterable<T>) => Peekable<T>
isIterableCheck if value is iterable<T>(x: unknown) => x is Iterable<T>
isNonStringIterableCheck iterable (not string)<T>(x: unknown) => x is Iterable<T>
isAsyncIterableCheck if async iterable<T>(x: unknown) => x is AsyncIterable<T>

Class-Based API

Iter<T>

Chainable wrapper around iterables providing a fluent API.

Static Methods

MethodDescriptionReturn Type
Iter#from(iterable)Create an Iter from any iterableIter<T>
Iter#safeFrom(maybeIterable?)Create an Iter from unknown input, returns empty Iter if not iterableIter<T>
Iter#fromAsync(iterable)Create an Iter from async iterable or promisesIter<T>
Iter#fromEntries(obj)Create an Iter from object entriesIter<[K, V]>
Iter#safeFromEntries(obj?)Create an Iter from object entries, returns empty Iter if null/undefinedIter<[K, V]>
Iter#fromRange(stop, start?, step?)Create an Iter from a numeric rangeIter<number>
Iter#gen(fn)Create infinite Iter using generator function() => Iter<T>
Iter#zip(iterables, stopOnMin?)Zip multiple iterables into tuplesIter<[...]>
Iter#search(obj, fn, skipAfterYield?)Recursively search object for matching valuesIter<KeyValuePair<U>>

Chainable Methods

Returns a new Iter<T> instance for continued chaining.

MethodDescription
Iter#flatMap(fn)Map and flatten in one step
Iter#flat(depth?)Flatten nested iterables
Iter#map(fn)Transform each item
Iter#filter(fn)Filter items by predicate
Iter#filterNullish()Remove null and undefined values
Iter#unique()Remove duplicate values
Iter#enumerate()Add index to each item as [index, value]
Iter#uniqueBy(fn)Remove duplicates by selector function
Iter#tap(fn)Run side effects without modifying items
Iter#scan(fn, start?)Like reduce but yields intermediate values
Iter#pluck(key)Extract property from each item
Iter#take(n)Take first n items
Iter#chunk(n)Split into chunks of size n
Iter#skip(n)Skip first n items
Iter#takeWhile(fn)Take items while predicate is true
Iter#skipWhile(fn)Skip items while predicate is true
Iter#until(fn)Take items until predicate is true
Iter#windows(size)Create sliding windows of size n
Iter#apply(fn)Apply a function to the iterable
Iter#peekable()Convert to PeekableIter
Iter#repeat(times)Repeat the iterable n times
Iter#cycle()Cycle through iterable infinitely

Terminal Methods

Consumes the iterator and returns a final value.

MethodDescriptionReturn Type
Iter#first()Get the first itemT
Iter#last()Get the last itemT | undefined
Iter#find(fn)Find first item matching predicateT | null
Iter#findIndex(fn)Find index of first matchnumber
Iter#includes(value)Check if value existsboolean
Iter#count()Count total itemsnumber
Iter#isEmpty()Check if iterable is emptyboolean
Iter#forEach(fn)Like Array.forEach but for Itervoid
Iter#reduce(fn, start)Reduce to single valueU
Iter#every(fn)Test if all items match predicateboolean
Iter#some(fn)Test if any item matches predicateboolean
Iter#unzip()Transpose iterable of arraysUnzipOutput<T>
Iter#partition(fn)Split into [passed, failed] arrays[T[], T[]]
Iter#join(delimiter?)Join items into stringstring
Iter#groupBy(fn)Group items by keyMap<K, T[]>
Iter#sum()Sum all numbersnumber
Iter#product()Multiply all numbersnumber
Iter#average()Average all numbersnumber
Iter#min()Find minimum valueT
Iter#max()Find maximum valueT
Iter#collect(collector?)Collect using custom collectorU
Iter#toArray()Collect all items into an arrayT[]
Iter#toSet()Collect all items into a SetSet<T>
Iter#toMap()Collect entries into a MapMap<K, V>

PeekableIter<T>

Extends Iter<T> with the ability to peek at the next value without consuming it.

const iter = PeekableIter.from([1, 2, 3]);
console.log(iter.peek()); // 1 (doesn't consume)
console.log(iter.first()); // 1 (consumes)

Additional Method

MethodDescriptionReturn Type
PeekableIter#peek()Look at next value without consuming itT | undefined

Examples

Currying

import { map, filter, pipe } from 'it-al';

// Curried form
const double = map((x: number) => x * 2);
const isPowerOfTwo = filter((x: number) => Math.sqrt(x, 2) % 1 === 0);

const result = pipe([double, isPowerOfTwo])([1, 2, 3, 4]);
// [2, 4, 8]

Method Chaining

import { Iter } from 'it-al';

const result = Iter.from([1, 2, 3, 4, 5])
  .map(x => x * 2)
  .filter(x => x > 5)
  .take(2)
  .toArray();
// [6, 8]

Lazy Evaluation

import { map, take } from 'it-al';

const expensive = map((x: number) => {
  console.log('Processing:', x);
  return x * 2;
});

// Only processes first 3 items
const result = take(expensive([1, 2, 3, 4, 5, 6, 7, 8]), 3);

for (const _ of result) {}
// Logs: Processing: 1, 2, 3

Working with Infinite Iterators

import { Iter } from 'it-al';

// Generate infinite sequence
const randomNumbers = Iter.gen((n) => Math.random());

// Generates 10 random numbers
const first10 = fibonacci().take(10).toArray();

Grouping and Aggregation

import { Iter } from 'it-al';

const data = [
  { category: 'A', value: 10 },
  { category: 'B', value: 20 },
  { category: 'A', value: 30 },
];

const grouped = Iter.from(data).groupBy(item => item.category);
// Map { 'A' => [{...}, {...}], 'B' => [{...}] }

FAQs

Package last updated on 11 Dec 2025

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