bare-script 3.1.0 → 3.2.1
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/lib/value.js +20 -0
- package/package.json +2 -2
package/lib/value.js
CHANGED
|
@@ -116,6 +116,8 @@ function valueJSONSort(value) {
|
|
|
116
116
|
valueCopy[valueKey] = valueJSONSort(value[valueKey]);
|
|
117
117
|
}
|
|
118
118
|
return valueCopy;
|
|
119
|
+
} else if (type === 'function') {
|
|
120
|
+
return valueString(value);
|
|
119
121
|
}
|
|
120
122
|
|
|
121
123
|
// Everything else is null
|
|
@@ -199,6 +201,24 @@ export function valueCompare(left, right) {
|
|
|
199
201
|
}
|
|
200
202
|
}
|
|
201
203
|
return left.length < right.length ? -1 : (left.length === right.length ? 0 : 1);
|
|
204
|
+
} else if (leftType === 'object' && Object.getPrototypeOf(left) === Object.prototype &&
|
|
205
|
+
rightType === 'object' && Object.getPrototypeOf(right) === Object.prototype) {
|
|
206
|
+
const leftKeyValues = Object.entries(left).sort((kv1, kv2) => kv1[0].localeCompare(kv2[0]));
|
|
207
|
+
const rightKeyValues = Object.entries(right).sort((kv1, kv2) => kv1[0].localeCompare(kv2[0]));
|
|
208
|
+
const ixMax = Math.min(leftKeyValues.length, rightKeyValues.length);
|
|
209
|
+
let ix = 0;
|
|
210
|
+
while (ix < ixMax) {
|
|
211
|
+
const keyCompare = valueCompare(leftKeyValues[ix][0], rightKeyValues[ix][0]);
|
|
212
|
+
if (keyCompare !== 0) {
|
|
213
|
+
return keyCompare;
|
|
214
|
+
}
|
|
215
|
+
const valCompare = valueCompare(leftKeyValues[ix][1], rightKeyValues[ix][1]);
|
|
216
|
+
if (valCompare !== 0) {
|
|
217
|
+
return valCompare;
|
|
218
|
+
}
|
|
219
|
+
ix += 1;
|
|
220
|
+
}
|
|
221
|
+
return leftKeyValues.length < rightKeyValues.length ? -1 : (leftKeyValues.length === rightKeyValues.length ? 0 : 1);
|
|
202
222
|
}
|
|
203
223
|
|
|
204
224
|
// Invalid comparison - compare by type name
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "bare-script",
|
|
4
|
-
"version": "3.1
|
|
4
|
+
"version": "3.2.1",
|
|
5
5
|
"description": "BareScript; a lightweight scripting and expression language",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"expression",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"c8": "~10.1",
|
|
34
|
-
"eslint": "~9.
|
|
34
|
+
"eslint": "~9.21",
|
|
35
35
|
"jsdoc": "~4.0"
|
|
36
36
|
}
|
|
37
37
|
}
|