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

blinsky

v1.1.4

Published

A micro library helping to keep the context in nested promises and callbacks

Downloads

8

Readme

Build Status

blinsky

Utility classes for functional programming in JS. The goal is to make creation of immutable classes easier.

Why is it called 'blinsky'?

Do you know what the hardest part of software development is? Naming variables? Nope, naming npm packages! All reasonable names on npm.js are taken already, this is why this library's name is a transcription of a russian word "блинский".

How to use it

This library defines three main abstract classes.

  1. CloneWith

It basically defines a method replicating Scala's copy method. Usage example (written in TypeScript):

import { CloneWith } from 'blinsky';
class ImmutableHouse extends CloneWith {
    constructor(
        readonly address: string,
        protected owner: string
    ) {
        super();
    }
    buy(newOwner: string): ImmutableHouse {
        return this.cloneWith((house) => {
            house.owner = newOwner;
        });
    }
    getOwner(): string {
        return this.owner;
    }
}

const house = new ImmutableHouse("Street", "Owner");
const updatedHouse = house.buy("New Owner");
house.getOwner() + " vs " + updatedHouser.getOwner(); // Owner vs New Owner

Also there is another utility method for performing identical operations using a set of input data. Example usage (TypeScript, as well):

import { CloneWith } from 'blinsky';
import { Set } from 'immutable';
class ImmutableHouse extends CloneWith {
    constructor(
        readonly address: string,
        protected furniture: Set<string> = Set()
    ) {
        super();
    }
    addFurniture(furnitureItem: string): ImmutableHouse {
        return this.cloneWith((house) => {
            house.furniture = house.furniture.add(furnitureItem);
        });
    }
    getFurniture(): Set<string> {
        return this.furniture;
    }
}

const house = new ImmutableHouse("Street");
const updatedHouse = house.transformFor(
    Set.of("Table", "Chair"),
    (house, furnitureItem) => house.addFurniture(furnitureItem)
);
house.getFurniture() + " vs " + updatedHouser.getFurniture(); // [] vs ["Table", "Chair"]
  1. ValueObject

This is basically the same as CloneWith, but it also declares "equals" and "hashCode" methods to make it work nicely with Immutable.js. These methods uses all the objects' fields to check for equality and compute the hash code. Refer DDD's value object for more info. Usage is exactly same as with CloneWith, just use ValueObject instead of CloneWith.

  1. IdentifiedEntity

Same as ValueObject, except it uses only object's identifier for checking the equality and computing hash code. Refer DDD's entity for more info. Usage is exactly same as with CloneWith, just use IdentifiedEntity instead of CloneWith.