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 🙏

© 2025 – Pkg Stats / Ryan Hefner

biselect

v2.11.1

Published

Two-way selectors for Redux-like applications, TypeScript-first.

Readme

Biselect

Two-way selectors for Redux-like applications, TypeScript-first.

Documentation

Motivation

Redux store shape is defined by reducers - but the connect method in redux gives selectors the whole store to choose props from, meaning we need to duplicate the store shape there too. And in some cases, reducers use selectors to get the state of the store before modifying it.

Wouldn't it be easier if selectors defined the shape of the store, and let you modify as well as retrieve data?

Features

  • Intuitive fluent API for building transformations
  • Strong typing so faulty configurations fail at compile-time
  • Built-in parameterisation of selectors
  • Extension mechanism for adding functionality
  • Avoid rerendering with built-in Memoization extension
  • Deep equality testing for updates - only return new object references when necessary

Examples

Select a property of an object:

interface User {
  name: string
}
const nameSelector = Biselect.from<User>().prop('name')
const bond: User = { name: "Bond" }

nameSelector.get(bond) // "Bond"
nameSelector.set(bond, "James") // { name: "James" }
nameSelector.modify(bond, name => "James " + name) // { name: "James Bond" }

Select an object from a "dictionary" object:

interface Users {
  [key: string]: User
}
const users: Users = {
  "007": { name: "James Bond" }
}

const userSelector = Biselect.from<Users>().index('userId')

userSelector.get(users, { userId: "007" }) // { name: "James Bond" }
userSelector.get(users, { userId: "006" }) // null
userSelector.set(users, { userId: "006" }, { name: "Alec Trevelyan" })
// { "007": { name: "James Bond" }, "006": { name: "Alec Trevelyan" } }

Compose the two together:

const users: Users = {
  "006": { name: "Alec Trevelyan" },
  "007": { name: "James Bond" }
}

const userNameSelector = userSelector.compose(nameSelector)

userNameSelector.get(users, { userId: "007" }) // "James Bond"
userNameSelector.modify(users, { userId: "007" }, name => name.split('').reverse().join(''))
// { "006": { name: { "Alec Trevelyan" }, "007": { name: "dnoB semaJ" }}

Or just chain functions:

const userNameSelector = Biselect.from<Users>().indexBy('userId').prop('name')

Documentation

For detailed documentation, please visit the wiki

Isn't this just Lenses with another name?

Mostly. Lenses do not have a secondary "parameter" argument like Selectors do, and the general field of Optics is entrenched in opaque FP terminology. This library is an attempt to bridge the gap between useful functional concepts and the pragmatic needs of everyday programming.

That said, credit must go to the functional programming community for inventing (discovering?) these concepts, in particular the Monocle library for Scala which introduced them to the author.