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

data-sorcerer

v0.0.2

Published

Query any data source using a common, fluent API

Readme

data-sorcerer [WORK IN PROGRESS]

Query any data source using a common, fluent API

Description

data-sorcerer provides a unified interface for accessing any data source. It allows you to build queries to data sources using a fluent API. Such queries can then be converted to data source-specific queries and then executed.

Because query operations and results have a unified interface, generic modules can be built on top of data-sorcerer to query any type of data source type and work with the results of such queries.

How to install

npm i data-sorcerer

How to use

import * as Sorcerer from 'data-sorcerer';

//Create references to data sources
const employees = new Sorcerer.FetchDataSource('/api/northwind/employees');
const products = new Sorcerer.FetchDataSource('/api/northwind/products');
const orders = new Sorcerer.FetchDataSource('/api/northwind/orders');

//Get products out of stock
const outOfStock = products
    .filter(product => product.unitsInStock == 0);

//Get employee full names from a city
const londonEmployees = employees
    .filter(employee => employee.city == 'London')
    .map(employee => employee.firstName + ' ' + employee.lastName);
// -> [ 'John Smith', 'Lara Croft', 'Henry Spencer' ]

//Get orders where a discount has been applied and select the product name
const discountOrders = orders
    .filter(order => order.orderDetails.any(detail => detail.discount > 0))
    .map(order => ({
        orderId: order.orderId,
        products: order.orderDetails
            .filter(detail => detail.discount > 0)
            .map(detail => ({
                name: detail.product.productName
                discount: detail.discount
            }))
    }));
/* ->
[
    {
        orderId: 1,
        products: [
            {
                name: 'Dishwasher',
                discount: 50
            }
        ]
    },
    {
        orderId: 4,
        products: [
            {
                name: 'Chair',
                discount: 1.25
            },
            {
                name: 'Desk',
                discount: 23.05
            }
        ]
    },
]
*/

Lazy evaluation

All queries are lazy-evaluated meaning that the query is only sent for execution when the data source is converted to an array using toArray(), when the result of the operation is a value, or when the data source is iterated.

const londonEmployees = employees
    .filter(employee => employee.city == 'London')
    .map(employee => employee.firstName + ' ' + employee.lastName);
//londonEmployees is still a queryable data source, the query has not been sent for execution

const londonEmployeesResults = await londonEmployees.toArray(); //Results are loaded

const outOfStock = await products
    .filter(product => product.unitsInStock == 0)
    .any();
// -> true

Expression trees

The TypeScript expressions in these queries have to be converted to expression trees before they can be analyzed. For that we use ts-expressions. If you are making use of TypeScript expressions, you must compile data-sorcerer using the ts-expressions transformer. For more details please visit the ts-expressions page.