pacc 9.2.11 → 9.2.13

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 (2) hide show
  1. package/package.json +3 -2
  2. package/src/expand.mjs +15 -12
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "pacc",
3
- "version": "9.2.11",
3
+ "version": "9.2.13",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "provenance": true
7
7
  },
8
- "packageManager": "npm@11.13.0",
8
+ "packageManager": "npm@11.16.0",
9
9
  "types": "./types/module.d.mts",
10
10
  "exports": {
11
11
  ".": {
@@ -43,6 +43,7 @@
43
43
  },
44
44
  "devDependencies": {
45
45
  "@mitata/counters": "^0.0.8",
46
+ "aggregated-map": "^1.0.3",
46
47
  "ava": "^8.0.1",
47
48
  "browser-ava": "^2.3.61",
48
49
  "c8": "^11.0.0",
package/src/expand.mjs CHANGED
@@ -103,13 +103,12 @@ export function expand(object, context) {
103
103
  return object;
104
104
  }
105
105
 
106
- if (object === null || object instanceof Number || object instanceof Date) {
107
- // TODO: find a better way to identify special cases
106
+ if (object === null) {
108
107
  return object;
109
108
  }
110
109
 
111
110
  if (Array.isArray(object)) {
112
- const array = new Array(object.length);
111
+ const copy = new object.constructor[Symbol.species](object.length);
113
112
 
114
113
  for (let index = 0; index < object.length; index++) {
115
114
  const o = object[index];
@@ -122,25 +121,25 @@ export function expand(object, context) {
122
121
  ]);
123
122
  if (r instanceof Promise) {
124
123
  promises.push(r);
125
- r.then(f => (array[index] = f));
124
+ r.then(f => (copy[index] = f));
126
125
  }
127
- array[index] = r;
126
+ copy[index] = r;
128
127
  }
129
128
 
130
- return array;
129
+ return copy;
131
130
  }
132
131
 
133
132
  if (typeof object.add === "function") {
134
- const r = new object.constructor();
133
+ const copy = new object.constructor[Symbol.species]();
135
134
  for (const value of object.values()) {
136
- r.add(_expand(value, [...path, { value }]));
135
+ copy.add(_expand(value, [...path, { value }]));
137
136
  }
138
137
 
139
- return r;
138
+ return copy;
140
139
  }
141
140
 
142
141
  if (typeof object.entries === "function") {
143
- const r = new object.constructor();
142
+ const copy = new object.constructor[Symbol.species]();
144
143
  for (const [key, value] of object.entries()) {
145
144
  const path2 = [
146
145
  ...path,
@@ -150,16 +149,20 @@ export function expand(object, context) {
150
149
  }
151
150
  ];
152
151
 
153
- r.set(_expand(key, path2), _expand(value, path2));
152
+ copy.set(_expand(key, path2), _expand(value, path2));
154
153
  }
155
154
 
156
- return r;
155
+ return copy;
157
156
  }
158
157
 
159
158
  if (context.stopClass && object instanceof context.stopClass) {
160
159
  return object;
161
160
  }
162
161
 
162
+ if(Object.prototype.toString.call(object) !== '[object Object]') {
163
+ return object;
164
+ }
165
+
163
166
  let newObject = {};
164
167
 
165
168
  for (let [key, value] of Object.entries(object)) {