@mark1russell7/vex-domains 0.6.0 → 0.7.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/README.md +18 -4
- package/build/index.d.ts +58 -3
- package/build/index.d.ts.map +1 -1
- package/build/index.js +494 -75
- package/build/index.js.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +2 -1
- package/src/ndvector.ts +11 -1
- package/src/scalars.ts +47 -28
- package/src/text.ts +8 -7
- package/src/vec2.ts +48 -42
- package/src/xy.ts +74 -0
package/build/index.js
CHANGED
|
@@ -177,25 +177,39 @@ const Vec2Domain = defineDomain({
|
|
|
177
177
|
return new Vec2(typeof x === "number" ? x : NaN, typeof y === "number" ? y : NaN);
|
|
178
178
|
},
|
|
179
179
|
ops: {
|
|
180
|
+
x: {
|
|
181
|
+
fn: (v) => v.x,
|
|
182
|
+
params: [],
|
|
183
|
+
returns: "number"
|
|
184
|
+
},
|
|
185
|
+
y: {
|
|
186
|
+
fn: (v) => v.y,
|
|
187
|
+
params: [],
|
|
188
|
+
returns: "number"
|
|
189
|
+
},
|
|
180
190
|
add: {
|
|
181
191
|
laws: ["commutative", "associative"],
|
|
182
192
|
identity: () => Vec2.zero,
|
|
183
193
|
liftScalar: true,
|
|
184
|
-
params: ["domain"]
|
|
194
|
+
params: ["domain"],
|
|
195
|
+
returns: "domain"
|
|
185
196
|
},
|
|
186
197
|
subtract: {
|
|
187
198
|
liftScalar: true,
|
|
188
|
-
params: ["domain"]
|
|
199
|
+
params: ["domain"],
|
|
200
|
+
returns: "domain"
|
|
189
201
|
},
|
|
190
202
|
multiply: {
|
|
191
203
|
laws: ["commutative", "associative"],
|
|
192
204
|
identity: () => Vec2.one,
|
|
193
205
|
liftScalar: true,
|
|
194
|
-
params: ["domain"]
|
|
206
|
+
params: ["domain"],
|
|
207
|
+
returns: "domain"
|
|
195
208
|
},
|
|
196
209
|
divide: {
|
|
197
210
|
liftScalar: true,
|
|
198
|
-
params: ["domain"]
|
|
211
|
+
params: ["domain"],
|
|
212
|
+
returns: "domain"
|
|
199
213
|
},
|
|
200
214
|
min: {
|
|
201
215
|
laws: [
|
|
@@ -204,7 +218,8 @@ const Vec2Domain = defineDomain({
|
|
|
204
218
|
"idempotent"
|
|
205
219
|
],
|
|
206
220
|
liftScalar: true,
|
|
207
|
-
params: ["domain"]
|
|
221
|
+
params: ["domain"],
|
|
222
|
+
returns: "domain"
|
|
208
223
|
},
|
|
209
224
|
max: {
|
|
210
225
|
laws: [
|
|
@@ -213,47 +228,331 @@ const Vec2Domain = defineDomain({
|
|
|
213
228
|
"idempotent"
|
|
214
229
|
],
|
|
215
230
|
liftScalar: true,
|
|
216
|
-
params: ["domain"]
|
|
231
|
+
params: ["domain"],
|
|
232
|
+
returns: "domain"
|
|
233
|
+
},
|
|
234
|
+
scale: {
|
|
235
|
+
params: ["number"],
|
|
236
|
+
returns: "domain"
|
|
237
|
+
},
|
|
238
|
+
negate: {
|
|
239
|
+
params: [],
|
|
240
|
+
returns: "domain"
|
|
241
|
+
},
|
|
242
|
+
halve: {
|
|
243
|
+
params: [],
|
|
244
|
+
returns: "domain"
|
|
245
|
+
},
|
|
246
|
+
abs: {
|
|
247
|
+
params: [],
|
|
248
|
+
returns: "domain"
|
|
249
|
+
},
|
|
250
|
+
round: {
|
|
251
|
+
params: [],
|
|
252
|
+
returns: "domain"
|
|
253
|
+
},
|
|
254
|
+
floor: {
|
|
255
|
+
params: [],
|
|
256
|
+
returns: "domain"
|
|
257
|
+
},
|
|
258
|
+
ceil: {
|
|
259
|
+
params: [],
|
|
260
|
+
returns: "domain"
|
|
261
|
+
},
|
|
262
|
+
clamp: {
|
|
263
|
+
params: ["number", "number"],
|
|
264
|
+
returns: "domain"
|
|
265
|
+
},
|
|
266
|
+
swap: {
|
|
267
|
+
params: [],
|
|
268
|
+
returns: "domain"
|
|
269
|
+
},
|
|
270
|
+
rotate: {
|
|
271
|
+
params: ["number"],
|
|
272
|
+
returns: "domain"
|
|
273
|
+
},
|
|
274
|
+
normalize: {
|
|
275
|
+
params: [],
|
|
276
|
+
returns: "domain"
|
|
277
|
+
},
|
|
278
|
+
lerp: {
|
|
279
|
+
params: ["domain", "number"],
|
|
280
|
+
returns: "domain"
|
|
281
|
+
},
|
|
282
|
+
length: {
|
|
283
|
+
params: [],
|
|
284
|
+
returns: "number"
|
|
285
|
+
},
|
|
286
|
+
lengthSq: {
|
|
287
|
+
params: [],
|
|
288
|
+
returns: "number"
|
|
289
|
+
},
|
|
290
|
+
distance: {
|
|
291
|
+
params: ["domain"],
|
|
292
|
+
returns: "number"
|
|
217
293
|
},
|
|
218
|
-
scale: { params: ["number"] },
|
|
219
|
-
negate: {},
|
|
220
|
-
halve: {},
|
|
221
|
-
abs: {},
|
|
222
|
-
round: {},
|
|
223
|
-
floor: {},
|
|
224
|
-
ceil: {},
|
|
225
|
-
clamp: { params: ["number", "number"] },
|
|
226
|
-
swap: {},
|
|
227
|
-
rotate: { params: ["number"] },
|
|
228
|
-
normalize: {},
|
|
229
|
-
lerp: { params: ["domain", "number"] },
|
|
230
|
-
length: {},
|
|
231
|
-
lengthSq: {},
|
|
232
|
-
distance: { params: ["domain"] },
|
|
233
294
|
dot: {
|
|
234
295
|
laws: ["commutative"],
|
|
235
|
-
params: ["domain"]
|
|
296
|
+
params: ["domain"],
|
|
297
|
+
returns: "number"
|
|
298
|
+
},
|
|
299
|
+
cross: {
|
|
300
|
+
params: ["domain"],
|
|
301
|
+
returns: "number"
|
|
302
|
+
},
|
|
303
|
+
angle: {
|
|
304
|
+
params: [],
|
|
305
|
+
returns: "number"
|
|
306
|
+
},
|
|
307
|
+
area: {
|
|
308
|
+
params: [],
|
|
309
|
+
returns: "number"
|
|
310
|
+
},
|
|
311
|
+
sum: {
|
|
312
|
+
params: [],
|
|
313
|
+
returns: "number"
|
|
314
|
+
},
|
|
315
|
+
minComponent: {
|
|
316
|
+
params: [],
|
|
317
|
+
returns: "number"
|
|
318
|
+
},
|
|
319
|
+
maxComponent: {
|
|
320
|
+
params: [],
|
|
321
|
+
returns: "number"
|
|
236
322
|
},
|
|
237
|
-
cross: { params: ["domain"] },
|
|
238
|
-
angle: {},
|
|
239
|
-
area: {},
|
|
240
|
-
sum: {},
|
|
241
|
-
minComponent: {},
|
|
242
|
-
maxComponent: {},
|
|
243
323
|
equals: {
|
|
244
324
|
laws: ["commutative"],
|
|
245
|
-
params: ["domain"]
|
|
325
|
+
params: ["domain"],
|
|
326
|
+
returns: "boolean"
|
|
327
|
+
},
|
|
328
|
+
anyNonPositive: {
|
|
329
|
+
params: [],
|
|
330
|
+
returns: "boolean"
|
|
331
|
+
},
|
|
332
|
+
allPositive: {
|
|
333
|
+
params: [],
|
|
334
|
+
returns: "boolean"
|
|
335
|
+
},
|
|
336
|
+
anyNegative: {
|
|
337
|
+
params: [],
|
|
338
|
+
returns: "boolean"
|
|
339
|
+
},
|
|
340
|
+
allNonNegative: {
|
|
341
|
+
params: [],
|
|
342
|
+
returns: "boolean"
|
|
343
|
+
},
|
|
344
|
+
anyZero: {
|
|
345
|
+
params: [],
|
|
346
|
+
returns: "boolean"
|
|
347
|
+
},
|
|
348
|
+
allZero: {
|
|
349
|
+
params: [],
|
|
350
|
+
returns: "boolean"
|
|
351
|
+
},
|
|
352
|
+
anyLessThan: {
|
|
353
|
+
params: ["number"],
|
|
354
|
+
returns: "boolean"
|
|
355
|
+
},
|
|
356
|
+
allLessThan: {
|
|
357
|
+
params: ["number"],
|
|
358
|
+
returns: "boolean"
|
|
359
|
+
},
|
|
360
|
+
anyGreaterThan: {
|
|
361
|
+
params: ["number"],
|
|
362
|
+
returns: "boolean"
|
|
363
|
+
},
|
|
364
|
+
allGreaterThan: {
|
|
365
|
+
params: ["number"],
|
|
366
|
+
returns: "boolean"
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
});
|
|
370
|
+
//#endregion
|
|
371
|
+
//#region src/xy.ts
|
|
372
|
+
/**
|
|
373
|
+
* The domain of 2D vectors as plain data: an object with the two number fields `x` and `y` and no other field. The op
|
|
374
|
+
* `xy` of `NumDomain` makes one. No op lifts a number, so each op has a static site in a module. Put `XYDomain` before
|
|
375
|
+
* `NumRecordDomain`, because a record of numbers accepts the same objects.
|
|
376
|
+
*/
|
|
377
|
+
const XYDomain = defineDomain({
|
|
378
|
+
name: "XY",
|
|
379
|
+
is: (u) => typeof u === "object" && u !== null && [Object.prototype, null].includes(Object.getPrototypeOf(u)) && Object.keys(u).length === 2 && typeof u.x === "number" && typeof u.y === "number",
|
|
380
|
+
valid: (v) => Number.isFinite(v.x) && Number.isFinite(v.y),
|
|
381
|
+
show: (v) => `(${v.x}, ${v.y})`,
|
|
382
|
+
samples: () => [
|
|
383
|
+
{
|
|
384
|
+
x: 0,
|
|
385
|
+
y: 0
|
|
386
|
+
},
|
|
387
|
+
{
|
|
388
|
+
x: 1.5,
|
|
389
|
+
y: -2
|
|
390
|
+
},
|
|
391
|
+
{
|
|
392
|
+
x: 3,
|
|
393
|
+
y: 4
|
|
394
|
+
}
|
|
395
|
+
],
|
|
396
|
+
ops: {
|
|
397
|
+
x: {
|
|
398
|
+
fn: (a) => a.x,
|
|
399
|
+
params: [],
|
|
400
|
+
returns: "number"
|
|
401
|
+
},
|
|
402
|
+
y: {
|
|
403
|
+
fn: (a) => a.y,
|
|
404
|
+
params: [],
|
|
405
|
+
returns: "number"
|
|
406
|
+
},
|
|
407
|
+
add: {
|
|
408
|
+
fn: (a, b) => ({
|
|
409
|
+
x: a.x + b.x,
|
|
410
|
+
y: a.y + b.y
|
|
411
|
+
}),
|
|
412
|
+
laws: ["commutative", "associative"],
|
|
413
|
+
identity: () => ({
|
|
414
|
+
x: 0,
|
|
415
|
+
y: 0
|
|
416
|
+
}),
|
|
417
|
+
params: ["domain"],
|
|
418
|
+
returns: "domain"
|
|
419
|
+
},
|
|
420
|
+
subtract: {
|
|
421
|
+
fn: (a, b) => ({
|
|
422
|
+
x: a.x - b.x,
|
|
423
|
+
y: a.y - b.y
|
|
424
|
+
}),
|
|
425
|
+
params: ["domain"],
|
|
426
|
+
returns: "domain"
|
|
427
|
+
},
|
|
428
|
+
multiply: {
|
|
429
|
+
fn: (a, b) => ({
|
|
430
|
+
x: a.x * b.x,
|
|
431
|
+
y: a.y * b.y
|
|
432
|
+
}),
|
|
433
|
+
laws: ["commutative", "associative"],
|
|
434
|
+
identity: () => ({
|
|
435
|
+
x: 1,
|
|
436
|
+
y: 1
|
|
437
|
+
}),
|
|
438
|
+
params: ["domain"],
|
|
439
|
+
returns: "domain"
|
|
440
|
+
},
|
|
441
|
+
divide: {
|
|
442
|
+
fn: (a, b) => ({
|
|
443
|
+
x: a.x / b.x,
|
|
444
|
+
y: a.y / b.y
|
|
445
|
+
}),
|
|
446
|
+
params: ["domain"],
|
|
447
|
+
returns: "domain"
|
|
448
|
+
},
|
|
449
|
+
min: {
|
|
450
|
+
fn: (a, b) => ({
|
|
451
|
+
x: Math.min(a.x, b.x),
|
|
452
|
+
y: Math.min(a.y, b.y)
|
|
453
|
+
}),
|
|
454
|
+
laws: [
|
|
455
|
+
"commutative",
|
|
456
|
+
"associative",
|
|
457
|
+
"idempotent"
|
|
458
|
+
],
|
|
459
|
+
params: ["domain"],
|
|
460
|
+
returns: "domain"
|
|
461
|
+
},
|
|
462
|
+
max: {
|
|
463
|
+
fn: (a, b) => ({
|
|
464
|
+
x: Math.max(a.x, b.x),
|
|
465
|
+
y: Math.max(a.y, b.y)
|
|
466
|
+
}),
|
|
467
|
+
laws: [
|
|
468
|
+
"commutative",
|
|
469
|
+
"associative",
|
|
470
|
+
"idempotent"
|
|
471
|
+
],
|
|
472
|
+
params: ["domain"],
|
|
473
|
+
returns: "domain"
|
|
474
|
+
},
|
|
475
|
+
scale: {
|
|
476
|
+
fn: (a, k) => ({
|
|
477
|
+
x: a.x * k,
|
|
478
|
+
y: a.y * k
|
|
479
|
+
}),
|
|
480
|
+
params: ["number"],
|
|
481
|
+
returns: "domain"
|
|
482
|
+
},
|
|
483
|
+
negate: {
|
|
484
|
+
fn: (a) => ({
|
|
485
|
+
x: -a.x,
|
|
486
|
+
y: -a.y
|
|
487
|
+
}),
|
|
488
|
+
params: [],
|
|
489
|
+
returns: "domain"
|
|
490
|
+
},
|
|
491
|
+
abs: {
|
|
492
|
+
fn: (a) => ({
|
|
493
|
+
x: Math.abs(a.x),
|
|
494
|
+
y: Math.abs(a.y)
|
|
495
|
+
}),
|
|
496
|
+
params: [],
|
|
497
|
+
returns: "domain"
|
|
498
|
+
},
|
|
499
|
+
floor: {
|
|
500
|
+
fn: (a) => ({
|
|
501
|
+
x: Math.floor(a.x),
|
|
502
|
+
y: Math.floor(a.y)
|
|
503
|
+
}),
|
|
504
|
+
params: [],
|
|
505
|
+
returns: "domain"
|
|
506
|
+
},
|
|
507
|
+
ceil: {
|
|
508
|
+
fn: (a) => ({
|
|
509
|
+
x: Math.ceil(a.x),
|
|
510
|
+
y: Math.ceil(a.y)
|
|
511
|
+
}),
|
|
512
|
+
params: [],
|
|
513
|
+
returns: "domain"
|
|
514
|
+
},
|
|
515
|
+
round: {
|
|
516
|
+
fn: (a) => ({
|
|
517
|
+
x: Math.round(a.x),
|
|
518
|
+
y: Math.round(a.y)
|
|
519
|
+
}),
|
|
520
|
+
params: [],
|
|
521
|
+
returns: "domain"
|
|
522
|
+
},
|
|
523
|
+
dot: {
|
|
524
|
+
fn: (a, b) => a.x * b.x + a.y * b.y,
|
|
525
|
+
laws: ["commutative"],
|
|
526
|
+
params: ["domain"],
|
|
527
|
+
returns: "number"
|
|
528
|
+
},
|
|
529
|
+
length: {
|
|
530
|
+
fn: (a) => Math.hypot(a.x, a.y),
|
|
531
|
+
params: [],
|
|
532
|
+
returns: "number"
|
|
533
|
+
},
|
|
534
|
+
distance: {
|
|
535
|
+
fn: (a, b) => Math.hypot(a.x - b.x, a.y - b.y),
|
|
536
|
+
laws: ["commutative"],
|
|
537
|
+
params: ["domain"],
|
|
538
|
+
returns: "number"
|
|
539
|
+
},
|
|
540
|
+
area: {
|
|
541
|
+
fn: (a) => a.x * a.y,
|
|
542
|
+
params: [],
|
|
543
|
+
returns: "number"
|
|
246
544
|
},
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
545
|
+
sum: {
|
|
546
|
+
fn: (a) => a.x + a.y,
|
|
547
|
+
params: [],
|
|
548
|
+
returns: "number"
|
|
549
|
+
},
|
|
550
|
+
equals: {
|
|
551
|
+
fn: (a, b) => a.x === b.x && a.y === b.y,
|
|
552
|
+
laws: ["commutative"],
|
|
553
|
+
params: ["domain"],
|
|
554
|
+
returns: "boolean"
|
|
555
|
+
}
|
|
257
556
|
}
|
|
258
557
|
});
|
|
259
558
|
//#endregion
|
|
@@ -328,6 +627,14 @@ var NDVector = class NDVector {
|
|
|
328
627
|
multiply(o) {
|
|
329
628
|
return this.#combine(o, (a, b) => a * b);
|
|
330
629
|
}
|
|
630
|
+
/** The component-wise minimum. A component that one vector does not have counts as 0. */
|
|
631
|
+
min(o) {
|
|
632
|
+
return this.#combine(o, (a, b) => Math.min(a, b));
|
|
633
|
+
}
|
|
634
|
+
/** The component-wise maximum. A component that one vector does not have counts as 0. */
|
|
635
|
+
max(o) {
|
|
636
|
+
return this.#combine(o, (a, b) => Math.max(a, b));
|
|
637
|
+
}
|
|
331
638
|
/** Of each component, the value of this vector if it is not 0, else the value of `o`. */
|
|
332
639
|
mergePreferNonZero(o) {
|
|
333
640
|
return this.#combine(o, (a, b) => a !== 0 ? a : b);
|
|
@@ -382,6 +689,22 @@ const ndOps = {
|
|
|
382
689
|
laws: ["commutative", "associative"],
|
|
383
690
|
params: ["domain"]
|
|
384
691
|
},
|
|
692
|
+
min: {
|
|
693
|
+
laws: [
|
|
694
|
+
"commutative",
|
|
695
|
+
"associative",
|
|
696
|
+
"idempotent"
|
|
697
|
+
],
|
|
698
|
+
params: ["domain"]
|
|
699
|
+
},
|
|
700
|
+
max: {
|
|
701
|
+
laws: [
|
|
702
|
+
"commutative",
|
|
703
|
+
"associative",
|
|
704
|
+
"idempotent"
|
|
705
|
+
],
|
|
706
|
+
params: ["domain"]
|
|
707
|
+
},
|
|
385
708
|
mergePreferNonZero: {
|
|
386
709
|
laws: ["associative", "idempotent"],
|
|
387
710
|
params: ["domain"]
|
|
@@ -597,6 +920,7 @@ const DateDomain = defineDomain({
|
|
|
597
920
|
const NumDomain = defineDomain({
|
|
598
921
|
name: "Num",
|
|
599
922
|
is: (u) => typeof u === "number",
|
|
923
|
+
primitive: "number",
|
|
600
924
|
valid: (n) => Number.isFinite(n),
|
|
601
925
|
show: (n) => String(n),
|
|
602
926
|
ops: {
|
|
@@ -604,29 +928,35 @@ const NumDomain = defineDomain({
|
|
|
604
928
|
fn: (a, b) => a + b,
|
|
605
929
|
laws: ["commutative", "associative"],
|
|
606
930
|
identity: () => 0,
|
|
607
|
-
params: ["number"]
|
|
931
|
+
params: ["number"],
|
|
932
|
+
returns: "number"
|
|
608
933
|
},
|
|
609
934
|
subtract: {
|
|
610
935
|
fn: (a, b) => a - b,
|
|
611
|
-
params: ["number"]
|
|
936
|
+
params: ["number"],
|
|
937
|
+
returns: "number"
|
|
612
938
|
},
|
|
613
939
|
multiply: {
|
|
614
940
|
fn: (a, b) => a * b,
|
|
615
941
|
laws: ["commutative", "associative"],
|
|
616
942
|
identity: () => 1,
|
|
617
|
-
params: ["number"]
|
|
943
|
+
params: ["number"],
|
|
944
|
+
returns: "number"
|
|
618
945
|
},
|
|
619
946
|
divide: {
|
|
620
947
|
fn: (a, b) => a / b,
|
|
621
|
-
params: ["number"]
|
|
948
|
+
params: ["number"],
|
|
949
|
+
returns: "number"
|
|
622
950
|
},
|
|
623
951
|
mod: {
|
|
624
952
|
fn: (a, b) => a % b,
|
|
625
|
-
params: ["number"]
|
|
953
|
+
params: ["number"],
|
|
954
|
+
returns: "number"
|
|
626
955
|
},
|
|
627
956
|
pow: {
|
|
628
957
|
fn: (a, b) => a ** b,
|
|
629
|
-
params: ["number"]
|
|
958
|
+
params: ["number"],
|
|
959
|
+
returns: "number"
|
|
630
960
|
},
|
|
631
961
|
min: {
|
|
632
962
|
fn: (a, b) => Math.min(a, b),
|
|
@@ -635,7 +965,8 @@ const NumDomain = defineDomain({
|
|
|
635
965
|
"associative",
|
|
636
966
|
"idempotent"
|
|
637
967
|
],
|
|
638
|
-
params: ["number"]
|
|
968
|
+
params: ["number"],
|
|
969
|
+
returns: "number"
|
|
639
970
|
},
|
|
640
971
|
max: {
|
|
641
972
|
fn: (a, b) => Math.max(a, b),
|
|
@@ -644,45 +975,109 @@ const NumDomain = defineDomain({
|
|
|
644
975
|
"associative",
|
|
645
976
|
"idempotent"
|
|
646
977
|
],
|
|
647
|
-
params: ["number"]
|
|
978
|
+
params: ["number"],
|
|
979
|
+
returns: "number"
|
|
648
980
|
},
|
|
649
981
|
clamp: {
|
|
650
982
|
fn: (a, lo, hi) => Math.min(hi, Math.max(lo, a)),
|
|
651
|
-
params: ["number", "number"]
|
|
983
|
+
params: ["number", "number"],
|
|
984
|
+
returns: "number"
|
|
985
|
+
},
|
|
986
|
+
abs: {
|
|
987
|
+
fn: (a) => Math.abs(a),
|
|
988
|
+
returns: "number"
|
|
989
|
+
},
|
|
990
|
+
negate: {
|
|
991
|
+
fn: (a) => -a,
|
|
992
|
+
returns: "number"
|
|
993
|
+
},
|
|
994
|
+
sqrt: {
|
|
995
|
+
fn: (a) => Math.sqrt(a),
|
|
996
|
+
returns: "number"
|
|
997
|
+
},
|
|
998
|
+
ln: {
|
|
999
|
+
fn: (a) => Math.log(a),
|
|
1000
|
+
returns: "number"
|
|
1001
|
+
},
|
|
1002
|
+
exp: {
|
|
1003
|
+
fn: (a) => Math.exp(a),
|
|
1004
|
+
returns: "number"
|
|
1005
|
+
},
|
|
1006
|
+
log10: {
|
|
1007
|
+
fn: (a) => Math.log10(a),
|
|
1008
|
+
returns: "number"
|
|
1009
|
+
},
|
|
1010
|
+
sin: {
|
|
1011
|
+
fn: (a) => Math.sin(a),
|
|
1012
|
+
returns: "number"
|
|
1013
|
+
},
|
|
1014
|
+
cos: {
|
|
1015
|
+
fn: (a) => Math.cos(a),
|
|
1016
|
+
returns: "number"
|
|
1017
|
+
},
|
|
1018
|
+
asin: {
|
|
1019
|
+
fn: (a) => Math.asin(a),
|
|
1020
|
+
returns: "number"
|
|
1021
|
+
},
|
|
1022
|
+
hypot: {
|
|
1023
|
+
fn: (a, b) => Math.hypot(a, b),
|
|
1024
|
+
laws: ["commutative"],
|
|
1025
|
+
params: ["number"],
|
|
1026
|
+
returns: "number"
|
|
652
1027
|
},
|
|
653
|
-
abs: { fn: (a) => Math.abs(a) },
|
|
654
|
-
negate: { fn: (a) => -a },
|
|
655
|
-
sqrt: { fn: (a) => Math.sqrt(a) },
|
|
656
|
-
ln: { fn: (a) => Math.log(a) },
|
|
657
|
-
exp: { fn: (a) => Math.exp(a) },
|
|
658
|
-
log10: { fn: (a) => Math.log10(a) },
|
|
659
1028
|
date: {
|
|
660
1029
|
fn: (year, month, day) => LocalDate.of(year, month, day),
|
|
661
1030
|
params: ["number", "number"]
|
|
662
1031
|
},
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
1032
|
+
vec2: {
|
|
1033
|
+
fn: (x, y) => new Vec2(x, y),
|
|
1034
|
+
params: ["number"]
|
|
1035
|
+
},
|
|
1036
|
+
xy: {
|
|
1037
|
+
fn: (x, y) => ({
|
|
1038
|
+
x,
|
|
1039
|
+
y
|
|
1040
|
+
}),
|
|
1041
|
+
params: ["number"],
|
|
1042
|
+
returns: "domain:XY"
|
|
1043
|
+
},
|
|
1044
|
+
floor: {
|
|
1045
|
+
fn: (a) => Math.floor(a),
|
|
1046
|
+
returns: "number"
|
|
1047
|
+
},
|
|
1048
|
+
ceil: {
|
|
1049
|
+
fn: (a) => Math.ceil(a),
|
|
1050
|
+
returns: "number"
|
|
1051
|
+
},
|
|
1052
|
+
round: {
|
|
1053
|
+
fn: (a) => Math.round(a),
|
|
1054
|
+
returns: "number"
|
|
1055
|
+
},
|
|
666
1056
|
gt: {
|
|
667
1057
|
fn: (a, b) => a > b,
|
|
668
|
-
params: ["number"]
|
|
1058
|
+
params: ["number"],
|
|
1059
|
+
returns: "boolean"
|
|
669
1060
|
},
|
|
670
1061
|
gte: {
|
|
671
1062
|
fn: (a, b) => a >= b,
|
|
672
|
-
params: ["number"]
|
|
1063
|
+
params: ["number"],
|
|
1064
|
+
returns: "boolean"
|
|
673
1065
|
},
|
|
674
1066
|
lt: {
|
|
675
1067
|
fn: (a, b) => a < b,
|
|
676
|
-
params: ["number"]
|
|
1068
|
+
params: ["number"],
|
|
1069
|
+
returns: "boolean"
|
|
677
1070
|
},
|
|
678
1071
|
lte: {
|
|
679
1072
|
fn: (a, b) => a <= b,
|
|
680
|
-
params: ["number"]
|
|
1073
|
+
params: ["number"],
|
|
1074
|
+
returns: "boolean"
|
|
681
1075
|
},
|
|
682
1076
|
eq: {
|
|
683
1077
|
fn: (a, b) => a === b,
|
|
684
1078
|
laws: ["commutative"],
|
|
685
|
-
params: ["number"]
|
|
1079
|
+
params: ["number"],
|
|
1080
|
+
returns: "boolean"
|
|
686
1081
|
}
|
|
687
1082
|
}
|
|
688
1083
|
});
|
|
@@ -690,6 +1085,7 @@ const NumDomain = defineDomain({
|
|
|
690
1085
|
const BoolDomain = defineDomain({
|
|
691
1086
|
name: "Bool",
|
|
692
1087
|
is: (u) => typeof u === "boolean",
|
|
1088
|
+
primitive: "boolean",
|
|
693
1089
|
show: (b) => String(b),
|
|
694
1090
|
ops: {
|
|
695
1091
|
and: {
|
|
@@ -700,7 +1096,8 @@ const BoolDomain = defineDomain({
|
|
|
700
1096
|
"idempotent"
|
|
701
1097
|
],
|
|
702
1098
|
identity: () => true,
|
|
703
|
-
params: ["boolean"]
|
|
1099
|
+
params: ["boolean"],
|
|
1100
|
+
returns: "boolean"
|
|
704
1101
|
},
|
|
705
1102
|
or: {
|
|
706
1103
|
fn: (a, b) => a || b,
|
|
@@ -710,19 +1107,25 @@ const BoolDomain = defineDomain({
|
|
|
710
1107
|
"idempotent"
|
|
711
1108
|
],
|
|
712
1109
|
identity: () => false,
|
|
713
|
-
params: ["boolean"]
|
|
1110
|
+
params: ["boolean"],
|
|
1111
|
+
returns: "boolean"
|
|
714
1112
|
},
|
|
715
1113
|
xor: {
|
|
716
1114
|
fn: (a, b) => a !== b,
|
|
717
1115
|
laws: ["commutative", "associative"],
|
|
718
1116
|
identity: () => false,
|
|
719
|
-
params: ["boolean"]
|
|
1117
|
+
params: ["boolean"],
|
|
1118
|
+
returns: "boolean"
|
|
1119
|
+
},
|
|
1120
|
+
not: {
|
|
1121
|
+
fn: (a) => !a,
|
|
1122
|
+
returns: "boolean"
|
|
720
1123
|
},
|
|
721
|
-
not: { fn: (a) => !a },
|
|
722
1124
|
eq: {
|
|
723
1125
|
fn: (a, b) => a === b,
|
|
724
1126
|
laws: ["commutative"],
|
|
725
|
-
params: ["boolean"]
|
|
1127
|
+
params: ["boolean"],
|
|
1128
|
+
returns: "boolean"
|
|
726
1129
|
}
|
|
727
1130
|
}
|
|
728
1131
|
});
|
|
@@ -741,24 +1144,40 @@ const textOf = (u) => typeof u === "object" && u !== null && Object.getPrototype
|
|
|
741
1144
|
const TextDomain = defineDomain({
|
|
742
1145
|
name: "Text",
|
|
743
1146
|
is: (u) => typeof u === "string",
|
|
1147
|
+
primitive: "string",
|
|
744
1148
|
show: (s) => JSON.stringify(s),
|
|
745
1149
|
ops: {
|
|
746
1150
|
concat: {
|
|
747
1151
|
fn: (a, b) => a + textOf(b),
|
|
748
|
-
params: ["any"]
|
|
1152
|
+
params: ["any"],
|
|
1153
|
+
returns: "string"
|
|
1154
|
+
},
|
|
1155
|
+
length: {
|
|
1156
|
+
fn: (a) => a.length,
|
|
1157
|
+
returns: "number"
|
|
1158
|
+
},
|
|
1159
|
+
upper: {
|
|
1160
|
+
fn: (a) => a.toUpperCase(),
|
|
1161
|
+
returns: "string"
|
|
1162
|
+
},
|
|
1163
|
+
lower: {
|
|
1164
|
+
fn: (a) => a.toLowerCase(),
|
|
1165
|
+
returns: "string"
|
|
1166
|
+
},
|
|
1167
|
+
trim: {
|
|
1168
|
+
fn: (a) => a.trim(),
|
|
1169
|
+
returns: "string"
|
|
749
1170
|
},
|
|
750
|
-
length: { fn: (a) => a.length },
|
|
751
|
-
upper: { fn: (a) => a.toUpperCase() },
|
|
752
|
-
lower: { fn: (a) => a.toLowerCase() },
|
|
753
|
-
trim: { fn: (a) => a.trim() },
|
|
754
1171
|
contains: {
|
|
755
1172
|
fn: (a, b) => a.includes(b),
|
|
756
|
-
params: ["string"]
|
|
1173
|
+
params: ["string"],
|
|
1174
|
+
returns: "boolean"
|
|
757
1175
|
},
|
|
758
1176
|
eq: {
|
|
759
1177
|
fn: (a, b) => a === b,
|
|
760
1178
|
laws: ["commutative"],
|
|
761
|
-
params: ["string"]
|
|
1179
|
+
params: ["string"],
|
|
1180
|
+
returns: "boolean"
|
|
762
1181
|
}
|
|
763
1182
|
}
|
|
764
1183
|
});
|
|
@@ -1010,6 +1429,6 @@ const MaybeDomain = defineDomain({
|
|
|
1010
1429
|
}
|
|
1011
1430
|
});
|
|
1012
1431
|
//#endregion
|
|
1013
|
-
export { Angle, AngleDomain, BoolDomain, Color, ColorDomain, DateDomain, Fn, FnDomain, LiftedNDVectorDomain, LocalDate, MAX_DAYS, Maybe, MaybeDomain, NDVector, NDVectorDomain, NumDomain, NumRecordDomain, TextDomain, Vec2, Vec2Domain };
|
|
1432
|
+
export { Angle, AngleDomain, BoolDomain, Color, ColorDomain, DateDomain, Fn, FnDomain, LiftedNDVectorDomain, LocalDate, MAX_DAYS, Maybe, MaybeDomain, NDVector, NDVectorDomain, NumDomain, NumRecordDomain, TextDomain, Vec2, Vec2Domain, XYDomain };
|
|
1014
1433
|
|
|
1015
1434
|
//# sourceMappingURL=index.js.map
|