aio-class 2.1.2 → 2.1.3

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.
Files changed (3) hide show
  1. package/index.d.ts +7 -5
  2. package/index.js +5 -5
  3. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -176,13 +176,11 @@ type I_sort<T> = {
176
176
  getValue: (row: T, dir: 'inc' | 'dec') => any;
177
177
  };
178
178
  type I_id = string | number;
179
- type I_EntityClass<T> = {
179
+ export type I_EntityMap<T> = {
180
180
  getChilds: (row: T) => T[] | undefined;
181
181
  setChilds: (row: T, childs: T[] | undefined) => T;
182
182
  getId: (row: T) => I_id;
183
183
  setId: (row: T) => T;
184
- getData?: () => T[];
185
- setData?: (v: T[]) => void;
186
184
  };
187
185
  type I_rowResult<T> = {
188
186
  row: T;
@@ -200,10 +198,14 @@ type I_rowResult<T> = {
200
198
  isLastChild: boolean;
201
199
  };
202
200
  export declare class EntityClass<T> {
203
- params: I_EntityClass<T>;
201
+ map: I_EntityMap<T>;
204
202
  getData: () => T[];
205
203
  setData: (v: T[]) => void;
206
- constructor(p: I_EntityClass<T>);
204
+ constructor(p: {
205
+ map: I_EntityMap<T>;
206
+ getData?: () => T[];
207
+ setData?: (v: T[]) => void;
208
+ });
207
209
  private getId;
208
210
  private setId;
209
211
  private getChilds;
package/index.js CHANGED
@@ -1501,10 +1501,10 @@ export class EntityClass {
1501
1501
  constructor(p) {
1502
1502
  this.getData = () => [];
1503
1503
  this.setData = () => { };
1504
- this.getId = (row) => this.params.getId(row);
1505
- this.setId = (row) => this.params.setId(row);
1506
- this.getChilds = (row) => this.params.getChilds(row);
1507
- this.setChilds = (row, childs) => this.params.setChilds(row, childs);
1504
+ this.getId = (row) => this.map.getId(row);
1505
+ this.setId = (row) => this.map.setId(row);
1506
+ this.getChilds = (row) => this.map.getChilds(row);
1507
+ this.setChilds = (row, childs) => this.map.setChilds(row, childs);
1508
1508
  this.getRowDetailsByIds = (data, rowIds) => {
1509
1509
  const fn = (data, parents, temp) => {
1510
1510
  const isFoundAll = () => Object.keys(temp).filter((rowId) => temp[rowId] === false).length === 0;
@@ -1922,7 +1922,7 @@ export class EntityClass {
1922
1922
  this.traverse(data, callback);
1923
1923
  }
1924
1924
  };
1925
- this.params = p;
1925
+ this.map = p.map;
1926
1926
  if (p.getData) {
1927
1927
  this.getData = p.getData;
1928
1928
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aio-class",
3
- "version": "2.1.2",
3
+ "version": "2.1.3",
4
4
  "description": "",
5
5
  "homepage": "https://github.com/mohammadFeiz/aio-class#readme",
6
6
  "bugs": {