@akanjs/base 1.0.15 → 1.0.16

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/cjs/src/base.js CHANGED
@@ -78,8 +78,17 @@ class DataList {
78
78
  length;
79
79
  values;
80
80
  constructor(data = []) {
81
- this.values = Array.isArray(data) ? [...data] : [...data.values];
82
- this.#idMap = new Map(this.values.map((value, idx) => [value.id, idx]));
81
+ const values = Array.isArray(data) ? data : data.values;
82
+ this.values = [];
83
+ this.#idMap = /* @__PURE__ */ new Map();
84
+ values.forEach((value) => {
85
+ const idx = this.#idMap.get(value.id);
86
+ if (idx === void 0) {
87
+ this.#idMap.set(value.id, this.values.length);
88
+ this.values.push(value);
89
+ } else
90
+ this.values[idx] = value;
91
+ });
83
92
  this.length = this.values.length;
84
93
  }
85
94
  indexOf(id) {
@@ -105,7 +114,9 @@ class DataList {
105
114
  return this;
106
115
  this.#idMap.delete(id);
107
116
  this.values.splice(idx, 1);
108
- this.values.slice(idx).forEach((value, i) => this.#idMap.set(value.id, i + idx));
117
+ this.values.slice(idx).forEach((value, i) => {
118
+ this.#idMap.set(value.id, i + idx);
119
+ });
109
120
  this.length--;
110
121
  return this;
111
122
  }
package/esm/src/base.js CHANGED
@@ -53,8 +53,17 @@ class DataList {
53
53
  length;
54
54
  values;
55
55
  constructor(data = []) {
56
- this.values = Array.isArray(data) ? [...data] : [...data.values];
57
- this.#idMap = new Map(this.values.map((value, idx) => [value.id, idx]));
56
+ const values = Array.isArray(data) ? data : data.values;
57
+ this.values = [];
58
+ this.#idMap = /* @__PURE__ */ new Map();
59
+ values.forEach((value) => {
60
+ const idx = this.#idMap.get(value.id);
61
+ if (idx === void 0) {
62
+ this.#idMap.set(value.id, this.values.length);
63
+ this.values.push(value);
64
+ } else
65
+ this.values[idx] = value;
66
+ });
58
67
  this.length = this.values.length;
59
68
  }
60
69
  indexOf(id) {
@@ -80,7 +89,9 @@ class DataList {
80
89
  return this;
81
90
  this.#idMap.delete(id);
82
91
  this.values.splice(idx, 1);
83
- this.values.slice(idx).forEach((value, i) => this.#idMap.set(value.id, i + idx));
92
+ this.values.slice(idx).forEach((value, i) => {
93
+ this.#idMap.set(value.id, i + idx);
94
+ });
84
95
  this.length--;
85
96
  return this;
86
97
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akanjs/base",
3
- "version": "1.0.15",
3
+ "version": "1.0.16",
4
4
  "sourceType": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"