poe-code 13.0.2 → 13.0.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.
- package/dist/index.js +146 -95
- package/dist/index.js.map +2 -2
- package/dist/metafile.json +1 -1
- package/package.json +1 -1
- package/packages/safe-js/dist/chunks/{chunk-RIQRHKCB.js → chunk-73LWNNUG.js} +146 -95
- package/packages/safe-js/dist/chunks/{chunk-RIQRHKCB.js.map → chunk-73LWNNUG.js.map} +2 -2
- package/packages/safe-js/dist/chunks/{chunk-JP474LP7.js → chunk-QCJ7UAMC.js} +2 -2
- package/packages/safe-js/dist/cli.js +2 -2
- package/packages/safe-js/dist/core.js +1 -1
- package/packages/safe-js/dist/index.js +2 -2
- package/packages/safe-js/dist/interp/methods/array.js +136 -71
- /package/packages/safe-js/dist/chunks/{chunk-JP474LP7.js.map → chunk-QCJ7UAMC.js.map} +0 -0
package/dist/index.js
CHANGED
|
@@ -138898,14 +138898,6 @@ function enterRunningState(object) {
|
|
|
138898
138898
|
runningObjects.delete(object);
|
|
138899
138899
|
};
|
|
138900
138900
|
}
|
|
138901
|
-
function enterCollectionCallback(object) {
|
|
138902
|
-
const leaveRunning = enterRunningState(object);
|
|
138903
|
-
lockedCollections.add(object);
|
|
138904
|
-
return () => {
|
|
138905
|
-
lockedCollections.delete(object);
|
|
138906
|
-
leaveRunning();
|
|
138907
|
-
};
|
|
138908
|
-
}
|
|
138909
138901
|
function assertCollectionMutable(object) {
|
|
138910
138902
|
if (lockedCollections.has(object)) {
|
|
138911
138903
|
throw new SandboxError("reentry");
|
|
@@ -143669,7 +143661,7 @@ async function callArrayMethod(value, methodName, args, options, stack = []) {
|
|
|
143669
143661
|
if (isCallbackArrayMethod(methodName)) {
|
|
143670
143662
|
let callbackState = activeArrayCallbacks.get(value);
|
|
143671
143663
|
if (callbackState === void 0) {
|
|
143672
|
-
callbackState = { depth: 0, leave:
|
|
143664
|
+
callbackState = { depth: 0, leave: enterRunningState(value) };
|
|
143673
143665
|
activeArrayCallbacks.set(value, callbackState);
|
|
143674
143666
|
}
|
|
143675
143667
|
callbackState.depth += 1;
|
|
@@ -143920,42 +143912,63 @@ function getRequiredCallback(methodName, value) {
|
|
|
143920
143912
|
async function mapArray(value, callback, options, stack, thisValue) {
|
|
143921
143913
|
const length = value.length;
|
|
143922
143914
|
const result = new Array(length);
|
|
143923
|
-
|
|
143924
|
-
|
|
143925
|
-
|
|
143915
|
+
options.budget.setRetainedValues(result, () => [result]);
|
|
143916
|
+
try {
|
|
143917
|
+
for (let index = 0; index < length; index += 1) {
|
|
143918
|
+
options.budget.visitNode();
|
|
143919
|
+
if (!(index in value)) {
|
|
143920
|
+
continue;
|
|
143921
|
+
}
|
|
143922
|
+
result[index] = await callArrayCallback(
|
|
143923
|
+
callback,
|
|
143924
|
+
value[index],
|
|
143925
|
+
index,
|
|
143926
|
+
value,
|
|
143927
|
+
options,
|
|
143928
|
+
stack,
|
|
143929
|
+
thisValue
|
|
143930
|
+
);
|
|
143926
143931
|
}
|
|
143927
|
-
result
|
|
143928
|
-
|
|
143929
|
-
|
|
143930
|
-
index,
|
|
143931
|
-
value,
|
|
143932
|
-
options,
|
|
143933
|
-
stack,
|
|
143934
|
-
thisValue
|
|
143935
|
-
);
|
|
143932
|
+
return result;
|
|
143933
|
+
} finally {
|
|
143934
|
+
options.budget.setRetainedValues(result, void 0);
|
|
143936
143935
|
}
|
|
143937
|
-
return result;
|
|
143938
143936
|
}
|
|
143939
143937
|
async function filterArray(value, callback, options, stack, thisValue) {
|
|
143940
143938
|
const length = value.length;
|
|
143941
143939
|
const result = [];
|
|
143942
|
-
|
|
143943
|
-
|
|
143944
|
-
|
|
143945
|
-
|
|
143946
|
-
|
|
143947
|
-
|
|
143940
|
+
options.budget.setRetainedValues(result, () => [result]);
|
|
143941
|
+
try {
|
|
143942
|
+
for (let index = 0; index < length; index += 1) {
|
|
143943
|
+
options.budget.visitNode();
|
|
143944
|
+
if (!(index in value)) {
|
|
143945
|
+
continue;
|
|
143946
|
+
}
|
|
143947
|
+
const entry = value[index];
|
|
143948
|
+
if (await callArrayCallback(callback, entry, index, value, options, stack, thisValue)) {
|
|
143949
|
+
result.push(entry);
|
|
143950
|
+
}
|
|
143948
143951
|
}
|
|
143952
|
+
return result;
|
|
143953
|
+
} finally {
|
|
143954
|
+
options.budget.setRetainedValues(result, void 0);
|
|
143949
143955
|
}
|
|
143950
|
-
return result;
|
|
143951
143956
|
}
|
|
143952
143957
|
async function findInArray(value, callback, options, stack, thisValue) {
|
|
143953
|
-
const
|
|
143954
|
-
|
|
143958
|
+
const length = value.length;
|
|
143959
|
+
for (let index = 0; index < length; index += 1) {
|
|
143960
|
+
options.budget.visitNode();
|
|
143961
|
+
const entry = index in value ? value[index] : void 0;
|
|
143962
|
+
if (await callArrayCallback(callback, entry, index, value, options, stack, thisValue)) {
|
|
143963
|
+
return entry;
|
|
143964
|
+
}
|
|
143965
|
+
}
|
|
143966
|
+
return void 0;
|
|
143955
143967
|
}
|
|
143956
143968
|
async function findIndexInArray(value, callback, options, stack, thisValue) {
|
|
143957
143969
|
const length = value.length;
|
|
143958
143970
|
for (let index = 0; index < length; index += 1) {
|
|
143971
|
+
options.budget.visitNode();
|
|
143959
143972
|
const entry = index in value ? value[index] : void 0;
|
|
143960
143973
|
if (await callArrayCallback(callback, entry, index, value, options, stack, thisValue)) {
|
|
143961
143974
|
return index;
|
|
@@ -143966,6 +143979,7 @@ async function findIndexInArray(value, callback, options, stack, thisValue) {
|
|
|
143966
143979
|
async function findLastInArray(value, callback, options, stack, thisValue) {
|
|
143967
143980
|
const length = value.length;
|
|
143968
143981
|
for (let index = length - 1; index >= 0; index -= 1) {
|
|
143982
|
+
options.budget.visitNode();
|
|
143969
143983
|
const entry = index in value ? value[index] : void 0;
|
|
143970
143984
|
if (await callArrayCallback(callback, entry, index, value, options, stack, thisValue)) {
|
|
143971
143985
|
return entry;
|
|
@@ -143976,6 +143990,7 @@ async function findLastInArray(value, callback, options, stack, thisValue) {
|
|
|
143976
143990
|
async function findLastIndexInArray(value, callback, options, stack, thisValue) {
|
|
143977
143991
|
const length = value.length;
|
|
143978
143992
|
for (let index = length - 1; index >= 0; index -= 1) {
|
|
143993
|
+
options.budget.visitNode();
|
|
143979
143994
|
const entry = index in value ? value[index] : void 0;
|
|
143980
143995
|
if (await callArrayCallback(callback, entry, index, value, options, stack, thisValue)) {
|
|
143981
143996
|
return index;
|
|
@@ -143986,6 +144001,7 @@ async function findLastIndexInArray(value, callback, options, stack, thisValue)
|
|
|
143986
144001
|
async function someInArray(value, callback, options, stack, thisValue) {
|
|
143987
144002
|
const length = value.length;
|
|
143988
144003
|
for (let index = 0; index < length; index += 1) {
|
|
144004
|
+
options.budget.visitNode();
|
|
143989
144005
|
if (!(index in value)) {
|
|
143990
144006
|
continue;
|
|
143991
144007
|
}
|
|
@@ -143998,6 +144014,7 @@ async function someInArray(value, callback, options, stack, thisValue) {
|
|
|
143998
144014
|
async function everyInArray(value, callback, options, stack, thisValue) {
|
|
143999
144015
|
const length = value.length;
|
|
144000
144016
|
for (let index = 0; index < length; index += 1) {
|
|
144017
|
+
options.budget.visitNode();
|
|
144001
144018
|
if (!(index in value)) {
|
|
144002
144019
|
continue;
|
|
144003
144020
|
}
|
|
@@ -144009,10 +144026,10 @@ async function everyInArray(value, callback, options, stack, thisValue) {
|
|
|
144009
144026
|
}
|
|
144010
144027
|
async function reduceArray(value, callback, hasInitialValue, initialValue, options, stack) {
|
|
144011
144028
|
const length = value.length;
|
|
144012
|
-
const start = findNextDefinedIndex(value, 0, 1, length);
|
|
144013
144029
|
if (hasInitialValue) {
|
|
144014
|
-
return reduceFromLeft(value, callback, initialValue,
|
|
144030
|
+
return reduceFromLeft(value, callback, initialValue, 0, length, options, stack);
|
|
144015
144031
|
}
|
|
144032
|
+
const start = findNextDefinedIndex(value, 0, 1, length, options.budget);
|
|
144016
144033
|
if (start < 0) {
|
|
144017
144034
|
throw new TypeError("Reduce of empty array with no initial value.");
|
|
144018
144035
|
}
|
|
@@ -144020,10 +144037,10 @@ async function reduceArray(value, callback, hasInitialValue, initialValue, optio
|
|
|
144020
144037
|
}
|
|
144021
144038
|
async function reduceRightArray(value, callback, hasInitialValue, initialValue, options, stack) {
|
|
144022
144039
|
const length = value.length;
|
|
144023
|
-
const start = findNextDefinedIndex(value, length - 1, -1, length);
|
|
144024
144040
|
if (hasInitialValue) {
|
|
144025
|
-
return reduceFromRight(value, callback, initialValue,
|
|
144041
|
+
return reduceFromRight(value, callback, initialValue, length - 1, length, options, stack);
|
|
144026
144042
|
}
|
|
144043
|
+
const start = findNextDefinedIndex(value, length - 1, -1, length, options.budget);
|
|
144027
144044
|
if (start < 0) {
|
|
144028
144045
|
throw new TypeError("Reduce of empty array with no initial value.");
|
|
144029
144046
|
}
|
|
@@ -144031,27 +144048,42 @@ async function reduceRightArray(value, callback, hasInitialValue, initialValue,
|
|
|
144031
144048
|
}
|
|
144032
144049
|
async function reduceFromLeft(value, callback, accumulator, startIndex, length, options, stack) {
|
|
144033
144050
|
let current = accumulator;
|
|
144034
|
-
|
|
144035
|
-
|
|
144036
|
-
|
|
144051
|
+
const retainedAccumulator = {};
|
|
144052
|
+
options.budget.setRetainedValues(retainedAccumulator, () => [current]);
|
|
144053
|
+
try {
|
|
144054
|
+
for (let index = startIndex; index < length; index += 1) {
|
|
144055
|
+
options.budget.visitNode();
|
|
144056
|
+
if (!(index in value)) {
|
|
144057
|
+
continue;
|
|
144058
|
+
}
|
|
144059
|
+
current = await options.callClosure(callback, [current, value[index], index, value], stack);
|
|
144037
144060
|
}
|
|
144038
|
-
|
|
144061
|
+
return current;
|
|
144062
|
+
} finally {
|
|
144063
|
+
options.budget.setRetainedValues(retainedAccumulator, void 0);
|
|
144039
144064
|
}
|
|
144040
|
-
return current;
|
|
144041
144065
|
}
|
|
144042
144066
|
async function reduceFromRight(value, callback, accumulator, startIndex, length, options, stack) {
|
|
144043
144067
|
let current = accumulator;
|
|
144044
|
-
|
|
144045
|
-
|
|
144046
|
-
|
|
144068
|
+
const retainedAccumulator = {};
|
|
144069
|
+
options.budget.setRetainedValues(retainedAccumulator, () => [current]);
|
|
144070
|
+
try {
|
|
144071
|
+
for (let index = Math.min(startIndex, length - 1); index >= 0; index -= 1) {
|
|
144072
|
+
options.budget.visitNode();
|
|
144073
|
+
if (!(index in value)) {
|
|
144074
|
+
continue;
|
|
144075
|
+
}
|
|
144076
|
+
current = await options.callClosure(callback, [current, value[index], index, value], stack);
|
|
144047
144077
|
}
|
|
144048
|
-
|
|
144078
|
+
return current;
|
|
144079
|
+
} finally {
|
|
144080
|
+
options.budget.setRetainedValues(retainedAccumulator, void 0);
|
|
144049
144081
|
}
|
|
144050
|
-
return current;
|
|
144051
144082
|
}
|
|
144052
144083
|
async function forEachArray(value, callback, options, stack, thisValue) {
|
|
144053
144084
|
const length = value.length;
|
|
144054
144085
|
for (let index = 0; index < length; index += 1) {
|
|
144086
|
+
options.budget.visitNode();
|
|
144055
144087
|
if (!(index in value)) {
|
|
144056
144088
|
continue;
|
|
144057
144089
|
}
|
|
@@ -144061,33 +144093,40 @@ async function forEachArray(value, callback, options, stack, thisValue) {
|
|
|
144061
144093
|
async function flatMapArray(value, callback, options, stack, thisValue) {
|
|
144062
144094
|
const length = value.length;
|
|
144063
144095
|
const result = [];
|
|
144064
|
-
|
|
144065
|
-
|
|
144066
|
-
|
|
144067
|
-
|
|
144068
|
-
|
|
144069
|
-
|
|
144070
|
-
|
|
144071
|
-
|
|
144072
|
-
|
|
144073
|
-
|
|
144074
|
-
|
|
144075
|
-
|
|
144076
|
-
|
|
144077
|
-
|
|
144078
|
-
|
|
144079
|
-
|
|
144080
|
-
|
|
144096
|
+
options.budget.setRetainedValues(result, () => [result]);
|
|
144097
|
+
try {
|
|
144098
|
+
for (let index = 0; index < length; index += 1) {
|
|
144099
|
+
options.budget.visitNode();
|
|
144100
|
+
if (!(index in value)) {
|
|
144101
|
+
continue;
|
|
144102
|
+
}
|
|
144103
|
+
const mapped = await callArrayCallback(
|
|
144104
|
+
callback,
|
|
144105
|
+
value[index],
|
|
144106
|
+
index,
|
|
144107
|
+
value,
|
|
144108
|
+
options,
|
|
144109
|
+
stack,
|
|
144110
|
+
thisValue
|
|
144111
|
+
);
|
|
144112
|
+
if (Array.isArray(mapped)) {
|
|
144113
|
+
for (let mappedIndex = 0; mappedIndex < mapped.length; mappedIndex += 1) {
|
|
144114
|
+
options.budget.visitNode();
|
|
144115
|
+
if (!(mappedIndex in mapped)) {
|
|
144116
|
+
continue;
|
|
144117
|
+
}
|
|
144118
|
+
result.push(mapped[mappedIndex]);
|
|
144119
|
+
options.budget.allocateArrayLength(result.length);
|
|
144081
144120
|
}
|
|
144082
|
-
|
|
144083
|
-
options.budget.allocateArrayLength(result.length);
|
|
144121
|
+
continue;
|
|
144084
144122
|
}
|
|
144085
|
-
|
|
144123
|
+
result.push(mapped);
|
|
144124
|
+
options.budget.allocateArrayLength(result.length);
|
|
144086
144125
|
}
|
|
144087
|
-
result
|
|
144088
|
-
|
|
144126
|
+
return result;
|
|
144127
|
+
} finally {
|
|
144128
|
+
options.budget.setRetainedValues(result, void 0);
|
|
144089
144129
|
}
|
|
144090
|
-
return result;
|
|
144091
144130
|
}
|
|
144092
144131
|
function flattenArray(value, depth, budget) {
|
|
144093
144132
|
const result = [];
|
|
@@ -144109,47 +144148,59 @@ function appendFlattenedEntries(value, depth, result, budget) {
|
|
|
144109
144148
|
}
|
|
144110
144149
|
}
|
|
144111
144150
|
async function sortArray(value, comparator, options, stack) {
|
|
144151
|
+
const length = value.length;
|
|
144112
144152
|
const definedValues = [];
|
|
144113
144153
|
let undefinedCount = 0;
|
|
144114
|
-
|
|
144115
|
-
|
|
144116
|
-
|
|
144154
|
+
let currentEntry;
|
|
144155
|
+
options.budget.setRetainedValues(definedValues, () => [definedValues, currentEntry]);
|
|
144156
|
+
try {
|
|
144157
|
+
for (let index = 0; index < length; index += 1) {
|
|
144158
|
+
options.budget.visitNode();
|
|
144159
|
+
if (!(index in value)) {
|
|
144160
|
+
continue;
|
|
144161
|
+
}
|
|
144162
|
+
const entry = value[index];
|
|
144163
|
+
if (entry === void 0) {
|
|
144164
|
+
undefinedCount += 1;
|
|
144165
|
+
continue;
|
|
144166
|
+
}
|
|
144167
|
+
definedValues.push(entry);
|
|
144117
144168
|
}
|
|
144118
|
-
|
|
144119
|
-
|
|
144120
|
-
|
|
144121
|
-
|
|
144169
|
+
for (let index = 1; index < definedValues.length; index += 1) {
|
|
144170
|
+
currentEntry = definedValues[index];
|
|
144171
|
+
let cursor2 = index - 1;
|
|
144172
|
+
while (cursor2 >= 0 && await compareEntries(definedValues[cursor2], currentEntry, comparator, options, stack) > 0) {
|
|
144173
|
+
definedValues[cursor2 + 1] = definedValues[cursor2];
|
|
144174
|
+
cursor2 -= 1;
|
|
144175
|
+
}
|
|
144176
|
+
definedValues[cursor2 + 1] = currentEntry;
|
|
144122
144177
|
}
|
|
144123
|
-
|
|
144124
|
-
|
|
144125
|
-
|
|
144126
|
-
const entry = definedValues[index];
|
|
144127
|
-
let cursor2 = index - 1;
|
|
144128
|
-
while (cursor2 >= 0 && await compareEntries(definedValues[cursor2], entry, comparator, options, stack) > 0) {
|
|
144129
|
-
definedValues[cursor2 + 1] = definedValues[cursor2];
|
|
144130
|
-
cursor2 -= 1;
|
|
144178
|
+
currentEntry = void 0;
|
|
144179
|
+
for (let index = 0; index < definedValues.length; index += 1) {
|
|
144180
|
+
value[index] = definedValues[index];
|
|
144131
144181
|
}
|
|
144132
|
-
|
|
144133
|
-
|
|
144134
|
-
|
|
144135
|
-
|
|
144136
|
-
|
|
144137
|
-
|
|
144138
|
-
|
|
144139
|
-
}
|
|
144140
|
-
|
|
144141
|
-
delete value[index];
|
|
144182
|
+
for (let index = 0; index < undefinedCount; index += 1) {
|
|
144183
|
+
value[definedValues.length + index] = void 0;
|
|
144184
|
+
}
|
|
144185
|
+
for (let index = definedValues.length + undefinedCount; index < length; index += 1) {
|
|
144186
|
+
options.budget.visitNode();
|
|
144187
|
+
delete value[index];
|
|
144188
|
+
}
|
|
144189
|
+
} finally {
|
|
144190
|
+
options.budget.setRetainedValues(definedValues, void 0);
|
|
144142
144191
|
}
|
|
144143
144192
|
}
|
|
144144
144193
|
async function compareEntries(left, right, comparator, options, stack) {
|
|
144194
|
+
options.budget.visitNode();
|
|
144145
144195
|
const result = Number(await options.callClosure(comparator, [left, right], stack));
|
|
144146
144196
|
return Number.isNaN(result) ? 0 : result;
|
|
144147
144197
|
}
|
|
144148
144198
|
async function callArrayCallback(callback, value, index, array, options, stack, thisValue) {
|
|
144149
144199
|
return options.callClosure(callback, [value, index, array], stack, thisValue);
|
|
144150
144200
|
}
|
|
144151
|
-
function findNextDefinedIndex(value, startIndex, direction, length) {
|
|
144201
|
+
function findNextDefinedIndex(value, startIndex, direction, length, budget) {
|
|
144152
144202
|
for (let index = startIndex; direction > 0 ? index < length : index >= 0; index += direction) {
|
|
144203
|
+
budget.visitNode();
|
|
144153
144204
|
if (index in value) {
|
|
144154
144205
|
return index;
|
|
144155
144206
|
}
|
|
@@ -156554,7 +156605,7 @@ var init_package2 = __esm({
|
|
|
156554
156605
|
"package.json"() {
|
|
156555
156606
|
package_default2 = {
|
|
156556
156607
|
name: "poe-code",
|
|
156557
|
-
version: "13.0.
|
|
156608
|
+
version: "13.0.3",
|
|
156558
156609
|
description: "CLI tool to configure Poe API for developer workflows.",
|
|
156559
156610
|
license: "MIT",
|
|
156560
156611
|
type: "module",
|