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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@toadfans/active-support

v0.1.3

Published

A TypeScript utility library designed to optimize for programmer happiness. zzz

Downloads

1

Readme

@pleisto/active-support

A TypeScript utility library designed to optimize for programmer happiness.

NOTES: If you want to add a new methods, make sure it will be used on both the client and the server side. Any methods that will only used in a browser or NodeJS environment should not be added here.

Features

Alternative to lodash

You could directly use @pleisto/active-support instead of lodash and lodash-es.

import { differenceBy, zip, isString } from '@pleisto/active-support'

If some of the methods in lodash do not exist in @pleisto/active-support, it is because the are natively supported in modern ECMAScript. see YOU MIGHT NOT NEED LODASH for more information.

Unit Converter

Millisecond conversion

import { ms } from '@pleisto/active-support';
ms('2 days') // 172800000
ms('2.5 h') // 9000000
ms('-3 days) // -259200000
ms('-200') // -200
ms(60000) // '1m'
ms(ms('10 hours)) // '10h'
ms(6000, { long: true }) // '1 minute'
ms(2*6000, { long: true }) // '2 minutes'

see vercel/ms for more information.

ByteSize conversion

import { byteSize } from '@pleisto/active-support'
byteSize('3 mb') // 24_000_000
byteSize('2 Gigabytes') // 16_000_000_000
byteSize(32_000_000) // '4 MB'

NOTICE:

We use base 10 instead of base 2 for bit. See IEC 60027-2 A.2 and ISO/IEC 80000 for more information.

Type Checking Utilities

You could use most of the type checking utilities in lodash directly, such as isString, isEmpty and isBuffer. In addition we support methods such as isUUID nad isBlack. See src/isType.ts for more information.

isBlack

isBlack method could be used to check if any value is empty or undefined/null, just as it does in Ruby on Rails.

Inflections

import { pluralize, singularize } from '@pleisto/active-support'

pluralize('word') // 'words'
pluralize('datum') // 'data'
singularize('quizzes') // 'quiz'
singularize('news') // 'news'
singularize('are') // 'is'

Rust style error handling

import { ok, err } from '@pleisto/active-support'

// something awesome happend

const yesss = ok(someAesomeValue)

// moments later ...

const mappedYes = yesss.map(doingSuperUsefulStuff)

// neverthrow uses type-guards to differentiate between Ok and Err instances
// Mode info: https://www.typescriptlang.org/docs/handbook/advanced-types.html#type-guards-and-differentiating-types
if (mappedYes.isOk()) {
  // using type guards, we can access an Ok instance's `value` field
  doStuffWith(mappedYes.value)
} else {
  // because of type guards
  // typescript knows that mappedYes is an Err instance and thus has a `error` field
  doStuffWith(mappedYes.error)
}

See neverthrow for more information.

Rust style pattern matching

import { match, P } from '@pleisto/active-support'

type Data =
  | { type: 'text'; content: string }
  | { type: 'img'; src: string };

type Result =
  | { type: 'ok'; data: Data }
  | { type: 'error'; error: Error };

const result: Result = ...;

return match(result)
  .with({ type: 'error' }, () => `<p>Oups! An error occured</p>`)
  .with({ type: 'ok', data: { type: 'text' } }, (res) => `<p>${res.data.content}</p>`)
  .with({ type: 'ok', data: { type: 'img', src: P.select() } }, (src) => `<img src=${src} />`)
  .exhaustive();

See ts-pattern for more information.

Utilities

array2Tree

Converts an array of items with ids and parent ids to a nested tree in a performant way (time complexity O(n)).

Se Performant array to tree for more information.

equals

The fastest deep equal with ES6 Map, Set and Typed arrays support. Based on fast-deep-equal/es6/react