moroshko / shallow-equal

Minimalistic shallow equality check for arrays/objects

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TS support

slorber opened this issue · comments

That would be cool to ship TS defs for this package ;)

Since the PR mentioned above has just been left to dry I've created my own small declaration. It's probably incorrect or missing parts but it covers the core functionality for me. Just sharing here in case anyone else wants to use it.

declare module "shallow-equal" {
  type primitives =
    | string
    | number
    | boolean
    | bigint
    | undefined
    | symbol
    | null;
  export function shallowEqualArrays(arr1: primitives[], arr2: primitives[]);

  interface primitiveObject {
    [key: string]: primitives;
  }
  export function shallowEqualObjects(
    obj1: primitiveObject,
    obj2: primitiveObject
  );
}

In this day and age with a PR ready to go that is ignored. Packages like this waste people's time.

@slorber @silverlight513 @rhyek : I'm three years late to the party, but seeing as PRs aren't being taken in this repo, I've forked the codebase, implemented typescript, added tests as well as a generic shallowEqual, and have launched it as shallow-equal-modern.

I do plan to support and maintain that.

I'm sorry guys. I really struggle with time. If anyone in interested to continue maintaining this package, please react out on Twitter.

@moroshko : DM sent. Happy to help maintain/support this package, and remove my fork.

Ok - @moroshko and I have now published v3.0.0, which supports Typescript.