npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@rbxts/distinct-array

v1.1.0

Published

A TypeScript/roblox-ts array that enforces uniqueness of elements. Each value can only appear once in the array.

Readme

DistinctArray

A TypeScript/roblox-ts array that enforces uniqueness of elements. Each value can only appear once in the array.

Features

  • Unique elements: Automatically prevents duplicate values from being added
  • Fast lookups: O(1) membership testing with has() and indexOf()
  • Standard Array API: Implements familiar array methods like push, pop, forEach, map, filter
  • Unordered operations: unorderedRemove() and unorderedDelete() for O(1) removals when order doesn't matter

Installation

npm install @your-org/distinct-array

Usage

import { DistinctArray } from "@your-org/distinct-array";

// Create an empty DistinctArray
const arr = DistinctArray.create<number>();

// Add values - duplicates will throw
arr.push(1, 2, 3);
arr.push(1); // Throws: "Value already exists in array"

// Check membership - O(1) lookup
arr.has(2); // true
arr.has(4); // false

// Remove by value
arr.delete(2);
arr.has(2); // false

// Create from existing array
const arr2 = DistinctArray.fromArray([1, 2, 3]);

// Custom distinctness key (e.g., case-insensitive strings)
const caseInsensitiveArr = DistinctArray.create<string>((s) => s.lower());
caseInsensitiveArr.push("Hello");
caseInsensitiveArr.push("hello"); // Throws: "Value already exists in array"

// Objects with unique IDs
interface PlayerData { id: number; name: string }
const players = DistinctArray.create<PlayerData>((p) => p.id);
players.push({ id: 1, name: "Alice" });
players.push({ id: 1, name: "Bob" }); // Throws: "Value already exists in array"

API

Static Methods

| Method | Description | |--------|-------------| | create<T, K = T>(keyMapper?: (value: T) => K) | Creates an empty DistinctArray<T> with optional key mapper | | fromArray<T, K = T>(array: T[], keyMapper?: (value: T) => K) | Creates from an array with optional key mapper | | fromSet<T>(set: Set<T>) | Creates from a Set, but does not accept an optional key mapper |

Instance Methods

Read Methods

| Method | Description | |--------|-------------| | has(value: T): boolean | O(1) check if value exists | | includes(searchElement: T, fromIndex?: number): boolean | Check if value exists (with optional fromIndex) | | indexOf(searchElement: T, fromIndex?: number): number | Get index of value (O(1)) | | size(): number | Get the number of elements in the array | | find(predicate): T \| undefined | Find first matching element | | findIndex(predicate): number | Find index of first matching element | | every(callback): boolean | Test if all elements pass | | some(callback): boolean | Test if any element passes | | filter(callback): T[] | Return filtered array | | map<U>(callback): U[] | Return mapped array | | mapFiltered<U>(callback): NonNullable<U>[] | Map, filtering out undefined values | | forEach(callback): void | Iterate over elements | | reduce<U>(callback, initialValue): U | Reduce to single value |

Write Methods

| Method | Description | |--------|-------------| | push(...items: T[]): number | Add elements (throws on duplicates) | | pop(): T \| undefined | Remove and return last element | | shift(): T \| undefined | Remove and return first element | | unshift(...items: T[]): number | Add elements at start (throws on duplicates) | | insert(index: number, value: T): void | Insert at index (throws on duplicates) | | remove(index: number): T \| undefined | Remove at index, shifting elements | | unorderedRemove(index: number): T \| undefined | Remove at index, replacing with last (O(1)) | | delete(value: T): void | Remove by value | | unorderedDelete(value: T): void | Remove by value, replacing with last (O(1)) | | clear(): void | Remove all elements | | sort(compareFunction?): this | Sort in place |

Dependencies

This package has no external dependencies. It only uses built-in TypeScript/roblox-ts types (Array, Map, Set).

License

MIT