@tspro/ts-utils-lib 1.15.0 → 1.17.0
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/CHANGELOG.md +16 -0
- package/dist/index.d.mts +418 -117
- package/dist/index.d.ts +418 -117
- package/dist/index.js +800 -257
- package/dist/index.mjs +798 -257
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* TsUtilsLib v1.
|
|
1
|
+
/* TsUtilsLib v1.17.0 | (c) 2023 PahkaSoft | Licensed under the MIT License */
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
4
|
var __export = (target, all) => {
|
|
@@ -1083,28 +1083,396 @@ var Stack = class {
|
|
|
1083
1083
|
}
|
|
1084
1084
|
};
|
|
1085
1085
|
|
|
1086
|
-
// src/core/
|
|
1087
|
-
var
|
|
1088
|
-
constructor(
|
|
1089
|
-
__publicField(this, "
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1086
|
+
// src/core/vec.ts
|
|
1087
|
+
var Vec = class _Vec {
|
|
1088
|
+
constructor(...coords) {
|
|
1089
|
+
__publicField(this, "coords");
|
|
1090
|
+
if (coords.length < 2) {
|
|
1091
|
+
throw new TypeError("Vec needs minumum two coords!");
|
|
1092
|
+
}
|
|
1093
|
+
this.coords = coords;
|
|
1093
1094
|
}
|
|
1094
|
-
|
|
1095
|
-
return
|
|
1095
|
+
static vec2(x, y) {
|
|
1096
|
+
return new _Vec(x, y);
|
|
1096
1097
|
}
|
|
1097
|
-
|
|
1098
|
-
return new
|
|
1098
|
+
static vec3(x, y, z) {
|
|
1099
|
+
return new _Vec(x, y, z);
|
|
1099
1100
|
}
|
|
1100
|
-
|
|
1101
|
-
|
|
1101
|
+
static zero(dim) {
|
|
1102
|
+
if (dim < 2) {
|
|
1103
|
+
throw new TypeError("Vec.zero requires dimension >= 2");
|
|
1104
|
+
}
|
|
1105
|
+
return new _Vec(...Array(dim).fill(0));
|
|
1102
1106
|
}
|
|
1103
|
-
|
|
1104
|
-
return
|
|
1107
|
+
get length() {
|
|
1108
|
+
return Math.hypot(...this.coords);
|
|
1105
1109
|
}
|
|
1106
|
-
|
|
1107
|
-
return
|
|
1110
|
+
get x() {
|
|
1111
|
+
return this.coords[0];
|
|
1112
|
+
}
|
|
1113
|
+
get y() {
|
|
1114
|
+
return this.coords[1];
|
|
1115
|
+
}
|
|
1116
|
+
get z() {
|
|
1117
|
+
if (this.coords[2] === void 0) {
|
|
1118
|
+
throw new TypeError("Vec z-coord not available!");
|
|
1119
|
+
}
|
|
1120
|
+
return this.coords[2];
|
|
1121
|
+
}
|
|
1122
|
+
add(...args) {
|
|
1123
|
+
const otherCoords = args[0] instanceof _Vec ? args[0].coords : args;
|
|
1124
|
+
if (this.coords.length !== otherCoords.length) {
|
|
1125
|
+
throw new TypeError("Coordinate length mismatch!");
|
|
1126
|
+
}
|
|
1127
|
+
return new _Vec(...this.coords.map((coord, i) => coord + otherCoords[i]));
|
|
1128
|
+
}
|
|
1129
|
+
sub(...args) {
|
|
1130
|
+
const otherCoords = args[0] instanceof _Vec ? args[0].coords : args;
|
|
1131
|
+
if (this.coords.length !== otherCoords.length) {
|
|
1132
|
+
throw new TypeError("Coordinate length mismatch!");
|
|
1133
|
+
}
|
|
1134
|
+
return new _Vec(...this.coords.map((coord, i) => coord - otherCoords[i]));
|
|
1135
|
+
}
|
|
1136
|
+
mul(scalar) {
|
|
1137
|
+
return new _Vec(...this.coords.map((coord) => coord * scalar));
|
|
1138
|
+
}
|
|
1139
|
+
div(scalar) {
|
|
1140
|
+
return new _Vec(...this.coords.map((coord) => coord / scalar));
|
|
1141
|
+
}
|
|
1142
|
+
dot(other) {
|
|
1143
|
+
if (this.coords.length !== other.coords.length) {
|
|
1144
|
+
throw new TypeError("Coordinate length mismatch!");
|
|
1145
|
+
}
|
|
1146
|
+
return this.coords.reduce((sum2, c, i) => sum2 + c * other.coords[i], 0);
|
|
1147
|
+
}
|
|
1148
|
+
distance(other) {
|
|
1149
|
+
if (this.coords.length !== other.coords.length) {
|
|
1150
|
+
throw new TypeError("Coordinate length mismatch!");
|
|
1151
|
+
}
|
|
1152
|
+
return Math.hypot(...this.coords.map((c, i) => c - other.coords[i]));
|
|
1153
|
+
}
|
|
1154
|
+
normalize() {
|
|
1155
|
+
const len = this.length;
|
|
1156
|
+
if (len === 0) {
|
|
1157
|
+
throw new TypeError("Cannot normalize zero-length vector!");
|
|
1158
|
+
}
|
|
1159
|
+
return this.div(len);
|
|
1160
|
+
}
|
|
1161
|
+
equals(other) {
|
|
1162
|
+
return this.coords.length === other.coords.length && this.coords.every((v, i) => v === other.coords[i]);
|
|
1163
|
+
}
|
|
1164
|
+
clone() {
|
|
1165
|
+
return new _Vec(...this.coords);
|
|
1166
|
+
}
|
|
1167
|
+
toObject() {
|
|
1168
|
+
return { x: this.x, y: this.y, z: this.z };
|
|
1169
|
+
}
|
|
1170
|
+
[Symbol.iterator]() {
|
|
1171
|
+
return this.coords[Symbol.iterator]();
|
|
1172
|
+
}
|
|
1173
|
+
toString() {
|
|
1174
|
+
return `Vec(${this.coords.join(", ")})`;
|
|
1175
|
+
}
|
|
1176
|
+
};
|
|
1177
|
+
|
|
1178
|
+
// src/core/div-rect.ts
|
|
1179
|
+
var DivRect = class _DivRect {
|
|
1180
|
+
constructor(...args) {
|
|
1181
|
+
__publicField(this, "left");
|
|
1182
|
+
__publicField(this, "centerX");
|
|
1183
|
+
__publicField(this, "right");
|
|
1184
|
+
__publicField(this, "top");
|
|
1185
|
+
__publicField(this, "centerY");
|
|
1186
|
+
__publicField(this, "bottom");
|
|
1187
|
+
if (args.length === 6) {
|
|
1188
|
+
this.left = args[0];
|
|
1189
|
+
this.centerX = args[1];
|
|
1190
|
+
this.right = args[2];
|
|
1191
|
+
this.top = args[3];
|
|
1192
|
+
this.centerY = args[4];
|
|
1193
|
+
this.bottom = args[5];
|
|
1194
|
+
} else if (args.length === 4) {
|
|
1195
|
+
this.left = args[0];
|
|
1196
|
+
this.right = args[1];
|
|
1197
|
+
this.centerX = (this.left + this.right) / 2;
|
|
1198
|
+
this.top = args[2];
|
|
1199
|
+
this.bottom = args[3];
|
|
1200
|
+
this.centerY = (this.top + this.bottom) / 2;
|
|
1201
|
+
} else if (args.length === 0) {
|
|
1202
|
+
this.left = this.centerX = this.right = 0;
|
|
1203
|
+
this.top = this.centerY = this.bottom = 0;
|
|
1204
|
+
} else {
|
|
1205
|
+
throw new TypeError(`Invalid DivRect args: ${args}`);
|
|
1206
|
+
}
|
|
1207
|
+
}
|
|
1208
|
+
/**
|
|
1209
|
+
* Create rect from basic left, top, width and height arguments.
|
|
1210
|
+
*
|
|
1211
|
+
* @param left - Left coordinate.
|
|
1212
|
+
* @param top - Top coordinate.
|
|
1213
|
+
* @param width - Width.
|
|
1214
|
+
* @param height - Height.
|
|
1215
|
+
* @returns - DivRect.
|
|
1216
|
+
*/
|
|
1217
|
+
static create(left, top, width, height) {
|
|
1218
|
+
return new _DivRect(left, left + width, top, top + height);
|
|
1219
|
+
}
|
|
1220
|
+
/**
|
|
1221
|
+
* Create rect from centerX, centerY, width, height arguments.
|
|
1222
|
+
*
|
|
1223
|
+
* @param centerX - Center x-coordinate.
|
|
1224
|
+
* @param centerY - Center y-coordinate.
|
|
1225
|
+
* @param width - Width.
|
|
1226
|
+
* @param height - Height.
|
|
1227
|
+
* @returns - DivRect.
|
|
1228
|
+
*/
|
|
1229
|
+
static createCentered(centerX, centerY, width, height) {
|
|
1230
|
+
return new _DivRect(
|
|
1231
|
+
centerX - width / 2,
|
|
1232
|
+
centerX,
|
|
1233
|
+
centerX + width / 2,
|
|
1234
|
+
centerY - height / 2,
|
|
1235
|
+
centerY,
|
|
1236
|
+
centerY + height / 2
|
|
1237
|
+
);
|
|
1238
|
+
}
|
|
1239
|
+
/**
|
|
1240
|
+
* Create rect from sections.
|
|
1241
|
+
*
|
|
1242
|
+
* @param leftw - Left section width.
|
|
1243
|
+
* @param rightw - Right section width.
|
|
1244
|
+
* @param toph - Top section height.
|
|
1245
|
+
* @param bottomh - Bottomsection height.
|
|
1246
|
+
* @returns - DivRect.
|
|
1247
|
+
*/
|
|
1248
|
+
static createSections(leftw, rightw, toph, bottomh) {
|
|
1249
|
+
return new _DivRect(-leftw, 0, rightw, -toph, 0, bottomh);
|
|
1250
|
+
}
|
|
1251
|
+
/**
|
|
1252
|
+
* Width getter.
|
|
1253
|
+
*/
|
|
1254
|
+
get width() {
|
|
1255
|
+
return this.right - this.left;
|
|
1256
|
+
}
|
|
1257
|
+
/**
|
|
1258
|
+
* Height getter.
|
|
1259
|
+
*/
|
|
1260
|
+
get height() {
|
|
1261
|
+
return this.bottom - this.top;
|
|
1262
|
+
}
|
|
1263
|
+
/**
|
|
1264
|
+
* Left section width getter.
|
|
1265
|
+
*/
|
|
1266
|
+
get leftw() {
|
|
1267
|
+
return this.centerX - this.left;
|
|
1268
|
+
}
|
|
1269
|
+
/**
|
|
1270
|
+
* Right section width getter.
|
|
1271
|
+
*/
|
|
1272
|
+
get rightw() {
|
|
1273
|
+
return this.right - this.centerX;
|
|
1274
|
+
}
|
|
1275
|
+
/**
|
|
1276
|
+
* Top section height getter.
|
|
1277
|
+
*/
|
|
1278
|
+
get toph() {
|
|
1279
|
+
return this.centerY - this.top;
|
|
1280
|
+
}
|
|
1281
|
+
/**
|
|
1282
|
+
* Bottom section height getter.
|
|
1283
|
+
*/
|
|
1284
|
+
get bottomh() {
|
|
1285
|
+
return this.bottom - this.centerY;
|
|
1286
|
+
}
|
|
1287
|
+
/**
|
|
1288
|
+
* Does this Rect contain given (x, y)-point?
|
|
1289
|
+
*
|
|
1290
|
+
* @param x - X-coordinate.
|
|
1291
|
+
* @param y - Y-coordinate.
|
|
1292
|
+
* @returns - True/false.
|
|
1293
|
+
*/
|
|
1294
|
+
contains(x, y) {
|
|
1295
|
+
return x >= this.left && x <= this.right && y >= this.top && y <= this.bottom;
|
|
1296
|
+
}
|
|
1297
|
+
/**
|
|
1298
|
+
* Do a and b rects overlap?
|
|
1299
|
+
*
|
|
1300
|
+
* @param a - DivRect a.
|
|
1301
|
+
* @param b - DivRect b.
|
|
1302
|
+
* @returns - True/false.
|
|
1303
|
+
*/
|
|
1304
|
+
static overlap(a, b) {
|
|
1305
|
+
return a.right > b.left && a.left < b.right && a.bottom > b.top && a.top < b.bottom;
|
|
1306
|
+
}
|
|
1307
|
+
/**
|
|
1308
|
+
* Do horizontal measures of a and b rects overlap?
|
|
1309
|
+
*
|
|
1310
|
+
* @param a - DivRect a.
|
|
1311
|
+
* @param b - DivRect b.
|
|
1312
|
+
* @returns - True/false.
|
|
1313
|
+
*/
|
|
1314
|
+
static overlapX(a, b) {
|
|
1315
|
+
return a.right > b.left && a.left < b.right;
|
|
1316
|
+
}
|
|
1317
|
+
/**
|
|
1318
|
+
* Check if given rects are equal.
|
|
1319
|
+
* @param a - DivRect a.
|
|
1320
|
+
* @param b - DivRect b.
|
|
1321
|
+
* @returns - True/false.
|
|
1322
|
+
*/
|
|
1323
|
+
static equals(a, b) {
|
|
1324
|
+
if (a == null && b == null) {
|
|
1325
|
+
return true;
|
|
1326
|
+
} else if (a == null || b == null) {
|
|
1327
|
+
return false;
|
|
1328
|
+
} else {
|
|
1329
|
+
return a === b || a.left === b.left && a.centerX === b.centerX && a.right === b.right && a.top === b.top && a.centerY === b.centerY && a.bottom === b.bottom;
|
|
1330
|
+
}
|
|
1331
|
+
}
|
|
1332
|
+
/**
|
|
1333
|
+
* Check if this rect equals with another rect.
|
|
1334
|
+
* @param other - The other rect.
|
|
1335
|
+
* @returns - True/false.
|
|
1336
|
+
*/
|
|
1337
|
+
equals(other) {
|
|
1338
|
+
return _DivRect.equals(this, other);
|
|
1339
|
+
}
|
|
1340
|
+
/**
|
|
1341
|
+
* Check if edges of given rects are equal, ignoring centerX and centerY.
|
|
1342
|
+
*
|
|
1343
|
+
* @param a - DivRect a.
|
|
1344
|
+
* @param b - DivRect b.
|
|
1345
|
+
* @returns - True/false.
|
|
1346
|
+
*/
|
|
1347
|
+
static equalsEdges(a, b) {
|
|
1348
|
+
if (a == null && b == null) {
|
|
1349
|
+
return true;
|
|
1350
|
+
} else if (a == null || b == null) {
|
|
1351
|
+
return false;
|
|
1352
|
+
} else {
|
|
1353
|
+
return a === b || a.left === b.left && a.right === b.right && a.top === b.top && a.bottom === b.bottom;
|
|
1354
|
+
}
|
|
1355
|
+
}
|
|
1356
|
+
/**
|
|
1357
|
+
* Check if edges of this Rect equals with given Rect, ignoring centerX and centerY.
|
|
1358
|
+
*
|
|
1359
|
+
* @param other - The other DivRect.
|
|
1360
|
+
* @returns - True/false.
|
|
1361
|
+
*/
|
|
1362
|
+
equalsEdges(other) {
|
|
1363
|
+
return _DivRect.equalsEdges(this, other);
|
|
1364
|
+
}
|
|
1365
|
+
/**
|
|
1366
|
+
* Created duplicate of this Rect.
|
|
1367
|
+
*
|
|
1368
|
+
* @returns - Duplicate.
|
|
1369
|
+
*/
|
|
1370
|
+
copy() {
|
|
1371
|
+
return new _DivRect(this.left, this.centerX, this.right, this.top, this.centerY, this.bottom);
|
|
1372
|
+
}
|
|
1373
|
+
/**
|
|
1374
|
+
* Move this rect by (dx, dy). Modifies this Rect.
|
|
1375
|
+
*
|
|
1376
|
+
* @param dx - Offset amount in x-direction.
|
|
1377
|
+
* @param dy - Offset amount in y-direction.
|
|
1378
|
+
* @returns - This DivRect instance.
|
|
1379
|
+
*/
|
|
1380
|
+
offsetInPlace(dx, dy) {
|
|
1381
|
+
this.left += dx;
|
|
1382
|
+
this.centerX += dx;
|
|
1383
|
+
this.right += dx;
|
|
1384
|
+
this.top += dy;
|
|
1385
|
+
this.centerY += dy;
|
|
1386
|
+
this.bottom += dy;
|
|
1387
|
+
return this;
|
|
1388
|
+
}
|
|
1389
|
+
/**
|
|
1390
|
+
* Move this rect by (dx, dy). Immutable, returns modified copy.
|
|
1391
|
+
*
|
|
1392
|
+
* @param dx - Offset amount in x-direction.
|
|
1393
|
+
* @param dy - Offset amount in y-direction.
|
|
1394
|
+
* @returns - DivRect copy with applied offset.
|
|
1395
|
+
*/
|
|
1396
|
+
offsetCopy(dx, dy) {
|
|
1397
|
+
return this.copy().offsetInPlace(dx, dy);
|
|
1398
|
+
}
|
|
1399
|
+
/**
|
|
1400
|
+
* Expand this Rect by given Rect. Modifies this Rect.
|
|
1401
|
+
*
|
|
1402
|
+
* @param rect - DivRect to expand this instance with.
|
|
1403
|
+
* @returns - This DivRect instance.
|
|
1404
|
+
*/
|
|
1405
|
+
expandInPlace(rect) {
|
|
1406
|
+
this.left = Math.min(this.left, rect.left);
|
|
1407
|
+
this.right = Math.max(this.right, rect.right);
|
|
1408
|
+
this.top = Math.min(this.top, rect.top);
|
|
1409
|
+
this.bottom = Math.max(this.bottom, rect.bottom);
|
|
1410
|
+
return this;
|
|
1411
|
+
}
|
|
1412
|
+
/**
|
|
1413
|
+
* Expand this Rect by given Rect. Immutable, returns modified copy.
|
|
1414
|
+
*
|
|
1415
|
+
* @param rect - DivRect to expand this instance with.
|
|
1416
|
+
* @returns - Expanded copy of this DivRect.
|
|
1417
|
+
*/
|
|
1418
|
+
expandCopy(rect) {
|
|
1419
|
+
return this.copy().expandInPlace(rect);
|
|
1420
|
+
}
|
|
1421
|
+
/**
|
|
1422
|
+
* Clip this Rect by given Rect. Mmodifies this Rect.
|
|
1423
|
+
*
|
|
1424
|
+
* @param clipRect - DivRect to clip this instance with.
|
|
1425
|
+
* @returns - This DivRect instance.
|
|
1426
|
+
*/
|
|
1427
|
+
clipInPlace(clipRect) {
|
|
1428
|
+
this.left = Math.max(this.left, clipRect.left);
|
|
1429
|
+
this.right = Math.min(this.right, clipRect.right);
|
|
1430
|
+
this.centerX = clamp(this.centerX, this.left, this.right);
|
|
1431
|
+
this.top = Math.max(this.top, clipRect.top);
|
|
1432
|
+
this.bottom = Math.min(this.bottom, clipRect.bottom);
|
|
1433
|
+
this.centerY = clamp(this.centerY, this.top, this.bottom);
|
|
1434
|
+
return this;
|
|
1435
|
+
}
|
|
1436
|
+
/**
|
|
1437
|
+
* Clip this Rect by given Rect. Immutable, return modified copy.
|
|
1438
|
+
*
|
|
1439
|
+
* @param clipRect - DivRecto to clip this instance with.
|
|
1440
|
+
* @returns - Clipped DivRect copy.
|
|
1441
|
+
*/
|
|
1442
|
+
clipCopy(clipRect) {
|
|
1443
|
+
return this.copy().clipInPlace(clipRect);
|
|
1444
|
+
}
|
|
1445
|
+
/**
|
|
1446
|
+
* Scale Rect. Anchor pos is (centerX, centerY). Modifies this Rect.
|
|
1447
|
+
*
|
|
1448
|
+
* @param scaleX - Scale x-amount.
|
|
1449
|
+
* @param scaleY - Scale y-amount. If undefined then scale x-amount is used.
|
|
1450
|
+
* @returns This DivRect instance.
|
|
1451
|
+
*/
|
|
1452
|
+
scaleInPlace(scaleX, scaleY) {
|
|
1453
|
+
scaleY = scaleY ?? scaleX;
|
|
1454
|
+
this.left = this.centerX - this.leftw * scaleX;
|
|
1455
|
+
this.right = this.centerX + this.rightw * scaleX;
|
|
1456
|
+
this.top = this.centerY - this.toph * scaleY;
|
|
1457
|
+
this.bottom = this.centerY + this.bottomh * scaleY;
|
|
1458
|
+
return this;
|
|
1459
|
+
}
|
|
1460
|
+
/**
|
|
1461
|
+
* Scale Rect. Anchor pos is (centerX, centerY). Immutable, returns modified copy.
|
|
1462
|
+
*
|
|
1463
|
+
* @param scaleX - Scale x-amount.
|
|
1464
|
+
* @param scaleY - Scale y-amount. If undefined then scale x-amount is used.
|
|
1465
|
+
* @returns Scaled copy of this DivRect.
|
|
1466
|
+
*/
|
|
1467
|
+
scaleCopy(scaleX, scaleY) {
|
|
1468
|
+
return this.copy().scaleInPlace(scaleX, scaleY);
|
|
1469
|
+
}
|
|
1470
|
+
/**
|
|
1471
|
+
* Get this DivRect instance.
|
|
1472
|
+
* @returns - This DivRect instance.
|
|
1473
|
+
*/
|
|
1474
|
+
getRect() {
|
|
1475
|
+
return this;
|
|
1108
1476
|
}
|
|
1109
1477
|
};
|
|
1110
1478
|
|
|
@@ -1205,107 +1573,54 @@ var LRUCache = class {
|
|
|
1205
1573
|
}
|
|
1206
1574
|
};
|
|
1207
1575
|
|
|
1208
|
-
// src/core/small-int-cache.ts
|
|
1209
|
-
var SmallIntCache = class {
|
|
1210
|
-
// for keys < 0
|
|
1211
|
-
constructor() {
|
|
1212
|
-
__publicField(this, "pos");
|
|
1213
|
-
// for keys >= 0
|
|
1214
|
-
__publicField(this, "neg");
|
|
1215
|
-
this.pos = [];
|
|
1216
|
-
this.neg = [];
|
|
1217
|
-
}
|
|
1218
|
-
set(key, value) {
|
|
1219
|
-
if (!isInteger(key)) {
|
|
1220
|
-
throw new Error("Key must be an integer");
|
|
1221
|
-
} else if (key >= 0) {
|
|
1222
|
-
this.pos[key] = value;
|
|
1223
|
-
} else {
|
|
1224
|
-
this.neg[-key - 1] = value;
|
|
1225
|
-
}
|
|
1226
|
-
}
|
|
1227
|
-
get(key) {
|
|
1228
|
-
if (!isInteger(key)) {
|
|
1229
|
-
throw new Error("Key must be an integer");
|
|
1230
|
-
} else if (key >= 0) {
|
|
1231
|
-
return this.pos[key];
|
|
1232
|
-
} else {
|
|
1233
|
-
return this.neg[-key - 1];
|
|
1234
|
-
}
|
|
1235
|
-
}
|
|
1236
|
-
has(key) {
|
|
1237
|
-
if (!isInteger(key)) {
|
|
1238
|
-
return false;
|
|
1239
|
-
} else if (key >= 0) {
|
|
1240
|
-
return key in this.pos;
|
|
1241
|
-
} else {
|
|
1242
|
-
return -key - 1 in this.neg;
|
|
1243
|
-
}
|
|
1244
|
-
}
|
|
1245
|
-
delete(key) {
|
|
1246
|
-
if (!isInteger(key)) {
|
|
1247
|
-
return;
|
|
1248
|
-
} else if (key >= 0) {
|
|
1249
|
-
delete this.pos[key];
|
|
1250
|
-
} else {
|
|
1251
|
-
delete this.neg[-key - 1];
|
|
1252
|
-
}
|
|
1253
|
-
}
|
|
1254
|
-
clear() {
|
|
1255
|
-
this.pos = [];
|
|
1256
|
-
this.neg = [];
|
|
1257
|
-
}
|
|
1258
|
-
};
|
|
1259
|
-
|
|
1260
1576
|
// src/core/index-array.ts
|
|
1261
1577
|
var IndexArray = class _IndexArray {
|
|
1262
1578
|
constructor(entries) {
|
|
1263
|
-
|
|
1264
|
-
__publicField(this, "posEl");
|
|
1579
|
+
__publicField(this, "posVal");
|
|
1265
1580
|
__publicField(this, "hasPos");
|
|
1266
|
-
//
|
|
1267
|
-
__publicField(this, "
|
|
1581
|
+
// Number of values
|
|
1582
|
+
__publicField(this, "valCount");
|
|
1268
1583
|
if (entries instanceof _IndexArray) {
|
|
1269
|
-
this.
|
|
1584
|
+
this.posVal = entries.posVal.slice();
|
|
1270
1585
|
this.hasPos = entries.hasPos.slice();
|
|
1271
|
-
this.
|
|
1586
|
+
this.valCount = entries.valCount;
|
|
1272
1587
|
} else {
|
|
1273
|
-
this.
|
|
1588
|
+
this.posVal = [];
|
|
1274
1589
|
this.hasPos = [];
|
|
1275
|
-
this.
|
|
1590
|
+
this.valCount = 0;
|
|
1276
1591
|
if (entries) {
|
|
1277
|
-
for (const [id,
|
|
1278
|
-
this.set(id,
|
|
1592
|
+
for (const [id, value] of entries) {
|
|
1593
|
+
this.set(id, value);
|
|
1279
1594
|
}
|
|
1280
1595
|
}
|
|
1281
1596
|
}
|
|
1282
1597
|
}
|
|
1283
|
-
static toNegIndex(id) {
|
|
1284
|
-
return -id - 1;
|
|
1285
|
-
}
|
|
1286
1598
|
static validateIndex(id) {
|
|
1287
1599
|
if (!isIntegerGte(id, 0)) throw new Error(`Invalid index ${id} - must be an integer >= 0!`);
|
|
1288
1600
|
return id;
|
|
1289
1601
|
}
|
|
1290
|
-
get size() {
|
|
1291
|
-
return this.elCount;
|
|
1292
|
-
}
|
|
1293
1602
|
get posLen() {
|
|
1294
1603
|
return this.hasPos.length;
|
|
1295
1604
|
}
|
|
1605
|
+
get size() {
|
|
1606
|
+
return this.valCount;
|
|
1607
|
+
}
|
|
1608
|
+
isEmpty() {
|
|
1609
|
+
return this.size === 0;
|
|
1610
|
+
}
|
|
1296
1611
|
has(id) {
|
|
1297
1612
|
_IndexArray.validateIndex(id);
|
|
1298
1613
|
return this.hasPos[id] === true;
|
|
1299
1614
|
}
|
|
1300
|
-
set(id,
|
|
1615
|
+
set(id, value) {
|
|
1301
1616
|
_IndexArray.validateIndex(id);
|
|
1302
|
-
if (this.hasPos[id] !== true) this.
|
|
1303
|
-
this.
|
|
1617
|
+
if (this.hasPos[id] !== true) this.valCount++;
|
|
1618
|
+
this.posVal[id] = value;
|
|
1304
1619
|
this.hasPos[id] = true;
|
|
1305
1620
|
}
|
|
1306
1621
|
get(id) {
|
|
1307
1622
|
_IndexArray.validateIndex(id);
|
|
1308
|
-
return this.hasPos[id] ? this.
|
|
1623
|
+
return this.hasPos[id] ? this.posVal[id] : void 0;
|
|
1309
1624
|
}
|
|
1310
1625
|
getOrDefault(id, defaultValue) {
|
|
1311
1626
|
return this.get(id) ?? defaultValue;
|
|
@@ -1321,19 +1636,19 @@ var IndexArray = class _IndexArray {
|
|
|
1321
1636
|
delete(id) {
|
|
1322
1637
|
_IndexArray.validateIndex(id);
|
|
1323
1638
|
if (!this.hasPos[id]) return false;
|
|
1324
|
-
this.
|
|
1639
|
+
this.posVal[id] = void 0;
|
|
1325
1640
|
this.hasPos[id] = false;
|
|
1326
|
-
this.
|
|
1641
|
+
this.valCount--;
|
|
1327
1642
|
return true;
|
|
1328
1643
|
}
|
|
1329
1644
|
clear() {
|
|
1330
|
-
this.
|
|
1645
|
+
this.posVal = [];
|
|
1331
1646
|
this.hasPos = [];
|
|
1332
|
-
this.
|
|
1647
|
+
this.valCount = 0;
|
|
1333
1648
|
}
|
|
1334
1649
|
forEach(callbackfn, thisArg) {
|
|
1335
|
-
for (const [id,
|
|
1336
|
-
callbackfn.call(thisArg,
|
|
1650
|
+
for (const [id, value] of this.entries()) {
|
|
1651
|
+
callbackfn.call(thisArg, value, id, this);
|
|
1337
1652
|
}
|
|
1338
1653
|
}
|
|
1339
1654
|
*indices() {
|
|
@@ -1341,25 +1656,40 @@ var IndexArray = class _IndexArray {
|
|
|
1341
1656
|
if (this.hasPos[id]) yield id;
|
|
1342
1657
|
}
|
|
1343
1658
|
}
|
|
1344
|
-
indicesArray() {
|
|
1345
|
-
return [...this.indices()];
|
|
1346
|
-
}
|
|
1347
1659
|
*values() {
|
|
1348
1660
|
for (let id = 0; id < this.posLen; id++) {
|
|
1349
|
-
if (this.hasPos[id]) yield this.
|
|
1661
|
+
if (this.hasPos[id]) yield this.posVal[id];
|
|
1350
1662
|
}
|
|
1351
1663
|
}
|
|
1352
|
-
valuesArray() {
|
|
1353
|
-
return [...this.values()];
|
|
1354
|
-
}
|
|
1355
1664
|
*entries() {
|
|
1356
1665
|
for (let id = 0; id < this.posLen; id++) {
|
|
1357
|
-
if (this.hasPos[id]) yield [id, this.
|
|
1666
|
+
if (this.hasPos[id]) yield [id, this.posVal[id]];
|
|
1358
1667
|
}
|
|
1359
1668
|
}
|
|
1669
|
+
indicesArray() {
|
|
1670
|
+
return [...this.indices()];
|
|
1671
|
+
}
|
|
1672
|
+
valuesArray() {
|
|
1673
|
+
return [...this.values()];
|
|
1674
|
+
}
|
|
1360
1675
|
entriesArray() {
|
|
1361
1676
|
return [...this.entries()];
|
|
1362
1677
|
}
|
|
1678
|
+
*kvKeys() {
|
|
1679
|
+
for (const id of this.indices()) {
|
|
1680
|
+
yield [id];
|
|
1681
|
+
}
|
|
1682
|
+
}
|
|
1683
|
+
*kvValues() {
|
|
1684
|
+
for (const value of this.values()) {
|
|
1685
|
+
yield value;
|
|
1686
|
+
}
|
|
1687
|
+
}
|
|
1688
|
+
*kvEntries() {
|
|
1689
|
+
for (const [id, value] of this.entries()) {
|
|
1690
|
+
yield [[id], value];
|
|
1691
|
+
}
|
|
1692
|
+
}
|
|
1363
1693
|
*[Symbol.iterator]() {
|
|
1364
1694
|
yield* this.entries();
|
|
1365
1695
|
}
|
|
@@ -1377,21 +1707,21 @@ var IndexArray = class _IndexArray {
|
|
|
1377
1707
|
return this;
|
|
1378
1708
|
}
|
|
1379
1709
|
some(fn) {
|
|
1380
|
-
for (const [id,
|
|
1381
|
-
if (fn(
|
|
1710
|
+
for (const [id, value] of this.entries()) {
|
|
1711
|
+
if (fn(value, id)) return true;
|
|
1382
1712
|
}
|
|
1383
1713
|
return false;
|
|
1384
1714
|
}
|
|
1385
1715
|
every(fn) {
|
|
1386
|
-
for (const [id,
|
|
1387
|
-
if (!fn(
|
|
1716
|
+
for (const [id, value] of this.entries()) {
|
|
1717
|
+
if (!fn(value, id)) return false;
|
|
1388
1718
|
}
|
|
1389
1719
|
return true;
|
|
1390
1720
|
}
|
|
1391
|
-
filter(
|
|
1392
|
-
|
|
1393
|
-
for (const [id,
|
|
1394
|
-
if (
|
|
1721
|
+
filter(predicate) {
|
|
1722
|
+
const result = new this.constructor();
|
|
1723
|
+
for (const [id, value] of this.entries()) {
|
|
1724
|
+
if (predicate(value, id, this)) result.set(id, value);
|
|
1395
1725
|
}
|
|
1396
1726
|
return result;
|
|
1397
1727
|
}
|
|
@@ -1414,22 +1744,22 @@ var IndexArray = class _IndexArray {
|
|
|
1414
1744
|
start = first;
|
|
1415
1745
|
}
|
|
1416
1746
|
for (let current = start; !current.done; current = iterator.next()) {
|
|
1417
|
-
const [id,
|
|
1418
|
-
acc = fn(acc,
|
|
1747
|
+
const [id, value] = current.value;
|
|
1748
|
+
acc = fn(acc, value, id);
|
|
1419
1749
|
}
|
|
1420
1750
|
return acc;
|
|
1421
1751
|
}
|
|
1422
1752
|
mapToArray(fn) {
|
|
1423
1753
|
let result = [];
|
|
1424
|
-
for (const [id,
|
|
1425
|
-
result.push(fn(
|
|
1754
|
+
for (const [id, value] of this.entries()) {
|
|
1755
|
+
result.push(fn(value, id));
|
|
1426
1756
|
}
|
|
1427
1757
|
return result;
|
|
1428
1758
|
}
|
|
1429
1759
|
map(fn) {
|
|
1430
1760
|
let result = new _IndexArray();
|
|
1431
|
-
for (const [id,
|
|
1432
|
-
result.set(id, fn(
|
|
1761
|
+
for (const [id, value] of this.entries()) {
|
|
1762
|
+
result.set(id, fn(value, id));
|
|
1433
1763
|
}
|
|
1434
1764
|
return result;
|
|
1435
1765
|
}
|
|
@@ -1441,13 +1771,13 @@ var IndexArray = class _IndexArray {
|
|
|
1441
1771
|
const hasA = this.hasPos[i];
|
|
1442
1772
|
const hasB = other.hasPos[i];
|
|
1443
1773
|
if (hasA !== hasB) return false;
|
|
1444
|
-
if (hasA && !eq(this.
|
|
1774
|
+
if (hasA && !eq(this.posVal[i], other.posVal[i])) return false;
|
|
1445
1775
|
}
|
|
1446
1776
|
return true;
|
|
1447
1777
|
}
|
|
1448
1778
|
toString() {
|
|
1449
1779
|
if (this.size === 0) return `IndexArray[ ]`;
|
|
1450
|
-
const entries = this.entriesArray().map(([id,
|
|
1780
|
+
const entries = this.entriesArray().map(([id, value]) => `${id}: ${value}`).join(", ");
|
|
1451
1781
|
return `IndexArray[ ${entries} ]`;
|
|
1452
1782
|
}
|
|
1453
1783
|
};
|
|
@@ -1455,29 +1785,29 @@ var IndexArray = class _IndexArray {
|
|
|
1455
1785
|
// src/core/signed-index-array.ts
|
|
1456
1786
|
var SignedIndexArray = class _SignedIndexArray {
|
|
1457
1787
|
constructor(entries) {
|
|
1458
|
-
//
|
|
1459
|
-
__publicField(this, "
|
|
1788
|
+
// For indexes >= 0
|
|
1789
|
+
__publicField(this, "posVal");
|
|
1460
1790
|
__publicField(this, "hasPos");
|
|
1461
|
-
//
|
|
1462
|
-
__publicField(this, "
|
|
1791
|
+
// For indexes < 0
|
|
1792
|
+
__publicField(this, "negVal");
|
|
1463
1793
|
__publicField(this, "hasNeg");
|
|
1464
|
-
//
|
|
1465
|
-
__publicField(this, "
|
|
1794
|
+
// Number of values
|
|
1795
|
+
__publicField(this, "valCount");
|
|
1466
1796
|
if (entries instanceof _SignedIndexArray) {
|
|
1467
|
-
this.
|
|
1797
|
+
this.negVal = entries.negVal.slice();
|
|
1468
1798
|
this.hasNeg = entries.hasNeg.slice();
|
|
1469
|
-
this.
|
|
1799
|
+
this.posVal = entries.posVal.slice();
|
|
1470
1800
|
this.hasPos = entries.hasPos.slice();
|
|
1471
|
-
this.
|
|
1801
|
+
this.valCount = entries.valCount;
|
|
1472
1802
|
} else {
|
|
1473
|
-
this.
|
|
1803
|
+
this.negVal = [];
|
|
1474
1804
|
this.hasNeg = [];
|
|
1475
|
-
this.
|
|
1805
|
+
this.posVal = [];
|
|
1476
1806
|
this.hasPos = [];
|
|
1477
|
-
this.
|
|
1807
|
+
this.valCount = 0;
|
|
1478
1808
|
if (entries) {
|
|
1479
|
-
for (const [id,
|
|
1480
|
-
this.set(id,
|
|
1809
|
+
for (const [id, value] of entries) {
|
|
1810
|
+
this.set(id, value);
|
|
1481
1811
|
}
|
|
1482
1812
|
}
|
|
1483
1813
|
}
|
|
@@ -1490,7 +1820,10 @@ var SignedIndexArray = class _SignedIndexArray {
|
|
|
1490
1820
|
return id;
|
|
1491
1821
|
}
|
|
1492
1822
|
get size() {
|
|
1493
|
-
return this.
|
|
1823
|
+
return this.valCount;
|
|
1824
|
+
}
|
|
1825
|
+
isEmpty() {
|
|
1826
|
+
return this.size === 0;
|
|
1494
1827
|
}
|
|
1495
1828
|
get posLen() {
|
|
1496
1829
|
return this.hasPos.length;
|
|
@@ -1506,26 +1839,26 @@ var SignedIndexArray = class _SignedIndexArray {
|
|
|
1506
1839
|
return this.hasNeg[_SignedIndexArray.toNegIndex(id)] === true;
|
|
1507
1840
|
}
|
|
1508
1841
|
}
|
|
1509
|
-
set(id,
|
|
1842
|
+
set(id, value) {
|
|
1510
1843
|
_SignedIndexArray.validateIndex(id);
|
|
1511
1844
|
if (id >= 0) {
|
|
1512
|
-
if (this.hasPos[id] !== true) this.
|
|
1513
|
-
this.
|
|
1845
|
+
if (this.hasPos[id] !== true) this.valCount++;
|
|
1846
|
+
this.posVal[id] = value;
|
|
1514
1847
|
this.hasPos[id] = true;
|
|
1515
1848
|
} else {
|
|
1516
1849
|
let negId = _SignedIndexArray.toNegIndex(id);
|
|
1517
|
-
if (this.hasNeg[negId] !== true) this.
|
|
1518
|
-
this.
|
|
1850
|
+
if (this.hasNeg[negId] !== true) this.valCount++;
|
|
1851
|
+
this.negVal[negId] = value;
|
|
1519
1852
|
this.hasNeg[negId] = true;
|
|
1520
1853
|
}
|
|
1521
1854
|
}
|
|
1522
1855
|
get(id) {
|
|
1523
1856
|
_SignedIndexArray.validateIndex(id);
|
|
1524
1857
|
if (id >= 0) {
|
|
1525
|
-
return this.hasPos[id] ? this.
|
|
1858
|
+
return this.hasPos[id] ? this.posVal[id] : void 0;
|
|
1526
1859
|
} else {
|
|
1527
1860
|
let negId = _SignedIndexArray.toNegIndex(id);
|
|
1528
|
-
return this.hasNeg[negId] ? this.
|
|
1861
|
+
return this.hasNeg[negId] ? this.negVal[negId] : void 0;
|
|
1529
1862
|
}
|
|
1530
1863
|
}
|
|
1531
1864
|
getOrDefault(id, defaultValue) {
|
|
@@ -1542,25 +1875,25 @@ var SignedIndexArray = class _SignedIndexArray {
|
|
|
1542
1875
|
delete(id) {
|
|
1543
1876
|
_SignedIndexArray.validateIndex(id);
|
|
1544
1877
|
const isPos = id >= 0;
|
|
1545
|
-
const arr = isPos ? this.
|
|
1878
|
+
const arr = isPos ? this.posVal : this.negVal;
|
|
1546
1879
|
const has = isPos ? this.hasPos : this.hasNeg;
|
|
1547
1880
|
const idx = isPos ? id : _SignedIndexArray.toNegIndex(id);
|
|
1548
1881
|
if (!has[idx]) return false;
|
|
1549
1882
|
arr[idx] = void 0;
|
|
1550
1883
|
has[idx] = false;
|
|
1551
|
-
this.
|
|
1884
|
+
this.valCount--;
|
|
1552
1885
|
return true;
|
|
1553
1886
|
}
|
|
1554
1887
|
clear() {
|
|
1555
|
-
this.
|
|
1888
|
+
this.negVal = [];
|
|
1556
1889
|
this.hasNeg = [];
|
|
1557
|
-
this.
|
|
1890
|
+
this.posVal = [];
|
|
1558
1891
|
this.hasPos = [];
|
|
1559
|
-
this.
|
|
1892
|
+
this.valCount = 0;
|
|
1560
1893
|
}
|
|
1561
1894
|
forEach(callbackfn, thisArg) {
|
|
1562
|
-
for (const [id,
|
|
1563
|
-
callbackfn.call(thisArg,
|
|
1895
|
+
for (const [id, value] of this.entries()) {
|
|
1896
|
+
callbackfn.call(thisArg, value, id, this);
|
|
1564
1897
|
}
|
|
1565
1898
|
}
|
|
1566
1899
|
*indices() {
|
|
@@ -1571,31 +1904,46 @@ var SignedIndexArray = class _SignedIndexArray {
|
|
|
1571
1904
|
if (this.hasPos[id]) yield id;
|
|
1572
1905
|
}
|
|
1573
1906
|
}
|
|
1574
|
-
indicesArray() {
|
|
1575
|
-
return [...this.indices()];
|
|
1576
|
-
}
|
|
1577
1907
|
*values() {
|
|
1578
1908
|
for (let id = this.negLen - 1; id >= 0; id--) {
|
|
1579
|
-
if (this.hasNeg[id]) yield this.
|
|
1909
|
+
if (this.hasNeg[id]) yield this.negVal[id];
|
|
1580
1910
|
}
|
|
1581
1911
|
for (let id = 0; id < this.posLen; id++) {
|
|
1582
|
-
if (this.hasPos[id]) yield this.
|
|
1912
|
+
if (this.hasPos[id]) yield this.posVal[id];
|
|
1583
1913
|
}
|
|
1584
1914
|
}
|
|
1585
|
-
valuesArray() {
|
|
1586
|
-
return [...this.values()];
|
|
1587
|
-
}
|
|
1588
1915
|
*entries() {
|
|
1589
1916
|
for (let id = this.negLen - 1; id >= 0; id--) {
|
|
1590
|
-
if (this.hasNeg[id]) yield [_SignedIndexArray.toNegIndex(id), this.
|
|
1917
|
+
if (this.hasNeg[id]) yield [_SignedIndexArray.toNegIndex(id), this.negVal[id]];
|
|
1591
1918
|
}
|
|
1592
1919
|
for (let id = 0; id < this.posLen; id++) {
|
|
1593
|
-
if (this.hasPos[id]) yield [id, this.
|
|
1920
|
+
if (this.hasPos[id]) yield [id, this.posVal[id]];
|
|
1594
1921
|
}
|
|
1595
1922
|
}
|
|
1923
|
+
indicesArray() {
|
|
1924
|
+
return [...this.indices()];
|
|
1925
|
+
}
|
|
1926
|
+
valuesArray() {
|
|
1927
|
+
return [...this.values()];
|
|
1928
|
+
}
|
|
1596
1929
|
entriesArray() {
|
|
1597
1930
|
return [...this.entries()];
|
|
1598
1931
|
}
|
|
1932
|
+
*kvKeys() {
|
|
1933
|
+
for (const id of this.indices()) {
|
|
1934
|
+
yield [id];
|
|
1935
|
+
}
|
|
1936
|
+
}
|
|
1937
|
+
*kvValues() {
|
|
1938
|
+
for (const value of this.values()) {
|
|
1939
|
+
yield value;
|
|
1940
|
+
}
|
|
1941
|
+
}
|
|
1942
|
+
*kvEntries() {
|
|
1943
|
+
for (const [id, value] of this.entries()) {
|
|
1944
|
+
yield [[id], value];
|
|
1945
|
+
}
|
|
1946
|
+
}
|
|
1599
1947
|
*[Symbol.iterator]() {
|
|
1600
1948
|
yield* this.entries();
|
|
1601
1949
|
}
|
|
@@ -1613,21 +1961,21 @@ var SignedIndexArray = class _SignedIndexArray {
|
|
|
1613
1961
|
return this;
|
|
1614
1962
|
}
|
|
1615
1963
|
some(fn) {
|
|
1616
|
-
for (const [id,
|
|
1617
|
-
if (fn(
|
|
1964
|
+
for (const [id, value] of this.entries()) {
|
|
1965
|
+
if (fn(value, id)) return true;
|
|
1618
1966
|
}
|
|
1619
1967
|
return false;
|
|
1620
1968
|
}
|
|
1621
1969
|
every(fn) {
|
|
1622
|
-
for (const [id,
|
|
1623
|
-
if (!fn(
|
|
1970
|
+
for (const [id, value] of this.entries()) {
|
|
1971
|
+
if (!fn(value, id)) return false;
|
|
1624
1972
|
}
|
|
1625
1973
|
return true;
|
|
1626
1974
|
}
|
|
1627
|
-
filter(
|
|
1628
|
-
|
|
1629
|
-
for (const [id,
|
|
1630
|
-
if (
|
|
1975
|
+
filter(predicate) {
|
|
1976
|
+
const result = new this.constructor();
|
|
1977
|
+
for (const [id, value] of this.entries()) {
|
|
1978
|
+
if (predicate(value, id, this)) result.set(id, value);
|
|
1631
1979
|
}
|
|
1632
1980
|
return result;
|
|
1633
1981
|
}
|
|
@@ -1650,22 +1998,22 @@ var SignedIndexArray = class _SignedIndexArray {
|
|
|
1650
1998
|
start = first;
|
|
1651
1999
|
}
|
|
1652
2000
|
for (let current = start; !current.done; current = iterator.next()) {
|
|
1653
|
-
const [id,
|
|
1654
|
-
acc = fn(acc,
|
|
2001
|
+
const [id, value] = current.value;
|
|
2002
|
+
acc = fn(acc, value, id);
|
|
1655
2003
|
}
|
|
1656
2004
|
return acc;
|
|
1657
2005
|
}
|
|
1658
2006
|
mapToArray(fn) {
|
|
1659
2007
|
let result = [];
|
|
1660
|
-
for (const [id,
|
|
1661
|
-
result.push(fn(
|
|
2008
|
+
for (const [id, value] of this.entries()) {
|
|
2009
|
+
result.push(fn(value, id));
|
|
1662
2010
|
}
|
|
1663
2011
|
return result;
|
|
1664
2012
|
}
|
|
1665
2013
|
map(fn) {
|
|
1666
2014
|
let result = new _SignedIndexArray();
|
|
1667
|
-
for (const [id,
|
|
1668
|
-
result.set(id, fn(
|
|
2015
|
+
for (const [id, value] of this.entries()) {
|
|
2016
|
+
result.set(id, fn(value, id));
|
|
1669
2017
|
}
|
|
1670
2018
|
return result;
|
|
1671
2019
|
}
|
|
@@ -1677,25 +2025,25 @@ var SignedIndexArray = class _SignedIndexArray {
|
|
|
1677
2025
|
const hasA = this.hasPos[i];
|
|
1678
2026
|
const hasB = other.hasPos[i];
|
|
1679
2027
|
if (hasA !== hasB) return false;
|
|
1680
|
-
if (hasA && !eq(this.
|
|
2028
|
+
if (hasA && !eq(this.posVal[i], other.posVal[i])) return false;
|
|
1681
2029
|
}
|
|
1682
2030
|
const negLen = Math.max(this.negLen, other.negLen);
|
|
1683
2031
|
for (let i = 0; i < negLen; ++i) {
|
|
1684
2032
|
const hasA = this.hasNeg[i];
|
|
1685
2033
|
const hasB = other.hasNeg[i];
|
|
1686
2034
|
if (hasA !== hasB) return false;
|
|
1687
|
-
if (hasA && !eq(this.
|
|
2035
|
+
if (hasA && !eq(this.negVal[i], other.negVal[i])) return false;
|
|
1688
2036
|
}
|
|
1689
2037
|
return true;
|
|
1690
2038
|
}
|
|
1691
2039
|
toString() {
|
|
1692
2040
|
if (this.size === 0) return `SignedIndexArray[ ]`;
|
|
1693
|
-
const entries = this.entriesArray().map(([id,
|
|
2041
|
+
const entries = this.entriesArray().map(([id, value]) => `${id}: ${value}`).join(", ");
|
|
1694
2042
|
return `SignedIndexArray[ ${entries} ]`;
|
|
1695
2043
|
}
|
|
1696
2044
|
};
|
|
1697
2045
|
|
|
1698
|
-
// src/core/
|
|
2046
|
+
// src/core/map1.ts
|
|
1699
2047
|
var Map1 = class _Map1 {
|
|
1700
2048
|
constructor(entries) {
|
|
1701
2049
|
__publicField(this, "map1");
|
|
@@ -1731,28 +2079,46 @@ var Map1 = class _Map1 {
|
|
|
1731
2079
|
get size() {
|
|
1732
2080
|
return this.map1.size;
|
|
1733
2081
|
}
|
|
2082
|
+
isEmpty() {
|
|
2083
|
+
return this.size === 0;
|
|
2084
|
+
}
|
|
1734
2085
|
forEach(callbackfn, thisArg) {
|
|
1735
2086
|
this.map1.forEach((value, key1) => callbackfn.call(thisArg, value, key1, this));
|
|
1736
2087
|
}
|
|
1737
|
-
keys() {
|
|
1738
|
-
|
|
2088
|
+
*keys() {
|
|
2089
|
+
yield* this.map1.keys();
|
|
2090
|
+
}
|
|
2091
|
+
*values() {
|
|
2092
|
+
yield* this.map1.values();
|
|
2093
|
+
}
|
|
2094
|
+
*entries() {
|
|
2095
|
+
for (const [key1, value] of this.map1)
|
|
2096
|
+
yield [key1, value];
|
|
1739
2097
|
}
|
|
1740
2098
|
keysArray() {
|
|
1741
2099
|
return [...this.keys()];
|
|
1742
2100
|
}
|
|
1743
|
-
values() {
|
|
1744
|
-
return this.map1.values();
|
|
1745
|
-
}
|
|
1746
2101
|
valuesArray() {
|
|
1747
2102
|
return [...this.values()];
|
|
1748
2103
|
}
|
|
1749
|
-
*entries() {
|
|
1750
|
-
for (const [key1, value] of this.map1)
|
|
1751
|
-
yield [key1, value];
|
|
1752
|
-
}
|
|
1753
2104
|
entriesArray() {
|
|
1754
2105
|
return [...this.entries()];
|
|
1755
2106
|
}
|
|
2107
|
+
*kvKeys() {
|
|
2108
|
+
for (const key of this.keys()) {
|
|
2109
|
+
yield [key];
|
|
2110
|
+
}
|
|
2111
|
+
}
|
|
2112
|
+
*kvValues() {
|
|
2113
|
+
for (const el of this.values()) {
|
|
2114
|
+
yield el;
|
|
2115
|
+
}
|
|
2116
|
+
}
|
|
2117
|
+
*kvEntries() {
|
|
2118
|
+
for (const [key, el] of this.entries()) {
|
|
2119
|
+
yield [[key], el];
|
|
2120
|
+
}
|
|
2121
|
+
}
|
|
1756
2122
|
*[Symbol.iterator]() {
|
|
1757
2123
|
yield* this.entries();
|
|
1758
2124
|
}
|
|
@@ -1781,16 +2147,33 @@ var Map1 = class _Map1 {
|
|
|
1781
2147
|
}
|
|
1782
2148
|
return true;
|
|
1783
2149
|
}
|
|
1784
|
-
filter(
|
|
1785
|
-
|
|
2150
|
+
filter(predicate) {
|
|
2151
|
+
const result = new this.constructor();
|
|
1786
2152
|
for (const [key1, value] of this.map1) {
|
|
1787
|
-
if (
|
|
2153
|
+
if (predicate(value, key1, this)) result.set(key1, value);
|
|
1788
2154
|
}
|
|
1789
2155
|
return result;
|
|
1790
2156
|
}
|
|
1791
2157
|
reduce(fn, init) {
|
|
1792
|
-
let
|
|
1793
|
-
|
|
2158
|
+
let iterator = this.entries();
|
|
2159
|
+
let first = iterator.next();
|
|
2160
|
+
if (first.done) {
|
|
2161
|
+
if (arguments.length < 2) {
|
|
2162
|
+
throw new TypeError("Reduce of empty Map1 with no initial value!");
|
|
2163
|
+
}
|
|
2164
|
+
return init;
|
|
2165
|
+
}
|
|
2166
|
+
let acc;
|
|
2167
|
+
let start;
|
|
2168
|
+
if (arguments.length < 2) {
|
|
2169
|
+
acc = first.value[1];
|
|
2170
|
+
start = iterator.next();
|
|
2171
|
+
} else {
|
|
2172
|
+
acc = init;
|
|
2173
|
+
start = first;
|
|
2174
|
+
}
|
|
2175
|
+
for (let current = start; !current.done; current = iterator.next()) {
|
|
2176
|
+
const [key1, value] = current.value;
|
|
1794
2177
|
acc = fn(acc, value, key1);
|
|
1795
2178
|
}
|
|
1796
2179
|
return acc;
|
|
@@ -1814,9 +2197,11 @@ var Map1 = class _Map1 {
|
|
|
1814
2197
|
}
|
|
1815
2198
|
toString() {
|
|
1816
2199
|
const entries = [...this.map1].map(([k, v]) => `${k} => ${v}`).join(", ");
|
|
1817
|
-
return `Map1(${this.
|
|
2200
|
+
return entries.length === 0 ? `Map1(0){ }` : `Map1(${this.size}){ ${entries} }`;
|
|
1818
2201
|
}
|
|
1819
2202
|
};
|
|
2203
|
+
|
|
2204
|
+
// src/core/map2.ts
|
|
1820
2205
|
var Map2 = class _Map2 {
|
|
1821
2206
|
constructor(entries) {
|
|
1822
2207
|
__publicField(this, "map1", /* @__PURE__ */ new Map());
|
|
@@ -1868,39 +2253,48 @@ var Map2 = class _Map2 {
|
|
|
1868
2253
|
}
|
|
1869
2254
|
return count;
|
|
1870
2255
|
}
|
|
2256
|
+
isEmpty() {
|
|
2257
|
+
return this.size === 0;
|
|
2258
|
+
}
|
|
1871
2259
|
forEach(callbackfn, thisArg) {
|
|
1872
2260
|
this.map1.forEach((map2, key1) => map2.forEach((value, key2) => callbackfn.call(thisArg, value, key1, key2, this)));
|
|
1873
2261
|
}
|
|
1874
|
-
keys() {
|
|
1875
|
-
|
|
1876
|
-
for (const
|
|
1877
|
-
|
|
1878
|
-
yield [key1, key2];
|
|
1879
|
-
}
|
|
1880
|
-
return gen(this.map1);
|
|
1881
|
-
}
|
|
1882
|
-
keysArray() {
|
|
1883
|
-
return [...this.keys()];
|
|
1884
|
-
}
|
|
1885
|
-
values() {
|
|
1886
|
-
function* gen(map1) {
|
|
1887
|
-
for (const map2 of map1.values())
|
|
1888
|
-
for (const value of map2.values())
|
|
1889
|
-
yield value;
|
|
1890
|
-
}
|
|
1891
|
-
return gen(this.map1);
|
|
2262
|
+
*keys() {
|
|
2263
|
+
for (const [key1, map2] of this.map1)
|
|
2264
|
+
for (const key2 of map2.keys())
|
|
2265
|
+
yield [key1, key2];
|
|
1892
2266
|
}
|
|
1893
|
-
|
|
1894
|
-
|
|
2267
|
+
*values() {
|
|
2268
|
+
for (const map2 of this.map1.values())
|
|
2269
|
+
for (const value of map2.values())
|
|
2270
|
+
yield value;
|
|
1895
2271
|
}
|
|
1896
2272
|
*entries() {
|
|
1897
2273
|
for (const [key1, map2] of this.map1)
|
|
1898
2274
|
for (const [key2, value] of map2)
|
|
1899
2275
|
yield [key1, key2, value];
|
|
1900
2276
|
}
|
|
2277
|
+
keysArray() {
|
|
2278
|
+
return [...this.keys()];
|
|
2279
|
+
}
|
|
2280
|
+
valuesArray() {
|
|
2281
|
+
return [...this.values()];
|
|
2282
|
+
}
|
|
1901
2283
|
entriesArray() {
|
|
1902
2284
|
return [...this.entries()];
|
|
1903
2285
|
}
|
|
2286
|
+
*kvKeys() {
|
|
2287
|
+
for (const [key1, key2] of this.keys())
|
|
2288
|
+
yield [key1, key2];
|
|
2289
|
+
}
|
|
2290
|
+
*kvValues() {
|
|
2291
|
+
for (const el of this.values())
|
|
2292
|
+
yield el;
|
|
2293
|
+
}
|
|
2294
|
+
*kvEntries() {
|
|
2295
|
+
for (const [key1, key2, el] of this.entries())
|
|
2296
|
+
yield [[key1, key2], el];
|
|
2297
|
+
}
|
|
1904
2298
|
*[Symbol.iterator]() {
|
|
1905
2299
|
yield* this.entries();
|
|
1906
2300
|
}
|
|
@@ -1933,21 +2327,36 @@ var Map2 = class _Map2 {
|
|
|
1933
2327
|
}
|
|
1934
2328
|
return true;
|
|
1935
2329
|
}
|
|
1936
|
-
filter(
|
|
1937
|
-
|
|
2330
|
+
filter(predicate) {
|
|
2331
|
+
const result = new this.constructor();
|
|
1938
2332
|
for (const [key1, map2] of this.map1) {
|
|
1939
2333
|
for (const [key2, value] of map2) {
|
|
1940
|
-
if (
|
|
2334
|
+
if (predicate(value, key1, key2, this)) result.set(key1, key2, value);
|
|
1941
2335
|
}
|
|
1942
2336
|
}
|
|
1943
2337
|
return result;
|
|
1944
2338
|
}
|
|
1945
2339
|
reduce(fn, init) {
|
|
1946
|
-
let
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
2340
|
+
let iterator = this.entries();
|
|
2341
|
+
let first = iterator.next();
|
|
2342
|
+
if (first.done) {
|
|
2343
|
+
if (arguments.length < 2) {
|
|
2344
|
+
throw new TypeError("Reduce of empty Map2 with no initial value!");
|
|
1950
2345
|
}
|
|
2346
|
+
return init;
|
|
2347
|
+
}
|
|
2348
|
+
let acc;
|
|
2349
|
+
let start;
|
|
2350
|
+
if (arguments.length < 2) {
|
|
2351
|
+
acc = first.value[2];
|
|
2352
|
+
start = iterator.next();
|
|
2353
|
+
} else {
|
|
2354
|
+
acc = init;
|
|
2355
|
+
start = first;
|
|
2356
|
+
}
|
|
2357
|
+
for (let current = start; !current.done; current = iterator.next()) {
|
|
2358
|
+
const [key1, key2, value] = current.value;
|
|
2359
|
+
acc = fn(acc, value, key1, key2);
|
|
1951
2360
|
}
|
|
1952
2361
|
return acc;
|
|
1953
2362
|
}
|
|
@@ -1984,9 +2393,11 @@ var Map2 = class _Map2 {
|
|
|
1984
2393
|
const inner = [...map2].map(([key2, v]) => `${key2} => ${v}`).join(", ");
|
|
1985
2394
|
entries.push(`${key1} => { ${inner} }`);
|
|
1986
2395
|
}
|
|
1987
|
-
return `Map2(${this.size})
|
|
2396
|
+
return entries.length === 0 ? `Map2(0){ }` : `Map2(${this.size}){ ${entries} }`;
|
|
1988
2397
|
}
|
|
1989
2398
|
};
|
|
2399
|
+
|
|
2400
|
+
// src/core/map3.ts
|
|
1990
2401
|
var Map3 = class _Map3 {
|
|
1991
2402
|
constructor(entries) {
|
|
1992
2403
|
__publicField(this, "map1", /* @__PURE__ */ new Map());
|
|
@@ -2054,32 +2465,23 @@ var Map3 = class _Map3 {
|
|
|
2054
2465
|
}
|
|
2055
2466
|
return count;
|
|
2056
2467
|
}
|
|
2468
|
+
isEmpty() {
|
|
2469
|
+
return this.size === 0;
|
|
2470
|
+
}
|
|
2057
2471
|
forEach(callbackfn, thisArg) {
|
|
2058
2472
|
this.map1.forEach((map2, key1) => map2.forEach((map3, key2) => map3.forEach((value, key3) => callbackfn.call(thisArg, value, key1, key2, key3, this))));
|
|
2059
2473
|
}
|
|
2060
|
-
keys() {
|
|
2061
|
-
|
|
2062
|
-
for (const [
|
|
2063
|
-
for (const
|
|
2064
|
-
|
|
2065
|
-
yield [key1, key2, key3];
|
|
2066
|
-
}
|
|
2067
|
-
return gen(this.map1);
|
|
2068
|
-
}
|
|
2069
|
-
keysArray() {
|
|
2070
|
-
return [...this.keys()];
|
|
2071
|
-
}
|
|
2072
|
-
values() {
|
|
2073
|
-
function* gen(map1) {
|
|
2074
|
-
for (const map2 of map1.values())
|
|
2075
|
-
for (const map3 of map2.values())
|
|
2076
|
-
for (const value of map3.values())
|
|
2077
|
-
yield value;
|
|
2078
|
-
}
|
|
2079
|
-
return gen(this.map1);
|
|
2474
|
+
*keys() {
|
|
2475
|
+
for (const [key1, map2] of this.map1)
|
|
2476
|
+
for (const [key2, map3] of map2)
|
|
2477
|
+
for (const key3 of map3.keys())
|
|
2478
|
+
yield [key1, key2, key3];
|
|
2080
2479
|
}
|
|
2081
|
-
|
|
2082
|
-
|
|
2480
|
+
*values() {
|
|
2481
|
+
for (const map2 of this.map1.values())
|
|
2482
|
+
for (const map3 of map2.values())
|
|
2483
|
+
for (const value of map3.values())
|
|
2484
|
+
yield value;
|
|
2083
2485
|
}
|
|
2084
2486
|
*entries() {
|
|
2085
2487
|
for (const [key1, map2] of this.map1)
|
|
@@ -2087,9 +2489,27 @@ var Map3 = class _Map3 {
|
|
|
2087
2489
|
for (const [key3, value] of map3)
|
|
2088
2490
|
yield [key1, key2, key3, value];
|
|
2089
2491
|
}
|
|
2492
|
+
keysArray() {
|
|
2493
|
+
return [...this.keys()];
|
|
2494
|
+
}
|
|
2495
|
+
valuesArray() {
|
|
2496
|
+
return [...this.values()];
|
|
2497
|
+
}
|
|
2090
2498
|
entriesArray() {
|
|
2091
2499
|
return [...this.entries()];
|
|
2092
2500
|
}
|
|
2501
|
+
*kvKeys() {
|
|
2502
|
+
for (const [key1, key2, key3] of this.keys())
|
|
2503
|
+
yield [key1, key2, key3];
|
|
2504
|
+
}
|
|
2505
|
+
*kvValues() {
|
|
2506
|
+
for (const el of this.values())
|
|
2507
|
+
yield el;
|
|
2508
|
+
}
|
|
2509
|
+
*kvEntries() {
|
|
2510
|
+
for (const [key1, key2, key3, el] of this.entries())
|
|
2511
|
+
yield [[key1, key2, key3], el];
|
|
2512
|
+
}
|
|
2093
2513
|
*[Symbol.iterator]() {
|
|
2094
2514
|
yield* this.entries();
|
|
2095
2515
|
}
|
|
@@ -2126,25 +2546,38 @@ var Map3 = class _Map3 {
|
|
|
2126
2546
|
}
|
|
2127
2547
|
return true;
|
|
2128
2548
|
}
|
|
2129
|
-
filter(
|
|
2130
|
-
|
|
2549
|
+
filter(predicate) {
|
|
2550
|
+
const result = new this.constructor();
|
|
2131
2551
|
for (const [key1, map2] of this.map1) {
|
|
2132
2552
|
for (const [key2, map3] of map2) {
|
|
2133
2553
|
for (const [key3, value] of map3) {
|
|
2134
|
-
if (
|
|
2554
|
+
if (predicate(value, key1, key2, key3, this)) result.set(key1, key2, key3, value);
|
|
2135
2555
|
}
|
|
2136
2556
|
}
|
|
2137
2557
|
}
|
|
2138
2558
|
return result;
|
|
2139
2559
|
}
|
|
2140
2560
|
reduce(fn, init) {
|
|
2141
|
-
let
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
}
|
|
2561
|
+
let iterator = this.entries();
|
|
2562
|
+
let first = iterator.next();
|
|
2563
|
+
if (first.done) {
|
|
2564
|
+
if (arguments.length < 2) {
|
|
2565
|
+
throw new TypeError("Reduce of empty Map3 with no initial value!");
|
|
2147
2566
|
}
|
|
2567
|
+
return init;
|
|
2568
|
+
}
|
|
2569
|
+
let acc;
|
|
2570
|
+
let start;
|
|
2571
|
+
if (arguments.length < 2) {
|
|
2572
|
+
acc = first.value[3];
|
|
2573
|
+
start = iterator.next();
|
|
2574
|
+
} else {
|
|
2575
|
+
acc = init;
|
|
2576
|
+
start = first;
|
|
2577
|
+
}
|
|
2578
|
+
for (let current = start; !current.done; current = iterator.next()) {
|
|
2579
|
+
const [key1, key2, key3, value] = current.value;
|
|
2580
|
+
acc = fn(acc, value, key1, key2, key3);
|
|
2148
2581
|
}
|
|
2149
2582
|
return acc;
|
|
2150
2583
|
}
|
|
@@ -2189,7 +2622,7 @@ var Map3 = class _Map3 {
|
|
|
2189
2622
|
entries.push(`${key1} => ${key2} => { ${inner} }`);
|
|
2190
2623
|
}
|
|
2191
2624
|
}
|
|
2192
|
-
return `Map3(${this.size})
|
|
2625
|
+
return entries.length === 0 ? `Map3(0){ }` : `Map3(${this.size}){ ${entries.join(", ")} }`;
|
|
2193
2626
|
}
|
|
2194
2627
|
};
|
|
2195
2628
|
|
|
@@ -2198,6 +2631,12 @@ var MultiContainer = class {
|
|
|
2198
2631
|
constructor(base) {
|
|
2199
2632
|
this.base = base;
|
|
2200
2633
|
}
|
|
2634
|
+
isEmpty() {
|
|
2635
|
+
return this.base.isEmpty();
|
|
2636
|
+
}
|
|
2637
|
+
clear() {
|
|
2638
|
+
this.base.clear?.();
|
|
2639
|
+
}
|
|
2201
2640
|
add(...keysAndValue) {
|
|
2202
2641
|
const keys = keysAndValue.slice(0, -1);
|
|
2203
2642
|
const value = keysAndValue[keysAndValue.length - 1];
|
|
@@ -2220,22 +2659,123 @@ var MultiContainer = class {
|
|
|
2220
2659
|
return this.base.get(...keys) ?? [];
|
|
2221
2660
|
}
|
|
2222
2661
|
*iterAll(...keys) {
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2662
|
+
yield* this.getAll(...keys);
|
|
2663
|
+
}
|
|
2664
|
+
*values() {
|
|
2665
|
+
for (const keys of this.keys()) {
|
|
2666
|
+
yield* this.getAll(...keys);
|
|
2226
2667
|
}
|
|
2227
2668
|
}
|
|
2228
|
-
|
|
2229
|
-
this.base.
|
|
2669
|
+
*keys() {
|
|
2670
|
+
for (const keys of this.base.kvKeys()) {
|
|
2671
|
+
yield keys;
|
|
2672
|
+
}
|
|
2673
|
+
}
|
|
2674
|
+
*entries() {
|
|
2675
|
+
for (const keys of this.keys()) {
|
|
2676
|
+
const arr = this.getAll(...keys);
|
|
2677
|
+
if (arr.length > 0) yield [keys, arr];
|
|
2678
|
+
}
|
|
2679
|
+
}
|
|
2680
|
+
[Symbol.iterator]() {
|
|
2681
|
+
return this.entries();
|
|
2682
|
+
}
|
|
2683
|
+
toString() {
|
|
2684
|
+
const entries = [];
|
|
2685
|
+
for (const keys of this.keys()) {
|
|
2686
|
+
const arr = this.getAll(...keys);
|
|
2687
|
+
const keyStr = Array.isArray(keys) ? `[${keys.map((k) => JSON.stringify(k)).join(", ")}]` : `[${JSON.stringify(keys)}]`;
|
|
2688
|
+
const valuesStr = Array.isArray(arr) ? `[${arr.map((v) => JSON.stringify(v)).join(", ")}]` : "[]";
|
|
2689
|
+
entries.push(`${keyStr} => ${valuesStr}`);
|
|
2690
|
+
}
|
|
2691
|
+
return `MultiContainer{ ${entries.join(", ")} }`;
|
|
2230
2692
|
}
|
|
2231
2693
|
};
|
|
2232
2694
|
function asMulti(base) {
|
|
2233
2695
|
return new MultiContainer(base);
|
|
2234
2696
|
}
|
|
2697
|
+
|
|
2698
|
+
// src/core/deprecated/vec2.ts
|
|
2699
|
+
var Vec2 = class _Vec2 {
|
|
2700
|
+
constructor(x, y) {
|
|
2701
|
+
__publicField(this, "x");
|
|
2702
|
+
__publicField(this, "y");
|
|
2703
|
+
this.x = x ?? 0;
|
|
2704
|
+
this.y = y ?? 0;
|
|
2705
|
+
}
|
|
2706
|
+
length() {
|
|
2707
|
+
return Math.sqrt(this.x * this.x + this.y * this.y);
|
|
2708
|
+
}
|
|
2709
|
+
add(a) {
|
|
2710
|
+
return new _Vec2(this.x + a.x, this.y + a.y);
|
|
2711
|
+
}
|
|
2712
|
+
sub(a) {
|
|
2713
|
+
return new _Vec2(this.x - a.x, this.y - a.y);
|
|
2714
|
+
}
|
|
2715
|
+
mul(a) {
|
|
2716
|
+
return new _Vec2(this.x * a, this.y * a);
|
|
2717
|
+
}
|
|
2718
|
+
div(a) {
|
|
2719
|
+
return new _Vec2(this.x / a, this.y / a);
|
|
2720
|
+
}
|
|
2721
|
+
};
|
|
2722
|
+
|
|
2723
|
+
// src/core/deprecated/small-int-cache.ts
|
|
2724
|
+
var SmallIntCache = class {
|
|
2725
|
+
// for keys < 0
|
|
2726
|
+
constructor() {
|
|
2727
|
+
__publicField(this, "pos");
|
|
2728
|
+
// for keys >= 0
|
|
2729
|
+
__publicField(this, "neg");
|
|
2730
|
+
this.pos = [];
|
|
2731
|
+
this.neg = [];
|
|
2732
|
+
}
|
|
2733
|
+
set(key, value) {
|
|
2734
|
+
if (!isInteger(key)) {
|
|
2735
|
+
throw new Error("Key must be an integer");
|
|
2736
|
+
} else if (key >= 0) {
|
|
2737
|
+
this.pos[key] = value;
|
|
2738
|
+
} else {
|
|
2739
|
+
this.neg[-key - 1] = value;
|
|
2740
|
+
}
|
|
2741
|
+
}
|
|
2742
|
+
get(key) {
|
|
2743
|
+
if (!isInteger(key)) {
|
|
2744
|
+
throw new Error("Key must be an integer");
|
|
2745
|
+
} else if (key >= 0) {
|
|
2746
|
+
return this.pos[key];
|
|
2747
|
+
} else {
|
|
2748
|
+
return this.neg[-key - 1];
|
|
2749
|
+
}
|
|
2750
|
+
}
|
|
2751
|
+
has(key) {
|
|
2752
|
+
if (!isInteger(key)) {
|
|
2753
|
+
return false;
|
|
2754
|
+
} else if (key >= 0) {
|
|
2755
|
+
return key in this.pos;
|
|
2756
|
+
} else {
|
|
2757
|
+
return -key - 1 in this.neg;
|
|
2758
|
+
}
|
|
2759
|
+
}
|
|
2760
|
+
delete(key) {
|
|
2761
|
+
if (!isInteger(key)) {
|
|
2762
|
+
return;
|
|
2763
|
+
} else if (key >= 0) {
|
|
2764
|
+
delete this.pos[key];
|
|
2765
|
+
} else {
|
|
2766
|
+
delete this.neg[-key - 1];
|
|
2767
|
+
}
|
|
2768
|
+
}
|
|
2769
|
+
clear() {
|
|
2770
|
+
this.pos = [];
|
|
2771
|
+
this.neg = [];
|
|
2772
|
+
}
|
|
2773
|
+
};
|
|
2235
2774
|
export {
|
|
2236
2775
|
Assert,
|
|
2237
2776
|
Cookies,
|
|
2238
2777
|
Device,
|
|
2778
|
+
DivRect,
|
|
2239
2779
|
IndexArray,
|
|
2240
2780
|
LRUCache,
|
|
2241
2781
|
Map1,
|
|
@@ -2246,6 +2786,7 @@ export {
|
|
|
2246
2786
|
SmallIntCache,
|
|
2247
2787
|
Stack,
|
|
2248
2788
|
utils_exports as Utils,
|
|
2789
|
+
Vec,
|
|
2249
2790
|
Vec2,
|
|
2250
2791
|
asMulti
|
|
2251
2792
|
};
|