@x-oasis/layout-equal 0.1.14 → 0.1.15

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.
package/dist/index.d.ts CHANGED
@@ -1,2 +1,5 @@
1
1
  import { ItemLayout } from './types';
2
- export default function layoutEqual(oldLayout: ItemLayout, newLayout: ItemLayout, keysToCheck?: Array<'x' | 'y' | 'height' | 'width'>): boolean;
2
+ export default function layoutEqual(oldLayout: ItemLayout, newLayout: ItemLayout, options?: {
3
+ keysToCheck?: Array<'x' | 'y' | 'height' | 'width'>;
4
+ correctionValue?: number;
5
+ }): boolean;
@@ -2,17 +2,15 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var KEY_TO_CHECK = ['x', 'y', 'height', 'width'];
6
- function layoutEqual(oldLayout, newLayout, keysToCheck) {
7
- if (keysToCheck === void 0) {
8
- keysToCheck = KEY_TO_CHECK;
9
- }
5
+ function layoutEqual(oldLayout, newLayout, options) {
10
6
  var oldLayoutType = Object.prototype.toString.call(oldLayout);
11
7
  var newLayoutType = Object.prototype.toString.call(newLayout);
8
+ var keysToCheck = options == null ? void 0 : options.keysToCheck;
9
+ var correctionValue = options.correctionValue || 0;
12
10
  if (oldLayoutType === newLayoutType && newLayoutType === '[object Object]') {
13
11
  for (var index = 0; index < keysToCheck.length; index++) {
14
12
  var key = keysToCheck[index];
15
- if (oldLayout[key] !== newLayout[key]) {
13
+ if (Math.abs(oldLayout[key] - newLayout[key]) > correctionValue) {
16
14
  return false;
17
15
  }
18
16
  }
@@ -1 +1 @@
1
- {"version":3,"file":"layout-equal.cjs.development.js","sources":["../src/index.ts"],"sourcesContent":["import { ItemLayout } from './types';\n\nconst KEY_TO_CHECK = ['x', 'y', 'height', 'width'];\n\nexport default function layoutEqual(\n oldLayout: ItemLayout,\n newLayout: ItemLayout,\n // @ts-ignore\n keysToCheck: Array<'x' | 'y' | 'height' | 'width'> = KEY_TO_CHECK\n) {\n const oldLayoutType = Object.prototype.toString.call(oldLayout);\n const newLayoutType = Object.prototype.toString.call(newLayout);\n\n if (oldLayoutType === newLayoutType && newLayoutType === '[object Object]') {\n for (let index = 0; index < keysToCheck.length; index++) {\n const key = keysToCheck[index];\n if (oldLayout[key] !== newLayout[key]) {\n return false;\n }\n }\n\n return true;\n }\n\n return false;\n}\n"],"names":["KEY_TO_CHECK","layoutEqual","oldLayout","newLayout","keysToCheck","oldLayoutType","Object","prototype","toString","call","newLayoutType","index","length","key"],"mappings":";;;;AAEA,IAAMA,YAAY,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,QAAQ,EAAE,OAAO,CAAC;SAE1BC,WAAWA,CACjCC,SAAqB,EACrBC,SAAqB,EAErBC;MAAAA;IAAAA,cAAqDJ,YAAY;;EAEjE,IAAMK,aAAa,GAAGC,MAAM,CAACC,SAAS,CAACC,QAAQ,CAACC,IAAI,CAACP,SAAS,CAAC;EAC/D,IAAMQ,aAAa,GAAGJ,MAAM,CAACC,SAAS,CAACC,QAAQ,CAACC,IAAI,CAACN,SAAS,CAAC;EAE/D,IAAIE,aAAa,KAAKK,aAAa,IAAIA,aAAa,KAAK,iBAAiB,EAAE;IAC1E,KAAK,IAAIC,KAAK,GAAG,CAAC,EAAEA,KAAK,GAAGP,WAAW,CAACQ,MAAM,EAAED,KAAK,EAAE,EAAE;MACvD,IAAME,GAAG,GAAGT,WAAW,CAACO,KAAK,CAAC;MAC9B,IAAIT,SAAS,CAACW,GAAG,CAAC,KAAKV,SAAS,CAACU,GAAG,CAAC,EAAE;QACrC,OAAO,KAAK;;;IAIhB,OAAO,IAAI;;EAGb,OAAO,KAAK;AACd;;;;"}
1
+ {"version":3,"file":"layout-equal.cjs.development.js","sources":["../src/index.ts"],"sourcesContent":["import { ItemLayout } from './types';\n\nconst KEY_TO_CHECK = ['x', 'y', 'height', 'width'];\n\nexport default function layoutEqual(\n oldLayout: ItemLayout,\n newLayout: ItemLayout,\n options?: {\n // @ts-ignore\n keysToCheck?: Array<'x' | 'y' | 'height' | 'width'> = KEY_TO_CHECK;\n correctionValue?: number;\n }\n) {\n const oldLayoutType = Object.prototype.toString.call(oldLayout);\n const newLayoutType = Object.prototype.toString.call(newLayout);\n const keysToCheck = options?.keysToCheck;\n const correctionValue = options.correctionValue || 0;\n\n if (oldLayoutType === newLayoutType && newLayoutType === '[object Object]') {\n for (let index = 0; index < keysToCheck.length; index++) {\n const key = keysToCheck[index];\n if (Math.abs(oldLayout[key] - newLayout[key]) > correctionValue) {\n return false;\n }\n }\n\n return true;\n }\n\n return false;\n}\n"],"names":["layoutEqual","oldLayout","newLayout","options","oldLayoutType","Object","prototype","toString","call","newLayoutType","keysToCheck","correctionValue","index","length","key","Math","abs"],"mappings":";;;;SAIwBA,WAAWA,CACjCC,SAAqB,EACrBC,SAAqB,EACrBC,OAIC;EAED,IAAMC,aAAa,GAAGC,MAAM,CAACC,SAAS,CAACC,QAAQ,CAACC,IAAI,CAACP,SAAS,CAAC;EAC/D,IAAMQ,aAAa,GAAGJ,MAAM,CAACC,SAAS,CAACC,QAAQ,CAACC,IAAI,CAACN,SAAS,CAAC;EAC/D,IAAMQ,WAAW,GAAGP,OAAO,oBAAPA,OAAO,CAAEO,WAAW;EACxC,IAAMC,eAAe,GAAGR,OAAO,CAACQ,eAAe,IAAI,CAAC;EAEpD,IAAIP,aAAa,KAAKK,aAAa,IAAIA,aAAa,KAAK,iBAAiB,EAAE;IAC1E,KAAK,IAAIG,KAAK,GAAG,CAAC,EAAEA,KAAK,GAAGF,WAAW,CAACG,MAAM,EAAED,KAAK,EAAE,EAAE;MACvD,IAAME,GAAG,GAAGJ,WAAW,CAACE,KAAK,CAAC;MAC9B,IAAIG,IAAI,CAACC,GAAG,CAACf,SAAS,CAACa,GAAG,CAAC,GAAGZ,SAAS,CAACY,GAAG,CAAC,CAAC,GAAGH,eAAe,EAAE;QAC/D,OAAO,KAAK;;;IAIhB,OAAO,IAAI;;EAGb,OAAO,KAAK;AACd;;;;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=["x","y","height","width"];exports.default=function(e,r,o){void 0===o&&(o=t);var i=Object.prototype.toString.call(e),c=Object.prototype.toString.call(r);if(i===c&&"[object Object]"===c){for(var n=0;n<o.length;n++){var a=o[n];if(e[a]!==r[a])return!1}return!0}return!1};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=function(t,e,r){var o=Object.prototype.toString.call(t),c=Object.prototype.toString.call(e),l=null==r?void 0:r.keysToCheck,n=r.correctionValue||0;if(o===c&&"[object Object]"===c){for(var a=0;a<l.length;a++){var u=l[a];if(Math.abs(t[u]-e[u])>n)return!1}return!0}return!1};
2
2
  //# sourceMappingURL=layout-equal.cjs.production.min.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"layout-equal.cjs.production.min.js","sources":["../src/index.ts"],"sourcesContent":["import { ItemLayout } from './types';\n\nconst KEY_TO_CHECK = ['x', 'y', 'height', 'width'];\n\nexport default function layoutEqual(\n oldLayout: ItemLayout,\n newLayout: ItemLayout,\n // @ts-ignore\n keysToCheck: Array<'x' | 'y' | 'height' | 'width'> = KEY_TO_CHECK\n) {\n const oldLayoutType = Object.prototype.toString.call(oldLayout);\n const newLayoutType = Object.prototype.toString.call(newLayout);\n\n if (oldLayoutType === newLayoutType && newLayoutType === '[object Object]') {\n for (let index = 0; index < keysToCheck.length; index++) {\n const key = keysToCheck[index];\n if (oldLayout[key] !== newLayout[key]) {\n return false;\n }\n }\n\n return true;\n }\n\n return false;\n}\n"],"names":["KEY_TO_CHECK","oldLayout","newLayout","keysToCheck","oldLayoutType","Object","prototype","toString","call","newLayoutType","index","length","key"],"mappings":"oEAEA,IAAMA,EAAe,CAAC,IAAK,IAAK,SAAU,kCAGxCC,EACAC,EAEAC,YAAAA,IAAAA,EAAqDH,GAErD,IAAMI,EAAgBC,OAAOC,UAAUC,SAASC,KAAKP,GAC/CQ,EAAgBJ,OAAOC,UAAUC,SAASC,KAAKN,GAErD,GAAIE,IAAkBK,GAAmC,oBAAlBA,EAAqC,CAC1E,IAAK,IAAIC,EAAQ,EAAGA,EAAQP,EAAYQ,OAAQD,IAAS,CACvD,IAAME,EAAMT,EAAYO,GACxB,GAAIT,EAAUW,KAASV,EAAUU,GAC/B,OAAO,EAIX,OAAO,EAGT,OAAO"}
1
+ {"version":3,"file":"layout-equal.cjs.production.min.js","sources":["../src/index.ts"],"sourcesContent":["import { ItemLayout } from './types';\n\nconst KEY_TO_CHECK = ['x', 'y', 'height', 'width'];\n\nexport default function layoutEqual(\n oldLayout: ItemLayout,\n newLayout: ItemLayout,\n options?: {\n // @ts-ignore\n keysToCheck?: Array<'x' | 'y' | 'height' | 'width'> = KEY_TO_CHECK;\n correctionValue?: number;\n }\n) {\n const oldLayoutType = Object.prototype.toString.call(oldLayout);\n const newLayoutType = Object.prototype.toString.call(newLayout);\n const keysToCheck = options?.keysToCheck;\n const correctionValue = options.correctionValue || 0;\n\n if (oldLayoutType === newLayoutType && newLayoutType === '[object Object]') {\n for (let index = 0; index < keysToCheck.length; index++) {\n const key = keysToCheck[index];\n if (Math.abs(oldLayout[key] - newLayout[key]) > correctionValue) {\n return false;\n }\n }\n\n return true;\n }\n\n return false;\n}\n"],"names":["oldLayout","newLayout","options","oldLayoutType","Object","prototype","toString","call","newLayoutType","keysToCheck","correctionValue","index","length","key","Math","abs"],"mappings":"6FAKEA,EACAC,EACAC,GAMA,IAAMC,EAAgBC,OAAOC,UAAUC,SAASC,KAAKP,GAC/CQ,EAAgBJ,OAAOC,UAAUC,SAASC,KAAKN,GAC/CQ,QAAcP,SAAAA,EAASO,YACvBC,EAAkBR,EAAQQ,iBAAmB,EAEnD,GAAIP,IAAkBK,GAAmC,oBAAlBA,EAAqC,CAC1E,IAAK,IAAIG,EAAQ,EAAGA,EAAQF,EAAYG,OAAQD,IAAS,CACvD,IAAME,EAAMJ,EAAYE,GACxB,GAAIG,KAAKC,IAAIf,EAAUa,GAAOZ,EAAUY,IAAQH,EAC9C,OAAO,EAIX,OAAO,EAGT,OAAO"}
@@ -1,14 +1,12 @@
1
- var KEY_TO_CHECK = ['x', 'y', 'height', 'width'];
2
- function layoutEqual(oldLayout, newLayout, keysToCheck) {
3
- if (keysToCheck === void 0) {
4
- keysToCheck = KEY_TO_CHECK;
5
- }
1
+ function layoutEqual(oldLayout, newLayout, options) {
6
2
  var oldLayoutType = Object.prototype.toString.call(oldLayout);
7
3
  var newLayoutType = Object.prototype.toString.call(newLayout);
4
+ var keysToCheck = options == null ? void 0 : options.keysToCheck;
5
+ var correctionValue = options.correctionValue || 0;
8
6
  if (oldLayoutType === newLayoutType && newLayoutType === '[object Object]') {
9
7
  for (var index = 0; index < keysToCheck.length; index++) {
10
8
  var key = keysToCheck[index];
11
- if (oldLayout[key] !== newLayout[key]) {
9
+ if (Math.abs(oldLayout[key] - newLayout[key]) > correctionValue) {
12
10
  return false;
13
11
  }
14
12
  }
@@ -1 +1 @@
1
- {"version":3,"file":"layout-equal.esm.js","sources":["../src/index.ts"],"sourcesContent":["import { ItemLayout } from './types';\n\nconst KEY_TO_CHECK = ['x', 'y', 'height', 'width'];\n\nexport default function layoutEqual(\n oldLayout: ItemLayout,\n newLayout: ItemLayout,\n // @ts-ignore\n keysToCheck: Array<'x' | 'y' | 'height' | 'width'> = KEY_TO_CHECK\n) {\n const oldLayoutType = Object.prototype.toString.call(oldLayout);\n const newLayoutType = Object.prototype.toString.call(newLayout);\n\n if (oldLayoutType === newLayoutType && newLayoutType === '[object Object]') {\n for (let index = 0; index < keysToCheck.length; index++) {\n const key = keysToCheck[index];\n if (oldLayout[key] !== newLayout[key]) {\n return false;\n }\n }\n\n return true;\n }\n\n return false;\n}\n"],"names":["KEY_TO_CHECK","layoutEqual","oldLayout","newLayout","keysToCheck","oldLayoutType","Object","prototype","toString","call","newLayoutType","index","length","key"],"mappings":"AAEA,IAAMA,YAAY,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,QAAQ,EAAE,OAAO,CAAC;SAE1BC,WAAWA,CACjCC,SAAqB,EACrBC,SAAqB,EAErBC;MAAAA;IAAAA,cAAqDJ,YAAY;;EAEjE,IAAMK,aAAa,GAAGC,MAAM,CAACC,SAAS,CAACC,QAAQ,CAACC,IAAI,CAACP,SAAS,CAAC;EAC/D,IAAMQ,aAAa,GAAGJ,MAAM,CAACC,SAAS,CAACC,QAAQ,CAACC,IAAI,CAACN,SAAS,CAAC;EAE/D,IAAIE,aAAa,KAAKK,aAAa,IAAIA,aAAa,KAAK,iBAAiB,EAAE;IAC1E,KAAK,IAAIC,KAAK,GAAG,CAAC,EAAEA,KAAK,GAAGP,WAAW,CAACQ,MAAM,EAAED,KAAK,EAAE,EAAE;MACvD,IAAME,GAAG,GAAGT,WAAW,CAACO,KAAK,CAAC;MAC9B,IAAIT,SAAS,CAACW,GAAG,CAAC,KAAKV,SAAS,CAACU,GAAG,CAAC,EAAE;QACrC,OAAO,KAAK;;;IAIhB,OAAO,IAAI;;EAGb,OAAO,KAAK;AACd;;;;"}
1
+ {"version":3,"file":"layout-equal.esm.js","sources":["../src/index.ts"],"sourcesContent":["import { ItemLayout } from './types';\n\nconst KEY_TO_CHECK = ['x', 'y', 'height', 'width'];\n\nexport default function layoutEqual(\n oldLayout: ItemLayout,\n newLayout: ItemLayout,\n options?: {\n // @ts-ignore\n keysToCheck?: Array<'x' | 'y' | 'height' | 'width'> = KEY_TO_CHECK;\n correctionValue?: number;\n }\n) {\n const oldLayoutType = Object.prototype.toString.call(oldLayout);\n const newLayoutType = Object.prototype.toString.call(newLayout);\n const keysToCheck = options?.keysToCheck;\n const correctionValue = options.correctionValue || 0;\n\n if (oldLayoutType === newLayoutType && newLayoutType === '[object Object]') {\n for (let index = 0; index < keysToCheck.length; index++) {\n const key = keysToCheck[index];\n if (Math.abs(oldLayout[key] - newLayout[key]) > correctionValue) {\n return false;\n }\n }\n\n return true;\n }\n\n return false;\n}\n"],"names":["layoutEqual","oldLayout","newLayout","options","oldLayoutType","Object","prototype","toString","call","newLayoutType","keysToCheck","correctionValue","index","length","key","Math","abs"],"mappings":"SAIwBA,WAAWA,CACjCC,SAAqB,EACrBC,SAAqB,EACrBC,OAIC;EAED,IAAMC,aAAa,GAAGC,MAAM,CAACC,SAAS,CAACC,QAAQ,CAACC,IAAI,CAACP,SAAS,CAAC;EAC/D,IAAMQ,aAAa,GAAGJ,MAAM,CAACC,SAAS,CAACC,QAAQ,CAACC,IAAI,CAACN,SAAS,CAAC;EAC/D,IAAMQ,WAAW,GAAGP,OAAO,oBAAPA,OAAO,CAAEO,WAAW;EACxC,IAAMC,eAAe,GAAGR,OAAO,CAACQ,eAAe,IAAI,CAAC;EAEpD,IAAIP,aAAa,KAAKK,aAAa,IAAIA,aAAa,KAAK,iBAAiB,EAAE;IAC1E,KAAK,IAAIG,KAAK,GAAG,CAAC,EAAEA,KAAK,GAAGF,WAAW,CAACG,MAAM,EAAED,KAAK,EAAE,EAAE;MACvD,IAAME,GAAG,GAAGJ,WAAW,CAACE,KAAK,CAAC;MAC9B,IAAIG,IAAI,CAACC,GAAG,CAACf,SAAS,CAACa,GAAG,CAAC,GAAGZ,SAAS,CAACY,GAAG,CAAC,CAAC,GAAGH,eAAe,EAAE;QAC/D,OAAO,KAAK;;;IAIhB,OAAO,IAAI;;EAGb,OAAO,KAAK;AACd;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@x-oasis/layout-equal",
3
- "version": "0.1.14",
3
+ "version": "0.1.15",
4
4
  "description": "select value function",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
package/src/index.ts CHANGED
@@ -5,16 +5,21 @@ const KEY_TO_CHECK = ['x', 'y', 'height', 'width'];
5
5
  export default function layoutEqual(
6
6
  oldLayout: ItemLayout,
7
7
  newLayout: ItemLayout,
8
- // @ts-ignore
9
- keysToCheck: Array<'x' | 'y' | 'height' | 'width'> = KEY_TO_CHECK
8
+ options?: {
9
+ // @ts-ignore
10
+ keysToCheck?: Array<'x' | 'y' | 'height' | 'width'> = KEY_TO_CHECK;
11
+ correctionValue?: number;
12
+ }
10
13
  ) {
11
14
  const oldLayoutType = Object.prototype.toString.call(oldLayout);
12
15
  const newLayoutType = Object.prototype.toString.call(newLayout);
16
+ const keysToCheck = options?.keysToCheck;
17
+ const correctionValue = options.correctionValue || 0;
13
18
 
14
19
  if (oldLayoutType === newLayoutType && newLayoutType === '[object Object]') {
15
20
  for (let index = 0; index < keysToCheck.length; index++) {
16
21
  const key = keysToCheck[index];
17
- if (oldLayout[key] !== newLayout[key]) {
22
+ if (Math.abs(oldLayout[key] - newLayout[key]) > correctionValue) {
18
23
  return false;
19
24
  }
20
25
  }