flo-mat 3.0.4 → 3.0.5
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/browser/index.js +611 -20
- package/browser/index.min.js +1 -1
- package/node/bezier/total-curvature.d.ts +13 -1
- package/node/bezier/total-length.d.ts +13 -1
- package/node/cp-node/cp-node-fs.d.ts +12 -1
- package/node/cp-node/fs/get-distance-to-next.d.ts +12 -1
- package/node/cp-node/fs/get-mat-curve-to-next.d.ts +12 -1
- package/node/cp-node/fs/get-smoothed-speed.d.ts +12 -1
- package/node/cp-node/fs/get-speed.d.ts +12 -1
- package/node/geometry/get-bounding-box-.d.ts +13 -1
- package/node/point-on-shape/is-pos-quite-sharp-corner.d.ts +12 -1
- package/node/point-on-shape/is-pos-sharp-corner.d.ts +12 -1
- package/node/svg/get-loop-bounds.d.ts +12 -1
- package/node/svg/get-shape-bounds.d.ts +12 -1
- package/package.json +2 -2
package/browser/index.js
CHANGED
|
@@ -5127,29 +5127,593 @@ function totalLength(ps, maxCurviness = 0.4, gaussOrder = 16) {
|
|
|
5127
5127
|
|
|
5128
5128
|
//# sourceMappingURL=total-length.js.map
|
|
5129
5129
|
;// ./node_modules/flo-memoize/node/memoize.js
|
|
5130
|
+
function checkMapLength(map, idx, maxPrimitiveCacheLengths) {
|
|
5131
|
+
if (map.size === undefined || maxPrimitiveCacheLengths === undefined) {
|
|
5132
|
+
return;
|
|
5133
|
+
}
|
|
5134
|
+
const maxLen = maxPrimitiveCacheLengths[idx];
|
|
5135
|
+
if (map.size > maxLen && maxLen !== undefined) {
|
|
5136
|
+
// the below is to make sure we use the iterator protocol on the map
|
|
5137
|
+
// so we ensure O(1)
|
|
5138
|
+
for (const [k] of map) {
|
|
5139
|
+
map.delete(k);
|
|
5140
|
+
break;
|
|
5141
|
+
}
|
|
5142
|
+
}
|
|
5143
|
+
}
|
|
5130
5144
|
/**
|
|
5131
|
-
* Memoize
|
|
5145
|
+
* Memoize the given arity 0 function.
|
|
5146
|
+
*/
|
|
5147
|
+
function memoize0(f, maxPrimitiveCacheLengths) {
|
|
5148
|
+
let r;
|
|
5149
|
+
let executed = false;
|
|
5150
|
+
const f_ = function () {
|
|
5151
|
+
if (!executed) {
|
|
5152
|
+
r = f();
|
|
5153
|
+
executed = true;
|
|
5154
|
+
}
|
|
5155
|
+
return r;
|
|
5156
|
+
};
|
|
5157
|
+
return f_;
|
|
5158
|
+
}
|
|
5159
|
+
/**
|
|
5160
|
+
* Memoize (by reference on the input parameter) the given arity 1 function.
|
|
5132
5161
|
*
|
|
5133
|
-
* *
|
|
5134
|
-
* `WeakMap` and thus garbage collected later; this is especially important
|
|
5135
|
-
* in functional programming where a lot of garbage collection takes place;
|
|
5162
|
+
* * prefer most numerous parameters last in formal parameter list
|
|
5136
5163
|
*
|
|
5137
|
-
*
|
|
5138
|
-
*
|
|
5164
|
+
* @param f the function to memoize
|
|
5165
|
+
* @param maxPrimitiveCacheLengths optional array of maximum cache lengths for
|
|
5166
|
+
* primitive parameters in the order of the parameters of the functio; use zero
|
|
5167
|
+
* (or anything else really) for non-primitive values as they won't be used
|
|
5139
5168
|
*/
|
|
5140
|
-
function
|
|
5141
|
-
const
|
|
5142
|
-
|
|
5143
|
-
|
|
5144
|
-
|
|
5145
|
-
|
|
5146
|
-
|
|
5169
|
+
function memoize1(f, maxPrimitiveCacheLengths, logCacheMissHit = false) {
|
|
5170
|
+
const weakMapS = new WeakMap();
|
|
5171
|
+
const mapS = new Map();
|
|
5172
|
+
function getRMap(s) {
|
|
5173
|
+
const isObjS = (typeof s === "object" || typeof s === 'function') && s !== null;
|
|
5174
|
+
return isObjS ? weakMapS : mapS;
|
|
5175
|
+
}
|
|
5176
|
+
const f_ = function (s) {
|
|
5177
|
+
let r;
|
|
5178
|
+
const mS = getRMap(s);
|
|
5179
|
+
if (!mS.has(s)) {
|
|
5180
|
+
if (logCacheMissHit) {
|
|
5181
|
+
console.log('cache miss');
|
|
5182
|
+
}
|
|
5183
|
+
r = f(s);
|
|
5184
|
+
mS.set(s, r);
|
|
5185
|
+
checkMapLength(mapS, 0, maxPrimitiveCacheLengths);
|
|
5186
|
+
}
|
|
5187
|
+
else {
|
|
5188
|
+
if (logCacheMissHit) {
|
|
5189
|
+
console.log('cache hit');
|
|
5190
|
+
}
|
|
5191
|
+
r = mS.get(s);
|
|
5192
|
+
}
|
|
5193
|
+
return r;
|
|
5194
|
+
};
|
|
5195
|
+
f_.mapS = mapS;
|
|
5196
|
+
f_.weakMapS = weakMapS;
|
|
5197
|
+
f_.clearCache = function () { mapS.clear(); };
|
|
5198
|
+
f_.addToCache = function (r, s) {
|
|
5199
|
+
const mS = getRMap(s);
|
|
5200
|
+
mS.set(s, r);
|
|
5201
|
+
checkMapLength(mS, 1, maxPrimitiveCacheLengths);
|
|
5202
|
+
};
|
|
5203
|
+
return f_;
|
|
5204
|
+
}
|
|
5205
|
+
/**
|
|
5206
|
+
* Memoize (by reference on the ordered input parameters) the given arity 2
|
|
5207
|
+
* function.
|
|
5208
|
+
*
|
|
5209
|
+
* * prefer most numerous parameters last in formal parameter list
|
|
5210
|
+
*
|
|
5211
|
+
* * @param cacheLengthForParam1 currently ignored but can easily be
|
|
5212
|
+
* implemented if needed
|
|
5213
|
+
*/
|
|
5214
|
+
function memoize2(f, maxPrimitiveCacheLengths) {
|
|
5215
|
+
const weakMapS = new WeakMap();
|
|
5216
|
+
const mapS = new Map();
|
|
5217
|
+
function getRMap(s, t) {
|
|
5218
|
+
const isObjS = (typeof s === "object" || typeof s === 'function') && s !== null;
|
|
5219
|
+
const isObjT = (typeof t === "object" || typeof t === 'function') && t !== null;
|
|
5220
|
+
let mS = isObjS ? weakMapS : mapS;
|
|
5221
|
+
let mmT = mS.get(s);
|
|
5222
|
+
if (mmT === undefined) {
|
|
5223
|
+
mmT = { weakMap: new WeakMap(), map: new Map() };
|
|
5224
|
+
mS.set(s, mmT);
|
|
5225
|
+
checkMapLength(mS, 0, maxPrimitiveCacheLengths);
|
|
5226
|
+
}
|
|
5227
|
+
return isObjT ? mmT.weakMap : mmT.map;
|
|
5228
|
+
}
|
|
5229
|
+
function f_(s, t) {
|
|
5230
|
+
const mT = getRMap(s, t);
|
|
5231
|
+
let r;
|
|
5232
|
+
if (!mT.has(t)) {
|
|
5233
|
+
r = f(s, t);
|
|
5234
|
+
mT.set(t, r);
|
|
5235
|
+
checkMapLength(mT, 1, maxPrimitiveCacheLengths);
|
|
5236
|
+
}
|
|
5237
|
+
else {
|
|
5238
|
+
r = mT.get(t);
|
|
5239
|
+
}
|
|
5240
|
+
return r;
|
|
5241
|
+
}
|
|
5242
|
+
f_.mapS = mapS;
|
|
5243
|
+
f_.weakMapS = weakMapS;
|
|
5244
|
+
f_.clearCache = function () { mapS.clear(); };
|
|
5245
|
+
f_.addToCache = function (r, s, t) {
|
|
5246
|
+
const mT = getRMap(s, t);
|
|
5247
|
+
mT.set(t, r);
|
|
5248
|
+
checkMapLength(mT, 1, maxPrimitiveCacheLengths);
|
|
5249
|
+
};
|
|
5250
|
+
return f_;
|
|
5251
|
+
}
|
|
5252
|
+
/**
|
|
5253
|
+
* Memoize (by reference on the ordered input parameters) the given arity 3
|
|
5254
|
+
* function.
|
|
5255
|
+
*
|
|
5256
|
+
* * prefer most numerous parameters last in formal parameter list
|
|
5257
|
+
*/
|
|
5258
|
+
function memoize3(f, maxPrimitiveCacheLengths) {
|
|
5259
|
+
const weakMapS = new WeakMap();
|
|
5260
|
+
const mapS = new Map();
|
|
5261
|
+
function getRMap(s, t, u) {
|
|
5262
|
+
const isObjS = (typeof s === "object" || typeof s === 'function') && s !== null;
|
|
5263
|
+
const isObjT = (typeof t === "object" || typeof t === 'function') && t !== null;
|
|
5264
|
+
const isObjU = (typeof u === "object" || typeof u === 'function') && u !== null;
|
|
5265
|
+
let mS = isObjS ? weakMapS : mapS;
|
|
5266
|
+
let mmT = mS.get(s);
|
|
5267
|
+
if (mmT === undefined) {
|
|
5268
|
+
mmT = { weakMap: new WeakMap(), map: new Map() };
|
|
5269
|
+
mS.set(s, mmT);
|
|
5270
|
+
checkMapLength(mS, 0, maxPrimitiveCacheLengths);
|
|
5271
|
+
}
|
|
5272
|
+
const mT = isObjT ? mmT.weakMap : mmT.map;
|
|
5273
|
+
let mmU = mT.get(t);
|
|
5274
|
+
if (mmU === undefined) {
|
|
5275
|
+
mmU = { weakMap: new WeakMap(), map: new Map() };
|
|
5276
|
+
mT.set(t, mmU);
|
|
5277
|
+
checkMapLength(mT, 1, maxPrimitiveCacheLengths);
|
|
5278
|
+
}
|
|
5279
|
+
return isObjU ? mmU.weakMap : mmU.map;
|
|
5280
|
+
}
|
|
5281
|
+
const f_ = function (s, t, u) {
|
|
5282
|
+
const mU = getRMap(s, t, u);
|
|
5283
|
+
let r;
|
|
5284
|
+
if (!mU.has(u)) {
|
|
5285
|
+
r = f(s, t, u);
|
|
5286
|
+
mU.set(u, r);
|
|
5287
|
+
checkMapLength(mU, 2, maxPrimitiveCacheLengths);
|
|
5288
|
+
}
|
|
5289
|
+
else {
|
|
5290
|
+
r = mU.get(u);
|
|
5291
|
+
}
|
|
5292
|
+
return r;
|
|
5293
|
+
};
|
|
5294
|
+
f_.mapS = mapS;
|
|
5295
|
+
f_.weakMapS = weakMapS;
|
|
5296
|
+
f_.clearCache = function () { mapS.clear(); };
|
|
5297
|
+
f_.addToCache = function (r, s, t, u) {
|
|
5298
|
+
const mU = getRMap(s, t, u);
|
|
5299
|
+
mU.set(u, r);
|
|
5300
|
+
checkMapLength(mU, 2, maxPrimitiveCacheLengths);
|
|
5301
|
+
};
|
|
5302
|
+
return f_;
|
|
5303
|
+
}
|
|
5304
|
+
/**
|
|
5305
|
+
* Memoize (by reference on the ordered input parameters) the given arity 4
|
|
5306
|
+
* function.
|
|
5307
|
+
*
|
|
5308
|
+
* * prefer most numerous parameters last in formal parameter list
|
|
5309
|
+
*/
|
|
5310
|
+
function memoize4(f, maxPrimitiveCacheLengths, logCacheMissHit = false) {
|
|
5311
|
+
const weakMapS = new WeakMap();
|
|
5312
|
+
const mapS = new Map();
|
|
5313
|
+
function getRMap(s, t, u, v) {
|
|
5314
|
+
const isObjS = (typeof s === "object" || typeof s === 'function') && s !== null;
|
|
5315
|
+
const isObjT = (typeof t === "object" || typeof t === 'function') && t !== null;
|
|
5316
|
+
const isObjU = (typeof u === "object" || typeof u === 'function') && u !== null;
|
|
5317
|
+
const isObjV = (typeof v === "object" || typeof v === 'function') && v !== null;
|
|
5318
|
+
let mS = isObjS
|
|
5319
|
+
? weakMapS
|
|
5320
|
+
: mapS;
|
|
5321
|
+
let mmT = mS.get(s);
|
|
5322
|
+
if (mmT === undefined) {
|
|
5323
|
+
mmT = { weakMap: new WeakMap(), map: new Map() };
|
|
5324
|
+
mS.set(s, mmT);
|
|
5325
|
+
checkMapLength(mS, 0, maxPrimitiveCacheLengths);
|
|
5326
|
+
}
|
|
5327
|
+
const mT = isObjT ? mmT.weakMap : mmT.map;
|
|
5328
|
+
let mmU = mT.get(t);
|
|
5329
|
+
if (mmU === undefined) {
|
|
5330
|
+
mmU = { weakMap: new WeakMap(), map: new Map() };
|
|
5331
|
+
mT.set(t, mmU);
|
|
5332
|
+
checkMapLength(mT, 1, maxPrimitiveCacheLengths);
|
|
5333
|
+
}
|
|
5334
|
+
const mU = isObjU ? mmU.weakMap : mmU.map;
|
|
5335
|
+
let mmV = mU.get(u);
|
|
5336
|
+
if (mmV === undefined) {
|
|
5337
|
+
mmV = { weakMap: new WeakMap(), map: new Map() };
|
|
5338
|
+
mU.set(u, mmV);
|
|
5339
|
+
checkMapLength(mU, 2, maxPrimitiveCacheLengths);
|
|
5340
|
+
}
|
|
5341
|
+
return isObjV ? mmV.weakMap : mmV.map;
|
|
5342
|
+
}
|
|
5343
|
+
const f_ = function (s, t, u, v) {
|
|
5344
|
+
const mV = getRMap(s, t, u, v);
|
|
5345
|
+
let r;
|
|
5346
|
+
if (!mV.has(v)) {
|
|
5347
|
+
if (logCacheMissHit) {
|
|
5348
|
+
console.log('cache miss');
|
|
5349
|
+
}
|
|
5350
|
+
r = f(s, t, u, v);
|
|
5351
|
+
mV.set(v, r);
|
|
5352
|
+
checkMapLength(mV, 3, maxPrimitiveCacheLengths);
|
|
5353
|
+
}
|
|
5354
|
+
else {
|
|
5355
|
+
if (logCacheMissHit) {
|
|
5356
|
+
console.log('cache hit');
|
|
5357
|
+
}
|
|
5358
|
+
r = mV.get(v);
|
|
5359
|
+
}
|
|
5360
|
+
return r;
|
|
5361
|
+
};
|
|
5362
|
+
f_.mapS = mapS;
|
|
5363
|
+
f_.weakMapS = weakMapS;
|
|
5364
|
+
f_.clearCache = function () { mapS.clear(); };
|
|
5365
|
+
f_.addToCache = function (r, s, t, u, v) {
|
|
5366
|
+
const mV = getRMap(s, t, u, v);
|
|
5367
|
+
mV.set(v, r);
|
|
5368
|
+
checkMapLength(mV, 3, maxPrimitiveCacheLengths);
|
|
5369
|
+
};
|
|
5370
|
+
return f_;
|
|
5371
|
+
}
|
|
5372
|
+
/**
|
|
5373
|
+
* Memoize (by reference on the ordered input parameters) the given arity 5
|
|
5374
|
+
* function.
|
|
5375
|
+
*
|
|
5376
|
+
* * prefer most numerous parameters last in formal parameter list
|
|
5377
|
+
*/
|
|
5378
|
+
function memoize5(f, maxPrimitiveCacheLengths) {
|
|
5379
|
+
const weakMapS = new WeakMap();
|
|
5380
|
+
const mapS = new Map();
|
|
5381
|
+
function getRMap(s, t, u, v, w) {
|
|
5382
|
+
const isObjS = (typeof s === "object" || typeof s === 'function') && s !== null;
|
|
5383
|
+
const isObjT = (typeof t === "object" || typeof t === 'function') && t !== null;
|
|
5384
|
+
const isObjU = (typeof u === "object" || typeof u === 'function') && u !== null;
|
|
5385
|
+
const isObjV = (typeof v === "object" || typeof v === 'function') && v !== null;
|
|
5386
|
+
const isObjW = (typeof w === "object" || typeof w === 'function') && w !== null;
|
|
5387
|
+
let mS = isObjS ? weakMapS : mapS;
|
|
5388
|
+
let mmT = mS.get(s);
|
|
5389
|
+
if (mmT === undefined) {
|
|
5390
|
+
mmT = { weakMap: new WeakMap(), map: new Map() };
|
|
5391
|
+
mS.set(s, mmT);
|
|
5392
|
+
checkMapLength(mS, 0, maxPrimitiveCacheLengths);
|
|
5393
|
+
}
|
|
5394
|
+
const mT = isObjT ? mmT.weakMap : mmT.map;
|
|
5395
|
+
let mmU = mT.get(t);
|
|
5396
|
+
if (mmU === undefined) {
|
|
5397
|
+
mmU = { weakMap: new WeakMap(), map: new Map() };
|
|
5398
|
+
mT.set(t, mmU);
|
|
5399
|
+
checkMapLength(mT, 1, maxPrimitiveCacheLengths);
|
|
5400
|
+
}
|
|
5401
|
+
const mU = isObjU ? mmU.weakMap : mmU.map;
|
|
5402
|
+
let mmV = mU.get(u);
|
|
5403
|
+
if (mmV === undefined) {
|
|
5404
|
+
mmV = { weakMap: new WeakMap(), map: new Map() };
|
|
5405
|
+
mU.set(u, mmV);
|
|
5406
|
+
checkMapLength(mU, 2, maxPrimitiveCacheLengths);
|
|
5407
|
+
}
|
|
5408
|
+
const mV = isObjV ? mmV.weakMap : mmV.map;
|
|
5409
|
+
let mmW = mV.get(v);
|
|
5410
|
+
if (mmW === undefined) {
|
|
5411
|
+
mmW = { weakMap: new WeakMap(), map: new Map() };
|
|
5412
|
+
mV.set(v, mmW);
|
|
5413
|
+
checkMapLength(mV, 3, maxPrimitiveCacheLengths);
|
|
5414
|
+
}
|
|
5415
|
+
return isObjW ? mmW.weakMap : mmW.map;
|
|
5416
|
+
}
|
|
5417
|
+
const f_ = function (s, t, u, v, w) {
|
|
5418
|
+
const mW = getRMap(s, t, u, v, w);
|
|
5419
|
+
let r;
|
|
5420
|
+
if (!mW.has(w)) {
|
|
5421
|
+
r = f(s, t, u, v, w);
|
|
5422
|
+
mW.set(w, r);
|
|
5423
|
+
checkMapLength(mW, 4, maxPrimitiveCacheLengths);
|
|
5424
|
+
}
|
|
5425
|
+
else {
|
|
5426
|
+
r = mW.get(w);
|
|
5147
5427
|
}
|
|
5148
|
-
//console.log('cache miss');
|
|
5149
|
-
r = f(t);
|
|
5150
|
-
results.set(t, r);
|
|
5151
5428
|
return r;
|
|
5152
5429
|
};
|
|
5430
|
+
f_.mapS = mapS;
|
|
5431
|
+
f_.weakMapS = weakMapS;
|
|
5432
|
+
f_.clearCache = function () { mapS.clear(); };
|
|
5433
|
+
f_.addToCache = function (r, s, t, u, v, w) {
|
|
5434
|
+
const mW = getRMap(s, t, u, v, w);
|
|
5435
|
+
mW.set(w, r);
|
|
5436
|
+
checkMapLength(mW, 4, maxPrimitiveCacheLengths);
|
|
5437
|
+
};
|
|
5438
|
+
return f_;
|
|
5439
|
+
}
|
|
5440
|
+
/**
|
|
5441
|
+
* Memoize (by reference on the ordered input parameters) the given arity 6
|
|
5442
|
+
* function.
|
|
5443
|
+
*
|
|
5444
|
+
* * prefer most numerous parameters last in formal parameter list
|
|
5445
|
+
*/
|
|
5446
|
+
function memoize6(f, maxPrimitiveCacheLengths) {
|
|
5447
|
+
const weakMapS = new WeakMap();
|
|
5448
|
+
const mapS = new Map();
|
|
5449
|
+
function getRMap(s, t, u, v, w, x) {
|
|
5450
|
+
const isObjS = (typeof s === "object" || typeof s === 'function') && s !== null;
|
|
5451
|
+
const isObjT = (typeof t === "object" || typeof t === 'function') && t !== null;
|
|
5452
|
+
const isObjU = (typeof u === "object" || typeof u === 'function') && u !== null;
|
|
5453
|
+
const isObjV = (typeof v === "object" || typeof v === 'function') && v !== null;
|
|
5454
|
+
const isObjW = (typeof w === "object" || typeof w === 'function') && w !== null;
|
|
5455
|
+
const isObjX = (typeof x === "object" || typeof x === 'function') && x !== null;
|
|
5456
|
+
let mS = isObjS ? weakMapS : mapS;
|
|
5457
|
+
let mmT = mS.get(s);
|
|
5458
|
+
if (mmT === undefined) {
|
|
5459
|
+
mmT = { weakMap: new WeakMap(), map: new Map() };
|
|
5460
|
+
mS.set(s, mmT);
|
|
5461
|
+
checkMapLength(mS, 0, maxPrimitiveCacheLengths);
|
|
5462
|
+
}
|
|
5463
|
+
const mT = isObjT ? mmT.weakMap : mmT.map;
|
|
5464
|
+
let mmU = mT.get(t);
|
|
5465
|
+
if (mmU === undefined) {
|
|
5466
|
+
mmU = { weakMap: new WeakMap(), map: new Map() };
|
|
5467
|
+
mT.set(t, mmU);
|
|
5468
|
+
checkMapLength(mT, 1, maxPrimitiveCacheLengths);
|
|
5469
|
+
}
|
|
5470
|
+
const mU = isObjU ? mmU.weakMap : mmU.map;
|
|
5471
|
+
let mmV = mU.get(u);
|
|
5472
|
+
if (mmV === undefined) {
|
|
5473
|
+
mmV = { weakMap: new WeakMap(), map: new Map() };
|
|
5474
|
+
mU.set(u, mmV);
|
|
5475
|
+
checkMapLength(mU, 2, maxPrimitiveCacheLengths);
|
|
5476
|
+
}
|
|
5477
|
+
const mV = isObjV ? mmV.weakMap : mmV.map;
|
|
5478
|
+
let mmW = mV.get(v);
|
|
5479
|
+
if (mmW === undefined) {
|
|
5480
|
+
mmW = { weakMap: new WeakMap(), map: new Map() };
|
|
5481
|
+
mV.set(v, mmW);
|
|
5482
|
+
checkMapLength(mV, 3, maxPrimitiveCacheLengths);
|
|
5483
|
+
}
|
|
5484
|
+
const mW = isObjW ? mmW.weakMap : mmW.map;
|
|
5485
|
+
let mmX = mW.get(w);
|
|
5486
|
+
if (mmX === undefined) {
|
|
5487
|
+
mmX = { weakMap: new WeakMap(), map: new Map() };
|
|
5488
|
+
mW.set(w, mmX);
|
|
5489
|
+
checkMapLength(mW, 4, maxPrimitiveCacheLengths);
|
|
5490
|
+
}
|
|
5491
|
+
return isObjX ? mmX.weakMap : mmX.map;
|
|
5492
|
+
}
|
|
5493
|
+
const f_ = function (s, t, u, v, w, x) {
|
|
5494
|
+
const mX = getRMap(s, t, u, v, w, x);
|
|
5495
|
+
let r;
|
|
5496
|
+
if (!mX.has(x)) {
|
|
5497
|
+
r = f(s, t, u, v, w, x);
|
|
5498
|
+
mX.set(x, r);
|
|
5499
|
+
checkMapLength(mX, 5, maxPrimitiveCacheLengths);
|
|
5500
|
+
}
|
|
5501
|
+
else {
|
|
5502
|
+
r = mX.get(x);
|
|
5503
|
+
}
|
|
5504
|
+
return r;
|
|
5505
|
+
};
|
|
5506
|
+
f_.mapS = mapS;
|
|
5507
|
+
f_.weakMapS = weakMapS;
|
|
5508
|
+
f_.clearCache = function () { mapS.clear(); };
|
|
5509
|
+
f_.addToCache = function (r, s, t, u, v, w, x) {
|
|
5510
|
+
const mX = getRMap(s, t, u, v, w, x);
|
|
5511
|
+
mX.set(x, r);
|
|
5512
|
+
checkMapLength(mX, 5, maxPrimitiveCacheLengths);
|
|
5513
|
+
};
|
|
5514
|
+
return f_;
|
|
5515
|
+
}
|
|
5516
|
+
/**
|
|
5517
|
+
* Memoize (by reference on the ordered input parameters) the given arity 7
|
|
5518
|
+
* function.
|
|
5519
|
+
*
|
|
5520
|
+
* * prefer most numerous parameters last in formal parameter list
|
|
5521
|
+
*/
|
|
5522
|
+
function memoize7(f, maxPrimitiveCacheLengths) {
|
|
5523
|
+
const weakMapS = new WeakMap();
|
|
5524
|
+
const mapS = new Map();
|
|
5525
|
+
function getRMap(s, t, u, v, w, x, y) {
|
|
5526
|
+
const isObjS = (typeof s === "object" || typeof s === 'function') && s !== null;
|
|
5527
|
+
const isObjT = (typeof t === "object" || typeof t === 'function') && t !== null;
|
|
5528
|
+
const isObjU = (typeof u === "object" || typeof u === 'function') && u !== null;
|
|
5529
|
+
const isObjV = (typeof v === "object" || typeof v === 'function') && v !== null;
|
|
5530
|
+
const isObjW = (typeof w === "object" || typeof w === 'function') && w !== null;
|
|
5531
|
+
const isObjX = (typeof x === "object" || typeof x === 'function') && x !== null;
|
|
5532
|
+
const isObjY = (typeof y === "object" || typeof y === 'function') && y !== null;
|
|
5533
|
+
let mS = isObjS ? weakMapS : mapS;
|
|
5534
|
+
let mmT = mS.get(s);
|
|
5535
|
+
if (mmT === undefined) {
|
|
5536
|
+
mmT = { weakMap: new WeakMap(), map: new Map() };
|
|
5537
|
+
mS.set(s, mmT);
|
|
5538
|
+
checkMapLength(mS, 0, maxPrimitiveCacheLengths);
|
|
5539
|
+
}
|
|
5540
|
+
const mT = isObjT ? mmT.weakMap : mmT.map;
|
|
5541
|
+
let mmU = mT.get(t);
|
|
5542
|
+
if (mmU === undefined) {
|
|
5543
|
+
mmU = { weakMap: new WeakMap(), map: new Map() };
|
|
5544
|
+
mT.set(t, mmU);
|
|
5545
|
+
checkMapLength(mT, 1, maxPrimitiveCacheLengths);
|
|
5546
|
+
}
|
|
5547
|
+
const mU = isObjU ? mmU.weakMap : mmU.map;
|
|
5548
|
+
let mmV = mU.get(u);
|
|
5549
|
+
if (mmV === undefined) {
|
|
5550
|
+
mmV = { weakMap: new WeakMap(), map: new Map() };
|
|
5551
|
+
mU.set(u, mmV);
|
|
5552
|
+
checkMapLength(mU, 2, maxPrimitiveCacheLengths);
|
|
5553
|
+
}
|
|
5554
|
+
const mV = isObjV ? mmV.weakMap : mmV.map;
|
|
5555
|
+
let mmW = mV.get(v);
|
|
5556
|
+
if (mmW === undefined) {
|
|
5557
|
+
mmW = { weakMap: new WeakMap(), map: new Map() };
|
|
5558
|
+
mV.set(v, mmW);
|
|
5559
|
+
checkMapLength(mV, 3, maxPrimitiveCacheLengths);
|
|
5560
|
+
}
|
|
5561
|
+
const mW = isObjW ? mmW.weakMap : mmW.map;
|
|
5562
|
+
let mmX = mW.get(w);
|
|
5563
|
+
if (mmX === undefined) {
|
|
5564
|
+
mmX = { weakMap: new WeakMap(), map: new Map() };
|
|
5565
|
+
mW.set(w, mmX);
|
|
5566
|
+
checkMapLength(mW, 4, maxPrimitiveCacheLengths);
|
|
5567
|
+
}
|
|
5568
|
+
const mX = isObjX ? mmX.weakMap : mmX.map;
|
|
5569
|
+
let mmY = mX.get(x);
|
|
5570
|
+
if (mmY === undefined) {
|
|
5571
|
+
mmY = { weakMap: new WeakMap(), map: new Map() };
|
|
5572
|
+
mX.set(x, mmY);
|
|
5573
|
+
checkMapLength(mX, 5, maxPrimitiveCacheLengths);
|
|
5574
|
+
}
|
|
5575
|
+
return isObjY ? mmY.weakMap : mmY.map;
|
|
5576
|
+
}
|
|
5577
|
+
const f_ = function (s, t, u, v, w, x, y) {
|
|
5578
|
+
const mY = getRMap(s, t, u, v, w, x, y);
|
|
5579
|
+
let r;
|
|
5580
|
+
if (!mY.has(y)) {
|
|
5581
|
+
r = f(s, t, u, v, w, x, y);
|
|
5582
|
+
mY.set(y, r);
|
|
5583
|
+
checkMapLength(mY, 6, maxPrimitiveCacheLengths);
|
|
5584
|
+
}
|
|
5585
|
+
else {
|
|
5586
|
+
r = mY.get(y);
|
|
5587
|
+
}
|
|
5588
|
+
return r;
|
|
5589
|
+
};
|
|
5590
|
+
f_.mapS = mapS;
|
|
5591
|
+
f_.weakMapS = weakMapS;
|
|
5592
|
+
f_.clearCache = function () { mapS.clear(); };
|
|
5593
|
+
f_.addToCache = function (r, s, t, u, v, w, x, y) {
|
|
5594
|
+
const mY = getRMap(s, t, u, v, w, x, y);
|
|
5595
|
+
mY.set(y, r);
|
|
5596
|
+
checkMapLength(mY, 6, maxPrimitiveCacheLengths);
|
|
5597
|
+
};
|
|
5598
|
+
return f_;
|
|
5599
|
+
}
|
|
5600
|
+
/**
|
|
5601
|
+
* Memoize (by reference on the ordered input parameters) the given arity 8
|
|
5602
|
+
* function.
|
|
5603
|
+
*
|
|
5604
|
+
* * prefer most numerous parameters last in formal parameter list
|
|
5605
|
+
*/
|
|
5606
|
+
function memoize8(f, maxPrimitiveCacheLengths) {
|
|
5607
|
+
const weakMapS = new WeakMap();
|
|
5608
|
+
const mapS = new Map();
|
|
5609
|
+
function getRMap(s, t, u, v, w, x, y, z) {
|
|
5610
|
+
const isObjS = (typeof s === "object" || typeof s === 'function') && s !== null;
|
|
5611
|
+
const isObjT = (typeof t === "object" || typeof t === 'function') && t !== null;
|
|
5612
|
+
const isObjU = (typeof u === "object" || typeof u === 'function') && u !== null;
|
|
5613
|
+
const isObjV = (typeof v === "object" || typeof v === 'function') && v !== null;
|
|
5614
|
+
const isObjW = (typeof w === "object" || typeof w === 'function') && w !== null;
|
|
5615
|
+
const isObjX = (typeof x === "object" || typeof x === 'function') && x !== null;
|
|
5616
|
+
const isObjY = (typeof y === "object" || typeof y === 'function') && y !== null;
|
|
5617
|
+
const isObjZ = (typeof z === "object" || typeof z === 'function') && z !== null;
|
|
5618
|
+
let mS = isObjS ? weakMapS : mapS;
|
|
5619
|
+
let mmT = mS.get(s);
|
|
5620
|
+
if (mmT === undefined) {
|
|
5621
|
+
mmT = { weakMap: new WeakMap(), map: new Map() };
|
|
5622
|
+
mS.set(s, mmT);
|
|
5623
|
+
checkMapLength(mS, 0, maxPrimitiveCacheLengths);
|
|
5624
|
+
}
|
|
5625
|
+
const mT = isObjT ? mmT.weakMap : mmT.map;
|
|
5626
|
+
let mmU = mT.get(t);
|
|
5627
|
+
if (mmU === undefined) {
|
|
5628
|
+
mmU = { weakMap: new WeakMap(), map: new Map() };
|
|
5629
|
+
mT.set(t, mmU);
|
|
5630
|
+
checkMapLength(mT, 1, maxPrimitiveCacheLengths);
|
|
5631
|
+
}
|
|
5632
|
+
const mU = isObjU ? mmU.weakMap : mmU.map;
|
|
5633
|
+
let mmV = mU.get(u);
|
|
5634
|
+
if (mmV === undefined) {
|
|
5635
|
+
mmV = { weakMap: new WeakMap(), map: new Map() };
|
|
5636
|
+
mU.set(u, mmV);
|
|
5637
|
+
checkMapLength(mU, 2, maxPrimitiveCacheLengths);
|
|
5638
|
+
}
|
|
5639
|
+
const mV = isObjV ? mmV.weakMap : mmV.map;
|
|
5640
|
+
let mmW = mV.get(v);
|
|
5641
|
+
if (mmW === undefined) {
|
|
5642
|
+
mmW = { weakMap: new WeakMap(), map: new Map() };
|
|
5643
|
+
mV.set(v, mmW);
|
|
5644
|
+
checkMapLength(mV, 3, maxPrimitiveCacheLengths);
|
|
5645
|
+
}
|
|
5646
|
+
const mW = isObjW ? mmW.weakMap : mmW.map;
|
|
5647
|
+
let mmX = mW.get(w);
|
|
5648
|
+
if (mmX === undefined) {
|
|
5649
|
+
mmX = { weakMap: new WeakMap(), map: new Map() };
|
|
5650
|
+
mW.set(w, mmX);
|
|
5651
|
+
checkMapLength(mW, 4, maxPrimitiveCacheLengths);
|
|
5652
|
+
}
|
|
5653
|
+
const mX = isObjX ? mmX.weakMap : mmX.map;
|
|
5654
|
+
let mmY = mX.get(x);
|
|
5655
|
+
if (mmY === undefined) {
|
|
5656
|
+
mmY = { weakMap: new WeakMap(), map: new Map() };
|
|
5657
|
+
mX.set(x, mmY);
|
|
5658
|
+
checkMapLength(mX, 5, maxPrimitiveCacheLengths);
|
|
5659
|
+
}
|
|
5660
|
+
const mY = isObjY ? mmY.weakMap : mmY.map;
|
|
5661
|
+
let mmZ = mY.get(y);
|
|
5662
|
+
if (mmZ === undefined) {
|
|
5663
|
+
mmZ = { weakMap: new WeakMap(), map: new Map() };
|
|
5664
|
+
mY.set(y, mmZ);
|
|
5665
|
+
checkMapLength(mY, 6, maxPrimitiveCacheLengths);
|
|
5666
|
+
}
|
|
5667
|
+
return isObjZ ? mmZ.weakMap : mmZ.map;
|
|
5668
|
+
}
|
|
5669
|
+
const f_ = function (s, t, u, v, w, x, y, z) {
|
|
5670
|
+
const mZ = getRMap(s, t, u, v, w, x, y, z);
|
|
5671
|
+
let r;
|
|
5672
|
+
if (!mZ.has(z)) {
|
|
5673
|
+
r = f(s, t, u, v, w, x, y, z);
|
|
5674
|
+
mZ.set(z, r);
|
|
5675
|
+
checkMapLength(mZ, 7, maxPrimitiveCacheLengths);
|
|
5676
|
+
}
|
|
5677
|
+
else {
|
|
5678
|
+
r = mZ.get(z);
|
|
5679
|
+
}
|
|
5680
|
+
return r;
|
|
5681
|
+
};
|
|
5682
|
+
f_.mapS = mapS;
|
|
5683
|
+
f_.weakMapS = weakMapS;
|
|
5684
|
+
f_.clearCache = function () { mapS.clear(); };
|
|
5685
|
+
f_.addToCache = function (r, s, t, u, v, w, x, y, z) {
|
|
5686
|
+
const mZ = getRMap(s, t, u, v, w, x, y, z);
|
|
5687
|
+
mZ.set(z, r);
|
|
5688
|
+
checkMapLength(mZ, 7, maxPrimitiveCacheLengths);
|
|
5689
|
+
};
|
|
5690
|
+
return f_;
|
|
5691
|
+
}
|
|
5692
|
+
const memoizeN = [
|
|
5693
|
+
memoize0,
|
|
5694
|
+
memoize1, memoize2, memoize3, memoize4,
|
|
5695
|
+
memoize5, memoize6, memoize7, memoize8
|
|
5696
|
+
];
|
|
5697
|
+
/**
|
|
5698
|
+
* Memoize (by reference on the ordered input parameters) the given function
|
|
5699
|
+
* up to arity 8.
|
|
5700
|
+
*
|
|
5701
|
+
* * prefer most numerous parameters last in formal parameter list
|
|
5702
|
+
*
|
|
5703
|
+
* @param f the function to memoize
|
|
5704
|
+
* @param maxPrimitiveCacheLengths if not `undefined` then the size of caching
|
|
5705
|
+
* maps having primitive values is limited to this value (in which case it is
|
|
5706
|
+
* a Map (not a WeakMap)). The value corresponds to the index of the function
|
|
5707
|
+
* parameter, starting from 0.
|
|
5708
|
+
*/
|
|
5709
|
+
function memoize(f, maxPrimitiveCacheLengths, logCacheMissHit = false) {
|
|
5710
|
+
const len = f.length;
|
|
5711
|
+
if (len > 8) {
|
|
5712
|
+
throw new Error('A maximum of 8 formal parameters are supported');
|
|
5713
|
+
}
|
|
5714
|
+
const memoize_ = memoizeN[len];
|
|
5715
|
+
//@ts-ignore
|
|
5716
|
+
return memoize_(f, maxPrimitiveCacheLengths, logCacheMissHit);
|
|
5153
5717
|
}
|
|
5154
5718
|
|
|
5155
5719
|
//# sourceMappingURL=memoize.js.map
|
|
@@ -10478,10 +11042,37 @@ function getBoundingBox(ps) {
|
|
|
10478
11042
|
}
|
|
10479
11043
|
|
|
10480
11044
|
//# sourceMappingURL=get-bounding-box.js.map
|
|
11045
|
+
;// ./node_modules/flo-boolean/node_modules/flo-memoize/node/memoize.js
|
|
11046
|
+
/**
|
|
11047
|
+
* Memoize (by reference on the input parameter) the given arity 1 function.
|
|
11048
|
+
*
|
|
11049
|
+
* * the input parameter must be an `object` (so it can be used as a key to
|
|
11050
|
+
* `WeakMap` and thus garbage collected later; this is especially important
|
|
11051
|
+
* in functional programming where a lot of garbage collection takes place;
|
|
11052
|
+
*
|
|
11053
|
+
* * use `memoizePrimitive` instead if it is not important that the keys
|
|
11054
|
+
* will *never* be garbage collected
|
|
11055
|
+
*/
|
|
11056
|
+
function memoize_memoize(f) {
|
|
11057
|
+
const results = new WeakMap();
|
|
11058
|
+
return function (t) {
|
|
11059
|
+
let r = results.get(t);
|
|
11060
|
+
if (r !== undefined) {
|
|
11061
|
+
//console.log('cache hit');
|
|
11062
|
+
return r;
|
|
11063
|
+
}
|
|
11064
|
+
//console.log('cache miss');
|
|
11065
|
+
r = f(t);
|
|
11066
|
+
results.set(t, r);
|
|
11067
|
+
return r;
|
|
11068
|
+
};
|
|
11069
|
+
}
|
|
11070
|
+
|
|
11071
|
+
//# sourceMappingURL=memoize.js.map
|
|
10481
11072
|
;// ./node_modules/flo-boolean/node/get-bounding-box-.js
|
|
10482
11073
|
|
|
10483
11074
|
|
|
10484
|
-
const getBoundingBox$ =
|
|
11075
|
+
const getBoundingBox$ = memoize_memoize(getBoundingBox);
|
|
10485
11076
|
|
|
10486
11077
|
//# sourceMappingURL=get-bounding-box-.js.map
|
|
10487
11078
|
;// ./node_modules/flo-bezier3/node/global-properties/bounds/get-bounds.js
|
|
@@ -10555,7 +11146,7 @@ function getBounds(ps) {
|
|
|
10555
11146
|
;// ./node_modules/flo-boolean/node/get-bounds-.js
|
|
10556
11147
|
|
|
10557
11148
|
|
|
10558
|
-
const getBounds$ =
|
|
11149
|
+
const getBounds$ = memoize_memoize(getBounds);
|
|
10559
11150
|
|
|
10560
11151
|
//# sourceMappingURL=get-bounds-.js.map
|
|
10561
11152
|
;// ./node_modules/flo-boolean/node/calc-paths/get-shape-bounds.js
|
|
@@ -21912,7 +22503,7 @@ function getExcessiveCurvatures(expMax, loops) {
|
|
|
21912
22503
|
/**
|
|
21913
22504
|
*
|
|
21914
22505
|
*/
|
|
21915
|
-
const get_min_y_getMinY =
|
|
22506
|
+
const get_min_y_getMinY = memoize_memoize(function (loop) {
|
|
21916
22507
|
const { curves } = loop;
|
|
21917
22508
|
let bestY = getYBoundsTight(curves[0].ps).minY;
|
|
21918
22509
|
let bestCurve = curves[0];
|
|
@@ -22710,7 +23301,7 @@ function scrambleLoops(loops, maxBitLength, expMax, mult = 0.02) {
|
|
|
22710
23301
|
* Returns the maximum control point coordinate value (x or y) within any loop.
|
|
22711
23302
|
* @param loops The array of loops
|
|
22712
23303
|
*/
|
|
22713
|
-
const getMaxCoordinate =
|
|
23304
|
+
const getMaxCoordinate = memoize_memoize((loops) => {
|
|
22714
23305
|
let max = 0;
|
|
22715
23306
|
for (const loop of loops) {
|
|
22716
23307
|
for (const ps of loop) {
|