es-tooling / ecosystem-cleanup

A place to keep track of ongoing efforts to clean up the JS ecosystem
405 stars 2 forks source link

migrate http-assert to another deep equality library #16

Open 43081j opened 10 months ago

43081j commented 10 months ago

http-assert can be found here: https://github.com/jshttp/http-assert

This package is depended on by koa: https://github.com/koajs/koa/blob/5f159415e58c42b54cb0703d7cfb10870d33d65f/package.json#L50

deep-equal has 18 dependencies, it should be possible to move to a lighter library.

Some options are:

mehulkar commented 10 months ago

Test suite passes, but no idea if that's enough for this https://github.com/jshttp/http-assert/pull/15

43081j commented 10 months ago

awesome work @mehulkar , if you need any help along the way do feel free to pull me into an issue/pr

looks like they want to maintain deep loose equality.

it would basically mean something like equal({a: null}, {a: undefined}) would be true if we did it non-strict.

deep-eql does let you pass a custom comparator, something like:

deepEqual(left, right, {
  comparator: (a, b) => {
    if(typeof a === 'object' || typeof b === 'object') {
      return null; // this tells deep-eql to carry on using default behaviour
    }
    return a == b;
  }
});

maybe we could do this inside http-assert.

some day i could talk to the other chai maintainers about having a loose equality comparator built in too maybe.