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

btypescript

v1.0.0

Published

Linq, collections and various helpers.

Downloads

5

Readme

bTypeScript

TypeScript collections, Linq and various helpers.

Install

I'm still working on the packaging, install directly from Git for now: npm install @hattrickltd/bTypeScript

Examples

See tests for a complete set of examples.

Collections

import {Queue, List} from 'btypescript';

var q = new Queue<number>();
q.enqueue(10);
q.dequeue(); // 10

var l = new List<number>();
l.addRange(List.range(10, 20));
l.count(); // 20

Linq

Usage

import {Linq} from 'btypescript';

var arr1 = [2, 4, 6, 8, 9, 7, 5, 3, 1],
    arr2 = [0, 3, 5, 7, 10],
    arr3 = [5, 10];

new Linq(arr1).filter(x => x % 2 === 0).toArray(); // [2, 4, 6, 8]
new Linq(arr1).orderBy(x => x).toArray(); // [1, 2, 3, 4, 5, 6, 7, 8, 9];
new Linq(arr1).skipWhile(x => x !== 7).toArray(); // [7, 5, 3, 1];

new Linq(arr1).intersect(arr2).toArray(); // [3, 5, 7];
new Linq(arr1).intersect(arr2, arr3).toArray(); // [5];

new Linq(arr1)
    .filter(x => x % 2 === 1) // [9, 7, 5, 3, 1]
    .map(x => x * 2) // [18, 14, 10, 6, 2]
    .skip(3) // [6, 2]
    .sum(); // 8

Short-hand

You can also use the short-hand LQ.

import {LQ} from 'btypescript';

var arr1 = [2, 4, 6, 8, 9, 7, 5, 3, 1],
    arr2 = [0, 3, 5, 7, 10],
    arr3 = [5, 10];

LQ(arr1).filter(x => x % 2 === 0).toArray(); // [2, 4, 6, 8]
LQ(arr1).orderBy(x => x).toArray(); // [1, 2, 3, 4, 5, 6, 7, 8, 9];
LQ(arr1).skipWhile(x => x !== 7).toArray(); // [7, 5, 3, 1];

LQ(arr1).intersect(arr2).toArray(); // [3, 5, 7];
LQ(arr1).intersect(arr2, arr3).toArray(); // [5];

LQ(arr1)
    .filter(x => x % 2 === 1) // [9, 7, 5, 3, 1]
    .map(x => x * 2) // [18, 14, 10, 6, 2]
    .skip(3) // [6, 2]
    .sum(); // 8

Static calls

If you're not looking to build chains you can also use static versions of all functions, no trailing .toArray() required.

import {Linq} from 'btypescript';

var arr1 = [2, 4, 6, 8, 9, 7, 5, 3, 1],
    arr2 = [0, 3, 5, 7, 10],
    arr3 = [5, 10];

Linq.filter(arr1, x => x % 2 === 0); // [2, 4, 6, 8]
Linq.orderBy(arr1, x => x); // [1, 2, 3, 4, 5, 6, 7, 8, 9];
Linq.skipWhile(arr1, x => x !== 7); // [7, 5, 3, 1];

Linq.intersect(arr1, arr2); // [3, 5, 7];
Linq.intersect(arr1, arr2, arr3); // [5];

Modules

Each Linq function is built in individual modules. So if you want smaller build sizes you can instead of including everything by using Linq from btypescript or btypescript/linq you can import each module individually like this:

import {Linq} from 'btypescript/linq/linq';
import 'btypescript/linq/add/filter';
import 'btypescript/linq/add/map';
import 'btypescript/linq/add/average';

This will build only the minimum code required for using .filter, .map and .average.

Note: Only Linq supports this at the moment. Collections and Helpers will still be fully built.

Helpers

import {Numbers, NumbersHelper, Strings, StringsHelper, Dates, DatesHelper} from './src/helpers';

Numbers(5).in([4, 5, 6]); // true
Numbers(5).between(1, 10); // true

Strings("Hello, {0}!").format("World"); // "Hello, World!"
StringsHelper.format("Hello, {0}", "World"); // "Hello, World!"

var d1 = new Date("2015-01-01T00:00:00+00:00"),
    d2 = new Date("2016-01-01T00:00:00+00:00"),
    d3 = new Date("2017-01-01T00:00:00+00:00");

Dates(d2).between(d1, d3); // true
DatesHelper.between(d2, d1, d3); // true
Dates(d2).addWeeks(1).date; // 2016-01-08T00:00:00+00:00