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

@twisuki/neo-filter

v1.0.2

Published

A lightweight, chainable, synchronous array filter utility for elegant data processing

Readme

neo-filter

A lightweight, chainable, synchronous array filter utility with multi-field sorting, pagination, and OR-branch support.

Install

pnpm install @twisuki/neo-filter

Quick Start

import { Filter } from "@twisuki/neo-filter";

const results = new Filter<DataItem>(rawData)
  .filter((item) => item.active)
  .sorter("createdAt", "DESC")
  .offset(0)
  .limit(10)
  .all();

API

filter(predicate)

Adds a filter predicate to the operation chain. Multiple filter() calls compose with AND logic — an item must satisfy every predicate.

new Filter(students)
  .filter((s) => s.subject1 >= 60)
  .filter((s) => s.subject2 >= 60)
  .all();

sorter(key, direction)

Adds a sort rule. Rules are appended in insertion order as comparison priority. When two items are equal under the highest-priority rule, the next rule breaks the tie.

Repeating the same key updates only its direction, preserving its original priority position.

// Primary: role ASC, tie-break: name ASC
new Filter(users)
  .sorter("role", "ASC")
  .sorter("name", "ASC")
  .all();

// Repeating the same key keeps its original priority
new Filter(data)
  .sorter("name", "ASC")
  .sorter("name", "DESC") // updates direction only, priority stays first
  .all();

offset(n) / limit(n)

offset skips n items from the start. Multiple calls are cumulative (added together).

limit caps the result size. Multiple calls take the minimum value.

// Page 2 with 10 items per page
new Filter(data)
  .offset(10)
  .limit(10)
  .all();

or(...branches)

Merges multiple OR branches into the pipeline. Each branch is a function that receives a Filter instance and returns it with its own predicates applied.

Branches are combined with OR logic against the existing predicates on this.

new Filter(students)
  .filter((s) => s.classId === 1)
  .or(
    (f) => f.filter((s) => s.isClassMonitor),
    (f) => f.filter((s) => s.isStudyCommissar),
    (f) => f.filter((s) => s.isLifeCommissar),
  )
  .all();

execute()

Runs the pipeline: filter → sort → slice, resets intermediate state, and returns this for further chaining.

If there are no pending operations, it is a no-op.

all()

Terminal method. Executes the pipeline and returns all matching items.

first()

Terminal method. Executes the pipeline and returns the first matching item, or null if empty.

map(...keys)

Terminal method. Executes the pipeline and returns a projected array containing only the specified keys from each item.

new Filter(users)
  .filter((u) => u.active)
  .map("id", "name");
// Returns: Array<Pick<User, "id" | "name">>

Extending

Subclass Filter to add reusable domain-specific methods:

class StudentFilter extends Filter<Student> {
  public isPassed(subject: Student.Subjects): this {
    return this.filter((s) => s[subject] && s[subject] >= 60);
  }
}

new StudentFilter(students)
  .isPassed("subject1")
  .isPassed("subject2")
  .all();

Architecture

execute() processes data in three stages:

  1. Filter — iterate _data, retain items satisfying every _operations predicate
  2. Sort — apply Array.sort with a multi-field comparator via _sorter Map (insertion order = priority order)
  3. Slice — apply _offset and _limit via Array.slice

State is reset after each execution so the instance can be reused.

License

MIT