Skip to main content
Home

@exts/list@0.3.5

latest

An expensive alternative to basic arrays in TypeScript. Includes various methods and properties to make List manipulation easy, chainable, and readable.

This package works with Node.js, Deno, BrowsersIt is unknown whether this package works with Cloudflare Workers, Bun
It is unknown whether this package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
It is unknown whether this package works with Bun
This package works with Browsers
JSR Score
70%
Published
a year ago (0.3.5)

This module provides a list data structure, which can be used instead of an array. A list is more computationally expensive than a regular array, but contains various methods and properties, which make manipulating list data simple, chainable, and readable.

Examples

Example 1

import { List } from "@exts/list";

const myList = new List(10, 20, 30, 40);
myList.push(50);
console.log(myList.last) // 50
console.log(myList.indexOfLast) // 4

// explicit return typing is necessary for some methods
// because TypeScript cannot infer the type of `item` from the type of `item.value`
myList.find((item): item is Item<number> => item.value > 10)!.value // 20
myList.find((item): item is Item<number> => item.value > 10)!.index // 1

// skip the first found item
myList.find((item): item is Item<number> => item.value > 10, 1)!.value // 30

myList.fromUntil(item => item.value === 10, item => item.value === 30)
 .values // [10, 20, 30]

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@exts/list

Import symbol

import * as list from "@exts/list";
or

Import directly with a jsr specifier

import * as list from "jsr:@exts/list";

Add Package

pnpm i jsr:@exts/list
or (using pnpm 10.8 or older)
pnpm dlx jsr add @exts/list

Import symbol

import * as list from "@exts/list";

Add Package

yarn add jsr:@exts/list
or (using Yarn 4.8 or older)
yarn dlx jsr add @exts/list

Import symbol

import * as list from "@exts/list";

Add Package

vlt install jsr:@exts/list

Import symbol

import * as list from "@exts/list";

Add Package

npx jsr add @exts/list

Import symbol

import * as list from "@exts/list";

Add Package

bunx jsr add @exts/list

Import symbol

import * as list from "@exts/list";