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

alter-atlas

v2.0.0

Published

library for creating a nice difference log

Downloads

131

Readme

AlterAtlas

Library for creating a nice difference log

Single Resolver

Utility to check if the value has changed

Attributes

  • options (required); -- name (required); -- compareBy (optional); -- transformForView (optional);
SingleResolver({
    name: 'Birthdate',
    compareBy: (doc) => new Date(doc?.birthDate).toISOString(),
    transformForView: (doc) => dayjs(doc?.birthDate).format('DD-MM-YYYY'),
});

Return value

The resolver returns the changed value or null

{
    "name": "Birthdate",
    "old": "2002-12-18T21:00:00.000Z",
    "new": "2024-11-04T21:00:00.000Z",
    "oldForView": "19-12-2002",
    "newForView": "05-11-2024",
    "subChanges": []
}

Array Resolver

Utility for comparing arrays

Attributes

  • change name (required);
  • array path resolver (required);
  • uniq by function to search for a unique item for comparison (required) (required)
  • item name (required)
  • resolvers for comparing the properties for each modified element (required)
type CarType = { uniqId: number; carName: string; power: number };
ArrayResolver<CarType[], CarType>(
    'Cars',
    (value) => value ?? [], // array path
    (value, index) => value?.uniqId, // uniq id resolver
    (value) => value?.carName ?? 'unknown', // name resolver
    [SingleResolver('power', (value) => value?.item?.power)], // nested change resolvers
)(prev, current);

Return value

Resolver returns the value of the array change or null

{
    "name": "Cars",
    "isArray": true,
    "subChanges": [
        {
            "name": "Ford",
            "isArrayItem": true,
            "isNewArrayItem": false,
            "isRemovedArrayItem": false,
            "isUpdatedArrayItem": true,
            "subChanges": [
                {
                    "name": "power",
                    "old": 100,
                    "new": 150,
                    "subChanges": []
                }
            ]
        },
        {
            "name": "Toyota",
            "isArrayItem": true,
            "isNewArrayItem": false,
            "isRemovedArrayItem": true,
            "isUpdatedArrayItem": false,
            "subChanges": [
                {
                    "name": "power",
                    "old": 200,
                    "subChanges": []
                }
            ]
        }
    ]
}

Resolver Wrapper

Utility for comparing objects with many resolvers

Attributes

  • array of resolvers (required)
type TestType = { field: string; array: CarType[] };
type CarType = { uniqId: number; carName: string; power: number };

ResolverWrapper<TestType>([
    SingleResolver('field', (value) => value?.field),
    ArrayResolver<TestType, CarType>(
        'Cars',
        (value) => value?.array ?? [],
        (value, index) => value?.uniqId,
        (value) => value?.carName ?? 'unknown',
        [SingleResolver('power', (value) => value?.item?.power)],
    ),
])(prev, current);

Return value

The return value is an array of changes

[
    {
        "name": "field",
        "old": "test1",
        "new": "test2",
        "subChanges": []
    },
    {
        "name": "Cars",
        "isArray": true,
        "subChanges": [
            {
                "name": "Ford",
                "isArrayItem": true,
                "isNewArrayItem": false,
                "isRemovedArrayItem": false,
                "isUpdatedArrayItem": true,
                "subChanges": [
                    {
                        "name": "power",
                        "old": 100,
                        "new": 150,
                        "subChanges": []
                    }
                ]
            }
        ]
    }
]

Nested Resolver

Utility for adding nested changes

Attributes

  • name of change (required)
  • array of resolvers (required)
NestedResolver<string>('test', [
    SingleResolver('first-resolve', (value) => value),
    SingleResolver('second-resolve', (value) => value),
])(prev, current);

Return value

Returns the nested structure of the changes

{
    "name": "test",
    "subChanges": [
        {
            "name": "first-resolve",
            "old": "prev",
            "new": "current",
            "subChanges": []
        },
        {
            "name": "second-resolve",
            "old": "prev",
            "new": "current",
            "subChanges": []
        }
    ]
}

Context

Utility for change the context of your resolvers

type NestedObject = {
    first: {
        second: {
            testField: string;
            testField2: number;
        };
    };
};

NestedResolver<NestedObject>('', [
    Context(
        (value) => value?.first.second,
        [
            SingleResolver('testField', (value) => value?.testField),
            SingleResolver('testField2', (value) => value?.testField2),
        ],
    ),
])(prev, current);