@x-oasis/shallow-equal 0.1.19 → 0.1.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,13 +2,11 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
+ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
6
+
7
+ var is = _interopDefault(require('@x-oasis/is'));
8
+
5
9
  var hasOwnProperty = Object.prototype.hasOwnProperty;
6
- function is(x, y) {
7
- if (x === y) {
8
- return x !== 0 || y !== 0 || 1 / x === 1 / y;
9
- }
10
- return x !== x && y !== y;
11
- }
12
10
  function shallowEqual(objA, objB) {
13
11
  if (is(objA, objB)) {
14
12
  return true;
@@ -1 +1 @@
1
- {"version":3,"file":"shallow-equal.cjs.development.js","sources":["../src/index.ts"],"sourcesContent":["// https://github.com/facebook/react/blob/144328fe81719e916b946e22660479e31561bb0b/packages/shared/shallowEqual.js#L36-L68\n\n/**\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * @flow\n */\n\n/* eslint-disable no-self-compare */\n\nconst hasOwnProperty = Object.prototype.hasOwnProperty;\n\n/**\n * inlined Object.is polyfill to avoid requiring consumers ship their own\n * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is\n */\nfunction is(x: any, y: any) {\n // SameValue algorithm\n if (x === y) {\n // Steps 1-5, 7-10\n // Steps 6.b-6.e: +0 != -0\n // Added the nonzero y check to make Flow happy, but it is redundant\n return x !== 0 || y !== 0 || 1 / x === 1 / y;\n }\n // Step 6.a: NaN == NaN\n return x !== x && y !== y;\n}\n\n/**\n * Performs equality by iterating through keys on an object and returning false\n * when any key has values which are not strictly equal between the arguments.\n * Returns true when the values of all keys are strictly equal.\n */\nfunction shallowEqual(objA: any, objB: any) {\n if (is(objA, objB)) {\n return true;\n }\n\n if (\n typeof objA !== 'object' ||\n objA === null ||\n typeof objB !== 'object' ||\n objB === null\n ) {\n return false;\n }\n\n const keysA = Object.keys(objA);\n const keysB = Object.keys(objB);\n\n if (keysA.length !== keysB.length) {\n return false;\n }\n\n // Test for A's keys different from B.\n for (let i = 0; i < keysA.length; i++) {\n if (\n !hasOwnProperty.call(objB, keysA[i]) ||\n !is(objA[keysA[i]], objB[keysA[i]])\n ) {\n return false;\n }\n }\n\n return true;\n}\n\nexport default shallowEqual;\n"],"names":["hasOwnProperty","Object","prototype","is","x","y","shallowEqual","objA","objB","keysA","keys","keysB","length","i","call"],"mappings":";;;;AAaA,IAAMA,cAAc,GAAGC,MAAM,CAACC,SAAS,CAACF,cAAc;AAMtD,SAASG,EAAEA,CAACC,CAAM,EAAEC,CAAM;EAExB,IAAID,CAAC,KAAKC,CAAC,EAAE;IAIX,OAAOD,CAAC,KAAK,CAAC,IAAIC,CAAC,KAAK,CAAC,IAAI,CAAC,GAAGD,CAAC,KAAK,CAAC,GAAGC,CAAC;;EAG9C,OAAOD,CAAC,KAAKA,CAAC,IAAIC,CAAC,KAAKA,CAAC;AAC3B;AAOA,SAASC,YAAYA,CAACC,IAAS,EAAEC,IAAS;EACxC,IAAIL,EAAE,CAACI,IAAI,EAAEC,IAAI,CAAC,EAAE;IAClB,OAAO,IAAI;;EAGb,IACE,OAAOD,IAAI,KAAK,QAAQ,IACxBA,IAAI,KAAK,IAAI,IACb,OAAOC,IAAI,KAAK,QAAQ,IACxBA,IAAI,KAAK,IAAI,EACb;IACA,OAAO,KAAK;;EAGd,IAAMC,KAAK,GAAGR,MAAM,CAACS,IAAI,CAACH,IAAI,CAAC;EAC/B,IAAMI,KAAK,GAAGV,MAAM,CAACS,IAAI,CAACF,IAAI,CAAC;EAE/B,IAAIC,KAAK,CAACG,MAAM,KAAKD,KAAK,CAACC,MAAM,EAAE;IACjC,OAAO,KAAK;;EAId,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGJ,KAAK,CAACG,MAAM,EAAEC,CAAC,EAAE,EAAE;IACrC,IACE,CAACb,cAAc,CAACc,IAAI,CAACN,IAAI,EAAEC,KAAK,CAACI,CAAC,CAAC,CAAC,IACpC,CAACV,EAAE,CAACI,IAAI,CAACE,KAAK,CAACI,CAAC,CAAC,CAAC,EAAEL,IAAI,CAACC,KAAK,CAACI,CAAC,CAAC,CAAC,CAAC,EACnC;MACA,OAAO,KAAK;;;EAIhB,OAAO,IAAI;AACb;;;;"}
1
+ {"version":3,"file":"shallow-equal.cjs.development.js","sources":["../src/index.ts"],"sourcesContent":["// https://github.com/facebook/react/blob/144328fe81719e916b946e22660479e31561bb0b/packages/shared/shallowEqual.js#L36-L68\n\nimport is from '@x-oasis/is';\n\nconst hasOwnProperty = Object.prototype.hasOwnProperty;\n\n/**\n * Performs equality by iterating through keys on an object and returning false\n * when any key has values which are not strictly equal between the arguments.\n * Returns true when the values of all keys are strictly equal.\n */\nfunction shallowEqual(objA: any, objB: any) {\n if (is(objA, objB)) {\n return true;\n }\n\n if (\n typeof objA !== 'object' ||\n objA === null ||\n typeof objB !== 'object' ||\n objB === null\n ) {\n return false;\n }\n\n const keysA = Object.keys(objA);\n const keysB = Object.keys(objB);\n\n if (keysA.length !== keysB.length) {\n return false;\n }\n\n // Test for A's keys different from B.\n for (let i = 0; i < keysA.length; i++) {\n if (\n !hasOwnProperty.call(objB, keysA[i]) ||\n !is(objA[keysA[i]], objB[keysA[i]])\n ) {\n return false;\n }\n }\n\n return true;\n}\n\nexport default shallowEqual;\n"],"names":["hasOwnProperty","Object","prototype","shallowEqual","objA","objB","is","keysA","keys","keysB","length","i","call"],"mappings":";;;;;;;;AAIA,IAAMA,cAAc,GAAGC,MAAM,CAACC,SAAS,CAACF,cAAc;AAOtD,SAASG,YAAYA,CAACC,IAAS,EAAEC,IAAS;EACxC,IAAIC,EAAE,CAACF,IAAI,EAAEC,IAAI,CAAC,EAAE;IAClB,OAAO,IAAI;;EAGb,IACE,OAAOD,IAAI,KAAK,QAAQ,IACxBA,IAAI,KAAK,IAAI,IACb,OAAOC,IAAI,KAAK,QAAQ,IACxBA,IAAI,KAAK,IAAI,EACb;IACA,OAAO,KAAK;;EAGd,IAAME,KAAK,GAAGN,MAAM,CAACO,IAAI,CAACJ,IAAI,CAAC;EAC/B,IAAMK,KAAK,GAAGR,MAAM,CAACO,IAAI,CAACH,IAAI,CAAC;EAE/B,IAAIE,KAAK,CAACG,MAAM,KAAKD,KAAK,CAACC,MAAM,EAAE;IACjC,OAAO,KAAK;;EAId,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGJ,KAAK,CAACG,MAAM,EAAEC,CAAC,EAAE,EAAE;IACrC,IACE,CAACX,cAAc,CAACY,IAAI,CAACP,IAAI,EAAEE,KAAK,CAACI,CAAC,CAAC,CAAC,IACpC,CAACL,EAAE,CAACF,IAAI,CAACG,KAAK,CAACI,CAAC,CAAC,CAAC,EAAEN,IAAI,CAACE,KAAK,CAACI,CAAC,CAAC,CAAC,CAAC,EACnC;MACA,OAAO,KAAK;;;EAIhB,OAAO,IAAI;AACb;;;;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=Object.prototype.hasOwnProperty;function t(e,t){return e===t?0!==e||0!==t||1/e==1/t:e!=e&&t!=t}exports.default=function(r,n){if(t(r,n))return!0;if("object"!=typeof r||null===r||"object"!=typeof n||null===n)return!1;var o=Object.keys(r),u=Object.keys(n);if(o.length!==u.length)return!1;for(var l=0;l<o.length;l++)if(!e.call(n,o[l])||!t(r[o[l]],n[o[l]]))return!1;return!0};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=(e=require("@x-oasis/is"))&&"object"==typeof e&&"default"in e?e.default:e,r=Object.prototype.hasOwnProperty;exports.default=function(e,o){if(t(e,o))return!0;if("object"!=typeof e||null===e||"object"!=typeof o||null===o)return!1;var n=Object.keys(e),u=Object.keys(o);if(n.length!==u.length)return!1;for(var l=0;l<n.length;l++)if(!r.call(o,n[l])||!t(e[n[l]],o[n[l]]))return!1;return!0};
2
2
  //# sourceMappingURL=shallow-equal.cjs.production.min.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"shallow-equal.cjs.production.min.js","sources":["../src/index.ts"],"sourcesContent":["// https://github.com/facebook/react/blob/144328fe81719e916b946e22660479e31561bb0b/packages/shared/shallowEqual.js#L36-L68\n\n/**\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * @flow\n */\n\n/* eslint-disable no-self-compare */\n\nconst hasOwnProperty = Object.prototype.hasOwnProperty;\n\n/**\n * inlined Object.is polyfill to avoid requiring consumers ship their own\n * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is\n */\nfunction is(x: any, y: any) {\n // SameValue algorithm\n if (x === y) {\n // Steps 1-5, 7-10\n // Steps 6.b-6.e: +0 != -0\n // Added the nonzero y check to make Flow happy, but it is redundant\n return x !== 0 || y !== 0 || 1 / x === 1 / y;\n }\n // Step 6.a: NaN == NaN\n return x !== x && y !== y;\n}\n\n/**\n * Performs equality by iterating through keys on an object and returning false\n * when any key has values which are not strictly equal between the arguments.\n * Returns true when the values of all keys are strictly equal.\n */\nfunction shallowEqual(objA: any, objB: any) {\n if (is(objA, objB)) {\n return true;\n }\n\n if (\n typeof objA !== 'object' ||\n objA === null ||\n typeof objB !== 'object' ||\n objB === null\n ) {\n return false;\n }\n\n const keysA = Object.keys(objA);\n const keysB = Object.keys(objB);\n\n if (keysA.length !== keysB.length) {\n return false;\n }\n\n // Test for A's keys different from B.\n for (let i = 0; i < keysA.length; i++) {\n if (\n !hasOwnProperty.call(objB, keysA[i]) ||\n !is(objA[keysA[i]], objB[keysA[i]])\n ) {\n return false;\n }\n }\n\n return true;\n}\n\nexport default shallowEqual;\n"],"names":["hasOwnProperty","Object","prototype","is","x","y","objA","objB","keysA","keys","keysB","length","i","call"],"mappings":"oEAaA,IAAMA,EAAiBC,OAAOC,UAAUF,eAMxC,SAASG,EAAGC,EAAQC,GAElB,OAAID,IAAMC,EAIK,IAAND,GAAiB,IAANC,GAAW,EAAID,GAAM,EAAIC,EAGtCD,GAAMA,GAAKC,GAAMA,kBAQ1B,SAAsBC,EAAWC,GAC/B,GAAIJ,EAAGG,EAAMC,GACX,OAAO,EAGT,GACkB,iBAATD,GACE,OAATA,GACgB,iBAATC,GACE,OAATA,EAEA,OAAO,EAGT,IAAMC,EAAQP,OAAOQ,KAAKH,GACpBI,EAAQT,OAAOQ,KAAKF,GAE1B,GAAIC,EAAMG,SAAWD,EAAMC,OACzB,OAAO,EAIT,IAAK,IAAIC,EAAI,EAAGA,EAAIJ,EAAMG,OAAQC,IAChC,IACGZ,EAAea,KAAKN,EAAMC,EAAMI,MAChCT,EAAGG,EAAKE,EAAMI,IAAKL,EAAKC,EAAMI,KAE/B,OAAO,EAIX,OAAO"}
1
+ {"version":3,"file":"shallow-equal.cjs.production.min.js","sources":["../src/index.ts"],"sourcesContent":["// https://github.com/facebook/react/blob/144328fe81719e916b946e22660479e31561bb0b/packages/shared/shallowEqual.js#L36-L68\n\nimport is from '@x-oasis/is';\n\nconst hasOwnProperty = Object.prototype.hasOwnProperty;\n\n/**\n * Performs equality by iterating through keys on an object and returning false\n * when any key has values which are not strictly equal between the arguments.\n * Returns true when the values of all keys are strictly equal.\n */\nfunction shallowEqual(objA: any, objB: any) {\n if (is(objA, objB)) {\n return true;\n }\n\n if (\n typeof objA !== 'object' ||\n objA === null ||\n typeof objB !== 'object' ||\n objB === null\n ) {\n return false;\n }\n\n const keysA = Object.keys(objA);\n const keysB = Object.keys(objB);\n\n if (keysA.length !== keysB.length) {\n return false;\n }\n\n // Test for A's keys different from B.\n for (let i = 0; i < keysA.length; i++) {\n if (\n !hasOwnProperty.call(objB, keysA[i]) ||\n !is(objA[keysA[i]], objB[keysA[i]])\n ) {\n return false;\n }\n }\n\n return true;\n}\n\nexport default shallowEqual;\n"],"names":["hasOwnProperty","Object","prototype","objA","objB","is","keysA","keys","keysB","length","i","call"],"mappings":"sJAIMA,EAAiBC,OAAOC,UAAUF,+BAOxC,SAAsBG,EAAWC,GAC/B,GAAIC,EAAGF,EAAMC,GACX,OAAO,EAGT,GACkB,iBAATD,GACE,OAATA,GACgB,iBAATC,GACE,OAATA,EAEA,OAAO,EAGT,IAAME,EAAQL,OAAOM,KAAKJ,GACpBK,EAAQP,OAAOM,KAAKH,GAE1B,GAAIE,EAAMG,SAAWD,EAAMC,OACzB,OAAO,EAIT,IAAK,IAAIC,EAAI,EAAGA,EAAIJ,EAAMG,OAAQC,IAChC,IACGV,EAAeW,KAAKP,EAAME,EAAMI,MAChCL,EAAGF,EAAKG,EAAMI,IAAKN,EAAKE,EAAMI,KAE/B,OAAO,EAIX,OAAO"}
@@ -1,10 +1,6 @@
1
+ import is from '@x-oasis/is';
2
+
1
3
  var hasOwnProperty = Object.prototype.hasOwnProperty;
2
- function is(x, y) {
3
- if (x === y) {
4
- return x !== 0 || y !== 0 || 1 / x === 1 / y;
5
- }
6
- return x !== x && y !== y;
7
- }
8
4
  function shallowEqual(objA, objB) {
9
5
  if (is(objA, objB)) {
10
6
  return true;
@@ -1 +1 @@
1
- {"version":3,"file":"shallow-equal.esm.js","sources":["../src/index.ts"],"sourcesContent":["// https://github.com/facebook/react/blob/144328fe81719e916b946e22660479e31561bb0b/packages/shared/shallowEqual.js#L36-L68\n\n/**\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * @flow\n */\n\n/* eslint-disable no-self-compare */\n\nconst hasOwnProperty = Object.prototype.hasOwnProperty;\n\n/**\n * inlined Object.is polyfill to avoid requiring consumers ship their own\n * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is\n */\nfunction is(x: any, y: any) {\n // SameValue algorithm\n if (x === y) {\n // Steps 1-5, 7-10\n // Steps 6.b-6.e: +0 != -0\n // Added the nonzero y check to make Flow happy, but it is redundant\n return x !== 0 || y !== 0 || 1 / x === 1 / y;\n }\n // Step 6.a: NaN == NaN\n return x !== x && y !== y;\n}\n\n/**\n * Performs equality by iterating through keys on an object and returning false\n * when any key has values which are not strictly equal between the arguments.\n * Returns true when the values of all keys are strictly equal.\n */\nfunction shallowEqual(objA: any, objB: any) {\n if (is(objA, objB)) {\n return true;\n }\n\n if (\n typeof objA !== 'object' ||\n objA === null ||\n typeof objB !== 'object' ||\n objB === null\n ) {\n return false;\n }\n\n const keysA = Object.keys(objA);\n const keysB = Object.keys(objB);\n\n if (keysA.length !== keysB.length) {\n return false;\n }\n\n // Test for A's keys different from B.\n for (let i = 0; i < keysA.length; i++) {\n if (\n !hasOwnProperty.call(objB, keysA[i]) ||\n !is(objA[keysA[i]], objB[keysA[i]])\n ) {\n return false;\n }\n }\n\n return true;\n}\n\nexport default shallowEqual;\n"],"names":["hasOwnProperty","Object","prototype","is","x","y","shallowEqual","objA","objB","keysA","keys","keysB","length","i","call"],"mappings":"AAaA,IAAMA,cAAc,GAAGC,MAAM,CAACC,SAAS,CAACF,cAAc;AAMtD,SAASG,EAAEA,CAACC,CAAM,EAAEC,CAAM;EAExB,IAAID,CAAC,KAAKC,CAAC,EAAE;IAIX,OAAOD,CAAC,KAAK,CAAC,IAAIC,CAAC,KAAK,CAAC,IAAI,CAAC,GAAGD,CAAC,KAAK,CAAC,GAAGC,CAAC;;EAG9C,OAAOD,CAAC,KAAKA,CAAC,IAAIC,CAAC,KAAKA,CAAC;AAC3B;AAOA,SAASC,YAAYA,CAACC,IAAS,EAAEC,IAAS;EACxC,IAAIL,EAAE,CAACI,IAAI,EAAEC,IAAI,CAAC,EAAE;IAClB,OAAO,IAAI;;EAGb,IACE,OAAOD,IAAI,KAAK,QAAQ,IACxBA,IAAI,KAAK,IAAI,IACb,OAAOC,IAAI,KAAK,QAAQ,IACxBA,IAAI,KAAK,IAAI,EACb;IACA,OAAO,KAAK;;EAGd,IAAMC,KAAK,GAAGR,MAAM,CAACS,IAAI,CAACH,IAAI,CAAC;EAC/B,IAAMI,KAAK,GAAGV,MAAM,CAACS,IAAI,CAACF,IAAI,CAAC;EAE/B,IAAIC,KAAK,CAACG,MAAM,KAAKD,KAAK,CAACC,MAAM,EAAE;IACjC,OAAO,KAAK;;EAId,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGJ,KAAK,CAACG,MAAM,EAAEC,CAAC,EAAE,EAAE;IACrC,IACE,CAACb,cAAc,CAACc,IAAI,CAACN,IAAI,EAAEC,KAAK,CAACI,CAAC,CAAC,CAAC,IACpC,CAACV,EAAE,CAACI,IAAI,CAACE,KAAK,CAACI,CAAC,CAAC,CAAC,EAAEL,IAAI,CAACC,KAAK,CAACI,CAAC,CAAC,CAAC,CAAC,EACnC;MACA,OAAO,KAAK;;;EAIhB,OAAO,IAAI;AACb;;;;"}
1
+ {"version":3,"file":"shallow-equal.esm.js","sources":["../src/index.ts"],"sourcesContent":["// https://github.com/facebook/react/blob/144328fe81719e916b946e22660479e31561bb0b/packages/shared/shallowEqual.js#L36-L68\n\nimport is from '@x-oasis/is';\n\nconst hasOwnProperty = Object.prototype.hasOwnProperty;\n\n/**\n * Performs equality by iterating through keys on an object and returning false\n * when any key has values which are not strictly equal between the arguments.\n * Returns true when the values of all keys are strictly equal.\n */\nfunction shallowEqual(objA: any, objB: any) {\n if (is(objA, objB)) {\n return true;\n }\n\n if (\n typeof objA !== 'object' ||\n objA === null ||\n typeof objB !== 'object' ||\n objB === null\n ) {\n return false;\n }\n\n const keysA = Object.keys(objA);\n const keysB = Object.keys(objB);\n\n if (keysA.length !== keysB.length) {\n return false;\n }\n\n // Test for A's keys different from B.\n for (let i = 0; i < keysA.length; i++) {\n if (\n !hasOwnProperty.call(objB, keysA[i]) ||\n !is(objA[keysA[i]], objB[keysA[i]])\n ) {\n return false;\n }\n }\n\n return true;\n}\n\nexport default shallowEqual;\n"],"names":["hasOwnProperty","Object","prototype","shallowEqual","objA","objB","is","keysA","keys","keysB","length","i","call"],"mappings":";;AAIA,IAAMA,cAAc,GAAGC,MAAM,CAACC,SAAS,CAACF,cAAc;AAOtD,SAASG,YAAYA,CAACC,IAAS,EAAEC,IAAS;EACxC,IAAIC,EAAE,CAACF,IAAI,EAAEC,IAAI,CAAC,EAAE;IAClB,OAAO,IAAI;;EAGb,IACE,OAAOD,IAAI,KAAK,QAAQ,IACxBA,IAAI,KAAK,IAAI,IACb,OAAOC,IAAI,KAAK,QAAQ,IACxBA,IAAI,KAAK,IAAI,EACb;IACA,OAAO,KAAK;;EAGd,IAAME,KAAK,GAAGN,MAAM,CAACO,IAAI,CAACJ,IAAI,CAAC;EAC/B,IAAMK,KAAK,GAAGR,MAAM,CAACO,IAAI,CAACH,IAAI,CAAC;EAE/B,IAAIE,KAAK,CAACG,MAAM,KAAKD,KAAK,CAACC,MAAM,EAAE;IACjC,OAAO,KAAK;;EAId,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGJ,KAAK,CAACG,MAAM,EAAEC,CAAC,EAAE,EAAE;IACrC,IACE,CAACX,cAAc,CAACY,IAAI,CAACP,IAAI,EAAEE,KAAK,CAACI,CAAC,CAAC,CAAC,IACpC,CAACL,EAAE,CAACF,IAAI,CAACG,KAAK,CAACI,CAAC,CAAC,CAAC,EAAEN,IAAI,CAACE,KAAK,CAACI,CAAC,CAAC,CAAC,CAAC,EACnC;MACA,OAAO,KAAK;;;EAIhB,OAAO,IAAI;AACb;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@x-oasis/shallow-equal",
3
- "version": "0.1.19",
3
+ "version": "0.1.20",
4
4
  "description": "shallow equal function",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -10,6 +10,9 @@
10
10
  "devDependencies": {
11
11
  "tsdx": "^0.14.1"
12
12
  },
13
+ "dependencies": {
14
+ "@x-oasis/is": "^0.1.19"
15
+ },
13
16
  "scripts": {
14
17
  "build": "tsdx build --tsconfig tsconfig.build.json",
15
18
  "clean": "rimraf ./dist",
package/src/index.ts CHANGED
@@ -1,34 +1,9 @@
1
1
  // https://github.com/facebook/react/blob/144328fe81719e916b946e22660479e31561bb0b/packages/shared/shallowEqual.js#L36-L68
2
2
 
3
- /**
4
- * Copyright (c) Facebook, Inc. and its affiliates.
5
- *
6
- * This source code is licensed under the MIT license found in the
7
- * LICENSE file in the root directory of this source tree.
8
- *
9
- * @flow
10
- */
11
-
12
- /* eslint-disable no-self-compare */
3
+ import is from '@x-oasis/is';
13
4
 
14
5
  const hasOwnProperty = Object.prototype.hasOwnProperty;
15
6
 
16
- /**
17
- * inlined Object.is polyfill to avoid requiring consumers ship their own
18
- * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
19
- */
20
- function is(x: any, y: any) {
21
- // SameValue algorithm
22
- if (x === y) {
23
- // Steps 1-5, 7-10
24
- // Steps 6.b-6.e: +0 != -0
25
- // Added the nonzero y check to make Flow happy, but it is redundant
26
- return x !== 0 || y !== 0 || 1 / x === 1 / y;
27
- }
28
- // Step 6.a: NaN == NaN
29
- return x !== x && y !== y;
30
- }
31
-
32
7
  /**
33
8
  * Performs equality by iterating through keys on an object and returning false
34
9
  * when any key has values which are not strictly equal between the arguments.
package/test/test.spec.ts CHANGED
@@ -1,5 +1,11 @@
1
- import { expect, test } from 'vitest'
1
+ import { expect, test } from 'vitest';
2
+ import shallowEqual from '../src';
2
3
 
3
4
  test('vitest', async () => {
4
- expect('vitest').toBe('vitest')
5
- })
5
+ expect(shallowEqual([1, 2], [1, 2])).toBe(true);
6
+ expect(shallowEqual([1, 2], [2, 1])).toBe(false);
7
+ expect(shallowEqual(1, 1)).toBe(true);
8
+ expect(shallowEqual(NaN, NaN)).toBe(true);
9
+ expect(shallowEqual(null, null)).toBe(true);
10
+ expect(shallowEqual(undefined, undefined)).toBe(true);
11
+ });