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

baats-core

v0.2.2

Published

Baats Core - BAATS (Baavgai's TypeScript) Library

Downloads

18

Readme

BAATS (Baavgai's TypeScript) Library

This is part of a collection of code I use for my projects.
If you find it interesting, feel free to use it in yours.

Module baats-core

A TypeScript port of node-clone.

clone<T>(parent: T, circular = true, depth = Infinity, prototype: any = undefined): T;

It's amazaing how much functional programming fun opens up with this simple function. Half the time I've loaded all of lodash was for this function and clone.

range(size: number): number[];

Padding functions are so small you just end up copy pasting them... Or, some cases, just finding a library and moving on. I wrote lpad and don't expect anyone to care. But the first guy to get such code out there really managed to cause some drama: How one developer just broke Node, Babel and thousands of projects in 11 lines of JavaScript

repChar(size: number, symbol?: string): string;
lpad(value: any, size: number, symbol?: string): string;
rpad(value: any, size: number, symbol?: string): string;
zpad(value: any, zeros: number): string;

A little 24 char randomized string. Not quite a UUID, but pretty good. Made with simplicity and speed in mind.

uniqueId(): string;

Filter to uniq items, accepts optional key function. Maintains order and is non destructive.

uniq<T>(xs: Array<T>, getKey?: (x: T) => string): T[];

Test Code

import * as lib from "baats-core";

const out = console.log;

const line = () => out(lib.repChar(40, '-'));

line();
lib
  .range(5)
  .map(x=>x+7)
  .forEach(x=>console.log(`${lib.zpad(x,2)}: ${lib.uniqueId()}`));

line();

out(lib.lpad("lpad", 10, '.')); 
out(lib.rpad("rpad", 10, '.x')); 

line();

class Foo {
  constructor(public name: string, private age: number) { }
  greeting() { console.log(`Hello ${this.name}`); }
}
const fooTest = (x:Foo) => {
  out(JSON.stringify(x));
  x.greeting();
  return x;
}

let alice = fooTest(new Foo('Alice', 42));
let bob = lib.clone(alice);
bob.name = 'Bob';
fooTest(bob);
fooTest(alice);

line();

const ut = ["Bob", "Alice", "Bob", "Chuck", "bob", "Dave"];

out(`uniq([${ut}]) = ${lib.uniq(ut)}`);
out(`uniq([${ut}], x=>x.toLowerCase()) = ${lib.uniq(ut, x=>x.toLowerCase())}`);

line();

Licence

MIT