flo-mat 4.1.0 → 4.1.2

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.
Files changed (45) hide show
  1. package/__tests__/helpers/jest.setup.ts +35 -0
  2. package/__tests__/specific-cases/specific-cases.spec.ts +1 -1
  3. package/browser/index.js +10665 -10243
  4. package/browser/index.min.js +1 -1
  5. package/node/cp-node/fs/get-implied-boundary-bezier-between.js.map +1 -1
  6. package/node/cp-node/stringification/cp-node-stringifyable.d.ts +29 -0
  7. package/node/cp-node/stringification/cp-node-stringifyable.js +7 -0
  8. package/node/cp-node/stringification/cp-node-stringifyable.js.map +1 -0
  9. package/node/cp-node/stringification/from-stringifyable.d.ts +4 -0
  10. package/node/cp-node/stringification/from-stringifyable.js +43 -0
  11. package/node/cp-node/stringification/from-stringifyable.js.map +1 -0
  12. package/node/cp-node/stringification/loop-from-stringifyable.d.ts +4 -0
  13. package/node/cp-node/stringification/loop-from-stringifyable.js +7 -0
  14. package/node/cp-node/stringification/loop-from-stringifyable.js.map +1 -0
  15. package/node/cp-node/stringification/loop-stringifyable.d.ts +5 -0
  16. package/node/cp-node/stringification/loop-stringifyable.js +2 -0
  17. package/node/cp-node/stringification/loop-stringifyable.js.map +1 -0
  18. package/node/cp-node/stringification/loop-to-stringifyable.d.ts +4 -0
  19. package/node/cp-node/stringification/loop-to-stringifyable.js +6 -0
  20. package/node/cp-node/stringification/loop-to-stringifyable.js.map +1 -0
  21. package/node/cp-node/stringification/to-stringifyable.d.ts +9 -0
  22. package/node/cp-node/stringification/to-stringifyable.js +46 -0
  23. package/node/cp-node/stringification/to-stringifyable.js.map +1 -0
  24. package/node/find-mat/find-mats.js +3 -1
  25. package/node/find-mat/find-mats.js.map +1 -1
  26. package/node/index.d.ts +5 -0
  27. package/node/index.js +5 -0
  28. package/node/index.js.map +1 -1
  29. package/node/mat/get-branches.js.map +1 -1
  30. package/node/mat/get-largest-3-prong.d.ts +3 -0
  31. package/node/mat/get-largest-3-prong.js +16 -0
  32. package/node/mat/get-largest-3-prong.js.map +1 -0
  33. package/node/mat/get-largest-vertex.d.ts +0 -1
  34. package/node/mat/get-largest-vertex.js +0 -1
  35. package/node/mat/get-largest-vertex.js.map +1 -1
  36. package/package.json +14 -14
  37. package/src/cp-node/fs/get-implied-boundary-bezier-between.ts +0 -1
  38. package/src/cp-node/stringification/from-stringifyable.ts +2 -2
  39. package/src/cp-node/stringification/to-stringifyable.ts +2 -2
  40. package/src/find-mat/find-mats.ts +3 -1
  41. package/src/index.ts +6 -1
  42. package/src/mat/get-branches.ts +1 -3
  43. package/src/mat/get-largest-3-prong.ts +3 -2
  44. package/src/mat/get-largest-vertex.ts +3 -2
  45. package/src/debug/functions/draw/draw-bezier-pieces.ts +0 -35
@@ -2,5 +2,40 @@ import { expect } from '@jest/globals';
2
2
  import { nearly } from './jest-extend-nearly.js';
3
3
 
4
4
 
5
+ // Polyfill for the TC39 `Map.prototype.getOrInsert` / `getOrInsertComputed`
6
+ // proposal, not yet available in the Node runtime Jest runs on (used by flo-boolean).
7
+ // See: https://github.com/tc39/proposal-upsert
8
+ if (typeof (Map.prototype as any).getOrInsert !== 'function') {
9
+ Object.defineProperty(Map.prototype, 'getOrInsert', {
10
+ value: function getOrInsert(this: Map<unknown, unknown>, key: unknown, defaultValue: unknown) {
11
+ if (this.has(key)) {
12
+ return this.get(key);
13
+ }
14
+ this.set(key, defaultValue);
15
+ return defaultValue;
16
+ },
17
+ writable: true,
18
+ configurable: true,
19
+ enumerable: false,
20
+ });
21
+ }
22
+
23
+ if (typeof (Map.prototype as any).getOrInsertComputed !== 'function') {
24
+ Object.defineProperty(Map.prototype, 'getOrInsertComputed', {
25
+ value: function getOrInsertComputed(this: Map<unknown, unknown>, key: unknown, callbackFn: (key: unknown) => unknown) {
26
+ if (this.has(key)) {
27
+ return this.get(key);
28
+ }
29
+ const value = callbackFn(key);
30
+ this.set(key, value);
31
+ return value;
32
+ },
33
+ writable: true,
34
+ configurable: true,
35
+ enumerable: false,
36
+ });
37
+ }
38
+
39
+
5
40
  // Register custom matchers globally for all test files.
6
41
  expect.extend(nearly);
@@ -100,7 +100,7 @@ test('Should correctly reconstruct original shape from medial axis for specific
100
100
 
101
101
  const bezierLoops = getPathsFromStr(pathStr);
102
102
 
103
- const loopss = simplifyPaths(bezierLoops, undefined, { forceOrientationNegative: true });
103
+ const loopss = simplifyPaths(bezierLoops, { forceOrientationNegative: true });
104
104
 
105
105
  let mats: Mat[];
106
106
  try {