@bitblit/ratchet-common 4.0.115-alpha → 4.0.119-alpha

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 (114) hide show
  1. package/lib/index.d.ts +73 -1
  2. package/lib/index.mjs +4 -0
  3. package/lib/index.mjs.map +1 -0
  4. package/lib/lang/base64-ratchet.d.ts +1 -1
  5. package/lib/stream/buffer-writable.d.ts +2 -2
  6. package/lib/stream/multi-stream.d.ts +1 -1
  7. package/lib/stream/stream-ratchet.d.ts +2 -2
  8. package/lib/stream/string-writable.d.ts +1 -1
  9. package/package.json +9 -5
  10. package/lib/2d/line-2d.js +0 -1
  11. package/lib/2d/plane-2d.js +0 -1
  12. package/lib/2d/point-2d.js +0 -1
  13. package/lib/2d/poly-line-2d.js +0 -1
  14. package/lib/2d/ratchet-2d.js +0 -245
  15. package/lib/2d/ratchet-2d.spec.js +0 -117
  16. package/lib/build/build-information.js +0 -1
  17. package/lib/build/ratchet-common-info.js +0 -14
  18. package/lib/histogram/histogram-entry.js +0 -1
  19. package/lib/histogram/histogram.js +0 -48
  20. package/lib/histogram/histogram.spec.js +0 -19
  21. package/lib/index.js +0 -1
  22. package/lib/jwt/common-jwt-token.js +0 -1
  23. package/lib/jwt/expired-jwt-handling.js +0 -6
  24. package/lib/jwt/jwt-ratchet-like.js +0 -1
  25. package/lib/jwt/jwt-ratchet.js +0 -164
  26. package/lib/jwt/jwt-ratchet.spec.js +0 -49
  27. package/lib/jwt/jwt-token-base.js +0 -1
  28. package/lib/lang/array-ratchet.js +0 -83
  29. package/lib/lang/array-ratchet.spec.js +0 -68
  30. package/lib/lang/base64-ratchet.js +0 -45
  31. package/lib/lang/base64-ratchet.spec.js +0 -28
  32. package/lib/lang/boolean-ratchet.js +0 -45
  33. package/lib/lang/boolean-ratchet.spec.js +0 -81
  34. package/lib/lang/composite-last-success-provider.js +0 -26
  35. package/lib/lang/composite-last-success-provider.spec.js +0 -26
  36. package/lib/lang/date-ratchet.js +0 -29
  37. package/lib/lang/date-ratchet.spec.js +0 -21
  38. package/lib/lang/duration-ratchet.js +0 -42
  39. package/lib/lang/duration-ratchet.spec.js +0 -39
  40. package/lib/lang/enum-ratchet.js +0 -30
  41. package/lib/lang/enum-ratchet.spec.js +0 -31
  42. package/lib/lang/error-ratchet.js +0 -44
  43. package/lib/lang/error-ratchet.spec.js +0 -20
  44. package/lib/lang/esm-ratchet.js +0 -17
  45. package/lib/lang/expiring-object.js +0 -72
  46. package/lib/lang/expiring-object.spec.js +0 -51
  47. package/lib/lang/geolocation-ratchet.js +0 -263
  48. package/lib/lang/geolocation-ratchet.spec.js +0 -74
  49. package/lib/lang/global-ratchet.js +0 -43
  50. package/lib/lang/global-ratchet.spec.js +0 -14
  51. package/lib/lang/key-value.js +0 -4
  52. package/lib/lang/last-success-provider.js +0 -1
  53. package/lib/lang/map-ratchet.js +0 -164
  54. package/lib/lang/map-ratchet.spec.js +0 -90
  55. package/lib/lang/no.js +0 -4
  56. package/lib/lang/no.spec.js +0 -7
  57. package/lib/lang/number-ratchet.js +0 -155
  58. package/lib/lang/number-ratchet.spec.js +0 -118
  59. package/lib/lang/parsed-url.js +0 -1
  60. package/lib/lang/promise-ratchet.js +0 -138
  61. package/lib/lang/promise-ratchet.spec.js +0 -74
  62. package/lib/lang/require-ratchet.js +0 -56
  63. package/lib/lang/require-ratchet.spec.js +0 -80
  64. package/lib/lang/stop-watch.js +0 -114
  65. package/lib/lang/string-ratchet.js +0 -201
  66. package/lib/lang/string-ratchet.spec.js +0 -158
  67. package/lib/lang/time-zone-ratchet.js +0 -77
  68. package/lib/lang/time-zone-ratchet.spec.js +0 -40
  69. package/lib/lang/timeout-token.js +0 -17
  70. package/lib/lang/timeout-token.spec.js +0 -9
  71. package/lib/lang/transform-ratchet.js +0 -66
  72. package/lib/lang/transform-ratchet.spec.js +0 -118
  73. package/lib/logger/classic-single-line-log-message-formatter.js +0 -13
  74. package/lib/logger/log-message-builder.js +0 -48
  75. package/lib/logger/log-message-format-type.js +0 -6
  76. package/lib/logger/log-message-formatter.js +0 -1
  77. package/lib/logger/log-message-processor.js +0 -1
  78. package/lib/logger/log-message.js +0 -1
  79. package/lib/logger/log-snapshot.js +0 -1
  80. package/lib/logger/logger-instance.js +0 -208
  81. package/lib/logger/logger-level-name.js +0 -9
  82. package/lib/logger/logger-meta.js +0 -1
  83. package/lib/logger/logger-options.js +0 -1
  84. package/lib/logger/logger-output-function.js +0 -6
  85. package/lib/logger/logger-ring-buffer.js +0 -73
  86. package/lib/logger/logger-util.js +0 -44
  87. package/lib/logger/logger-util.spec.js +0 -9
  88. package/lib/logger/logger.js +0 -134
  89. package/lib/logger/logger.spec.js +0 -134
  90. package/lib/logger/none-log-message-formatter.js +0 -5
  91. package/lib/logger/structured-json-log-message-formatter.js +0 -19
  92. package/lib/network/browser-local-ip-provider.js +0 -21
  93. package/lib/network/browser-local-ip-provider.spec.js +0 -16
  94. package/lib/network/fixed-local-ip-provider.js +0 -9
  95. package/lib/network/local-ip-provider.js +0 -1
  96. package/lib/network/network-ratchet.js +0 -102
  97. package/lib/network/network-ratchet.spec.js +0 -13
  98. package/lib/stream/buffer-writable.js +0 -16
  99. package/lib/stream/multi-stream.js +0 -12
  100. package/lib/stream/stream-ratchet.js +0 -68
  101. package/lib/stream/stream-ratchet.spec.js +0 -13
  102. package/lib/stream/string-writable.js +0 -14
  103. package/lib/stream/string-writable.spec.js +0 -12
  104. package/lib/third-party/google/google-recaptcha-ratchet.js +0 -28
  105. package/lib/third-party/google/google-recaptcha-ratchet.spec.js +0 -20
  106. package/lib/third-party/twilio/twilio-ratchet.js +0 -73
  107. package/lib/transform/built-in-transforms.js +0 -191
  108. package/lib/transform/transform-rule.js +0 -1
  109. package/lib/tx/transaction-configuration.js +0 -1
  110. package/lib/tx/transaction-final-state.js +0 -6
  111. package/lib/tx/transaction-ratchet.js +0 -76
  112. package/lib/tx/transaction-ratchet.spec.js +0 -130
  113. package/lib/tx/transaction-result.js +0 -1
  114. package/lib/tx/transaction-step.js +0 -1
@@ -1,4 +1,4 @@
1
- /// <reference types="node" resolution-mode="require"/>
1
+ /// <reference types="node" />
2
2
  export declare class Base64Ratchet {
3
3
  static safeObjectToBase64JSON(input: any): any;
4
4
  static safeBase64JSONParse(input: string): any;
@@ -1,5 +1,5 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
- /// <reference types="node" resolution-mode="require"/>
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
3
  import { Writable } from 'stream';
4
4
  export declare class BufferWritable extends Writable {
5
5
  private _val;
@@ -1,4 +1,4 @@
1
- /// <reference types="node" resolution-mode="require"/>
1
+ /// <reference types="node" />
2
2
  import { Readable, ReadableOptions } from 'stream';
3
3
  export declare class MultiStream extends Readable {
4
4
  _object: any;
@@ -1,5 +1,5 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
- /// <reference types="node" resolution-mode="require"/>
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
3
  import { Readable } from 'stream';
4
4
  export declare class StreamRatchet {
5
5
  private constructor();
@@ -1,4 +1,4 @@
1
- /// <reference types="node" resolution-mode="require"/>
1
+ /// <reference types="node" />
2
2
  import { Writable } from 'stream';
3
3
  export declare class StringWritable extends Writable {
4
4
  private _val;
package/package.json CHANGED
@@ -1,13 +1,18 @@
1
1
  {
2
2
  "name": "@bitblit/ratchet-common",
3
- "version": "4.0.115-alpha",
3
+ "version": "4.0.119-alpha",
4
4
  "description": "Common tools for general use",
5
5
  "type": "module",
6
- "module": "index.js",
7
6
  "files": [
8
7
  "lib/*",
9
8
  "bin/*"
10
9
  ],
10
+ "exports": {
11
+ ".": {
12
+ "types": "./lib/index.d.ts",
13
+ "import": "./lib/index.mjs"
14
+ }
15
+ },
11
16
  "contributors": [
12
17
  "Christopher Weiss <bitblit@gmail.com>",
13
18
  "William Weiss <npm@codification.org>",
@@ -34,9 +39,8 @@
34
39
  "docs": "typedoc",
35
40
  "lint": "eslint src/**/*.ts",
36
41
  "lint-fix": "eslint --fix src/**/*.ts",
37
- "__generate-barrels": "barrelsby -q --delete -d src -e .*\\.spec\\.ts",
38
- "__build": "yarn run generate-barrels && tsc",
39
- "build": "tsc",
42
+ "generate-barrels": "barrelsby -q --delete -d src -e .*\\.spec\\.ts && sed -i 's/\\x27;/.js\\x27;/' src/index.ts",
43
+ "build": "yarn clean && yarn generate-barrels && rollup -c rollup.config.js",
40
44
  "force-build": "tsc --build --force"
41
45
  },
42
46
  "repository": {
package/lib/2d/line-2d.js DELETED
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,245 +0,0 @@
1
- import { BooleanRatchet } from '../lang/boolean-ratchet.js';
2
- export class Ratchet2d {
3
- constructor() { }
4
- static translateToOriginVector(points) {
5
- let rval = null;
6
- if (Ratchet2d.validPoints(points)) {
7
- rval = {
8
- x: null,
9
- y: null,
10
- };
11
- points.forEach((p) => {
12
- rval.x = rval.x === null || p.x < rval.x ? p.x : rval.x;
13
- rval.y = rval.y === null || p.y < rval.y ? p.y : rval.y;
14
- });
15
- rval.x *= -1;
16
- rval.y *= -1;
17
- }
18
- return rval;
19
- }
20
- static minimalContainingPlane(points) {
21
- let rval = null;
22
- if (Ratchet2d.validPoints(points)) {
23
- rval = {
24
- width: 0,
25
- height: 0,
26
- };
27
- points.forEach((p) => {
28
- rval.width = Math.max(rval.width, p.x + 1);
29
- rval.height = Math.max(rval.height, p.y + 1);
30
- });
31
- }
32
- return rval;
33
- }
34
- static scaleVector(src, dst) {
35
- let rval = null;
36
- if (Ratchet2d.validPlane(src) && Ratchet2d.validPlane(dst)) {
37
- rval = {
38
- x: dst.width / src.width,
39
- y: dst.height / src.height,
40
- };
41
- }
42
- return rval;
43
- }
44
- static samePoint(p1, p2) {
45
- return !!p1 && !!p2 && p1.x === p2.x && p1.y === p2.y;
46
- }
47
- static atLeastOneDimensionShared(p1, p2) {
48
- return !!p1 && !!p2 && (p1.x === p2.x || p1.y === p2.y);
49
- }
50
- static validPlane(plane) {
51
- return !!plane && !!plane.height && !!plane.width;
52
- }
53
- static validLine(line) {
54
- return !!line && Ratchet2d.validPoint(line.p1) && Ratchet2d.validPoint(line.p2) && !Ratchet2d.samePoint(line.p1, line.p2);
55
- }
56
- static validLines(lines) {
57
- return !!lines && BooleanRatchet.allTrue(lines.map((l) => Ratchet2d.validLine(l)));
58
- }
59
- static validPolyLine(pline) {
60
- return !!pline && pline.pts?.length > 1 && BooleanRatchet.allTrue(pline.pts.map((p) => Ratchet2d.validPoint(p)));
61
- }
62
- static polyLineToLines(pline) {
63
- let rval = null;
64
- if (Ratchet2d.validPolyLine(pline)) {
65
- rval = [];
66
- for (let i = 1; i < pline.pts.length; i++) {
67
- rval.push({ p1: pline.pts[i - 1], p2: pline.pts[i] });
68
- }
69
- }
70
- return rval;
71
- }
72
- static lastPointOnPolyLine(polyLine) {
73
- return Ratchet2d.validPolyLine(polyLine) ? polyLine.pts[polyLine.pts.length - 1] : null;
74
- }
75
- static lineToPolyLine(line) {
76
- return Ratchet2d.validLine(line) ? { pts: [line.p1, line.p2] } : null;
77
- }
78
- static linesToPolyLines(lines) {
79
- let rval = null;
80
- if (Ratchet2d.validLines(lines)) {
81
- rval = [];
82
- let currentPLine = Ratchet2d.lineToPolyLine(lines[0]);
83
- for (let i = 1; i < lines.length; i++) {
84
- if (Ratchet2d.samePoint(Ratchet2d.lastPointOnPolyLine(currentPLine), lines[i].p1)) {
85
- currentPLine.pts.push(lines[i].p2);
86
- }
87
- else {
88
- rval.push(currentPLine);
89
- currentPLine = Ratchet2d.lineToPolyLine(lines[i]);
90
- }
91
- }
92
- rval.push(currentPLine);
93
- }
94
- return rval;
95
- }
96
- static validPoint(pt) {
97
- return !!pt && pt.x != null && pt.x != undefined && pt.y !== null && pt.y !== undefined;
98
- }
99
- static validPoints(pt) {
100
- return (!!pt &&
101
- BooleanRatchet.allTrue(pt.map((p) => Ratchet2d.validPoint(p)), false));
102
- }
103
- static planeContainsPoint(pt, plane) {
104
- return Ratchet2d.validPlane(plane) && Ratchet2d.validPoint(pt) && pt.x >= 0 && pt.x < plane.width && pt.y >= 0 && pt.y < plane.height;
105
- }
106
- static planeContainsPoints(pt, plane) {
107
- return pt && pt.map((p) => Ratchet2d.planeContainsPoint(p, plane)).reduce((a, i) => a && i, true);
108
- }
109
- static linesToPoints(lines) {
110
- let rval = null;
111
- if (Ratchet2d.validLines(lines)) {
112
- rval = lines.map((l) => [l.p1, l.p2]).flat();
113
- }
114
- return rval;
115
- }
116
- static pointsToLines(points) {
117
- let rval = null;
118
- if (Ratchet2d.validPoints(points)) {
119
- if (points.length % 2 == 0) {
120
- rval = [];
121
- for (let i = 0; i < points.length; i += 2) {
122
- rval.push({ p1: points[i], p2: points[i + 1] });
123
- }
124
- }
125
- else {
126
- throw new Error('Cannot convert non-even array of points into lines');
127
- }
128
- }
129
- return rval;
130
- }
131
- static rotateRightAboutOrigin90Degrees(points, times = 1) {
132
- let rval = null;
133
- let translate = { x: 0, y: 0 };
134
- if (Ratchet2d.validPoints(points)) {
135
- rval = Object.assign([], points);
136
- translate = Ratchet2d.translateToOriginVector(rval);
137
- rval = Ratchet2d.translate(rval, translate);
138
- let plane = Ratchet2d.minimalContainingPlane(rval);
139
- rval = Ratchet2d.xToY(rval);
140
- plane = { width: plane.height, height: plane.width };
141
- translate = { x: translate.y * -1, y: translate.x * -1 };
142
- rval = Ratchet2d.mirrorPointsOnPlane(rval, plane, true, false);
143
- rval = Ratchet2d.translate(rval, translate);
144
- }
145
- const timesToRotate = times > 4 ? times % 4 : times;
146
- if (timesToRotate > 1) {
147
- rval = Ratchet2d.rotateRightAboutOrigin90Degrees(rval, timesToRotate - 1);
148
- }
149
- return rval;
150
- }
151
- static planeContainsLines(lines, plane) {
152
- return lines && Ratchet2d.planeContainsPoints(lines.map((l) => [l.p1, l.p2]).flat(), plane);
153
- }
154
- static planeContainsPolyLine(pline, plane) {
155
- return Ratchet2d.planeContainsLines(Ratchet2d.polyLineToLines(pline), plane);
156
- }
157
- static planeContainsLine(line, plane) {
158
- return (Ratchet2d.validPlane(plane) &&
159
- Ratchet2d.validLine(line) &&
160
- Ratchet2d.planeContainsPoint(line.p1, plane) &&
161
- Ratchet2d.planeContainsPoint(line.p2, plane));
162
- }
163
- static xToY(points) {
164
- let rval = null;
165
- if (Ratchet2d.validPoints(points)) {
166
- rval = points.map((p) => {
167
- const next = { x: p.y, y: p.x };
168
- return next;
169
- });
170
- }
171
- return rval;
172
- }
173
- static translate(points, xlate) {
174
- let rval = null;
175
- if (Ratchet2d.validPoints(points) && Ratchet2d.validPoint(xlate)) {
176
- rval = points.map((p) => {
177
- const next = {
178
- x: p.x + xlate.x,
179
- y: p.y + xlate.y,
180
- };
181
- return next;
182
- });
183
- }
184
- return rval;
185
- }
186
- static mirrorPointsOnPlane(points, src, mirrorX, mirrorY) {
187
- let rval = null;
188
- if (Ratchet2d.validPoints(points) && Ratchet2d.validPlane(src)) {
189
- if (mirrorX || mirrorY) {
190
- rval = points.map((p) => {
191
- const next = {
192
- x: mirrorX ? src.width - 1 - p.x : p.x,
193
- y: mirrorY ? src.height - 1 - p.y : p.y,
194
- };
195
- return next;
196
- });
197
- }
198
- else {
199
- rval = Object.assign([], points);
200
- }
201
- }
202
- return rval;
203
- }
204
- static transformPointsToNewPlane(points, src, dst) {
205
- let rval = null;
206
- if (Ratchet2d.validPoints(points) && Ratchet2d.validPlane(src) && Ratchet2d.validPlane(dst)) {
207
- const scale = Ratchet2d.scaleVector(src, dst);
208
- rval = points.map((p) => {
209
- const next = { x: p.x * scale.x, y: p.y * scale.y };
210
- return next;
211
- });
212
- rval = Ratchet2d.mirrorPointsOnPlane(rval, dst, dst.rightToLeft !== src.rightToLeft, dst.topToBottom !== src.topToBottom);
213
- }
214
- return rval;
215
- }
216
- static transformPointToNewPlane(point, src, dst) {
217
- const tmp = Ratchet2d.transformPointsToNewPlane([point], src, dst);
218
- return tmp.length === 1 ? tmp[0] : null;
219
- }
220
- static transformLines(lines, src, dst) {
221
- return null;
222
- }
223
- static fitCurve(curveDef, inputX) {
224
- curveDef.sort((a, b) => {
225
- return a.x - b.x;
226
- });
227
- if (inputX <= curveDef[0].x) {
228
- return curveDef[0].y;
229
- }
230
- else if (inputX >= curveDef[curveDef.length - 1].x) {
231
- return curveDef[curveDef.length - 1].y;
232
- }
233
- else {
234
- let idx = 0;
235
- while (curveDef[idx + 1].x < inputX) {
236
- idx++;
237
- }
238
- const xSpread = curveDef[idx + 1].x - curveDef[idx].x;
239
- const ySpread = curveDef[idx + 1].y - curveDef[idx].y;
240
- const pct = (inputX - curveDef[idx].x) / xSpread;
241
- const yAdd = pct * ySpread;
242
- return curveDef[idx].y + yAdd;
243
- }
244
- }
245
- }
@@ -1,117 +0,0 @@
1
- import { Ratchet2d } from './ratchet-2d.js';
2
- describe('#ratchet2d', function () {
3
- it('should check for valid planes', function () {
4
- expect(Ratchet2d.validPlane(null)).toEqual(false);
5
- expect(Ratchet2d.validPlane({ width: null, height: null })).toEqual(false);
6
- expect(Ratchet2d.validPlane({ width: 0, height: null })).toEqual(false);
7
- expect(Ratchet2d.validPlane({ width: 0, height: 2 })).toEqual(false);
8
- expect(Ratchet2d.validPlane({ width: 1, height: 7 })).toEqual(true);
9
- });
10
- it('should check for valid lines', function () {
11
- expect(Ratchet2d.validLine(null)).toEqual(false);
12
- expect(Ratchet2d.validLine({ p1: null, p2: null })).toEqual(false);
13
- expect(Ratchet2d.validLine({ p1: { x: null, y: 0 }, p2: null })).toEqual(false);
14
- expect(Ratchet2d.validLine({ p1: { x: 0, y: 0 }, p2: { x: 27, y: null } })).toEqual(false);
15
- expect(Ratchet2d.validLine({ p1: { x: 0, y: 0 }, p2: { x: 27, y: 0 } })).toEqual(true);
16
- expect(Ratchet2d.validLine({ p1: { x: 1, y: 0 }, p2: { x: 1, y: 0 } })).toEqual(false);
17
- expect(Ratchet2d.validLine({ p1: { x: 0, y: 0 }, p2: { x: 27, y: 13 } })).toEqual(true);
18
- });
19
- it('should transform points from one plane to another (scale)', function () {
20
- const plane1 = { height: 10, width: 10 };
21
- const plane2 = { height: 100, width: 50 };
22
- const p1 = { x: 5, y: 5 };
23
- const out1 = Ratchet2d.transformPointToNewPlane(p1, plane1, plane2);
24
- const out2 = Ratchet2d.transformPointToNewPlane(out1, plane2, plane1);
25
- expect(out1.x).toEqual(25);
26
- expect(out1.y).toEqual(50);
27
- expect(out2.x).toEqual(p1.x);
28
- expect(out2.y).toEqual(p1.y);
29
- });
30
- it('should transform points from one plane to another (mirror)', function () {
31
- const plane1 = { height: 10, width: 10 };
32
- const plane2 = { height: 10, width: 10, rightToLeft: true, topToBottom: true };
33
- const p1 = { x: 2, y: 8 };
34
- const out1 = Ratchet2d.transformPointToNewPlane(p1, plane1, plane2);
35
- const out2 = Ratchet2d.transformPointToNewPlane(out1, plane2, plane1);
36
- expect(out1.x).toEqual(7);
37
- expect(out1.y).toEqual(1);
38
- expect(out2.x).toEqual(p1.x);
39
- expect(out2.y).toEqual(p1.y);
40
- });
41
- it('should check for containment', function () {
42
- const plane = {
43
- width: 100,
44
- height: 100,
45
- };
46
- expect(Ratchet2d.planeContainsPoint({ x: -1, y: 10 }, plane)).toEqual(false);
47
- expect(Ratchet2d.planeContainsPoint({ x: 101, y: 10 }, plane)).toEqual(false);
48
- expect(Ratchet2d.planeContainsPoint({ x: 1, y: -10 }, plane)).toEqual(false);
49
- expect(Ratchet2d.planeContainsPoint({ x: 10, y: 101 }, plane)).toEqual(false);
50
- expect(Ratchet2d.planeContainsPoint({ x: 10, y: 100 }, plane)).toEqual(false);
51
- expect(Ratchet2d.planeContainsPoint({ x: 1, y: 10 }, plane)).toEqual(true);
52
- expect(Ratchet2d.planeContainsPoint({ x: 10, y: 10 }, plane)).toEqual(true);
53
- expect(Ratchet2d.planeContainsPoints([
54
- { x: 10, y: 10 },
55
- { x: 100, y: 10 },
56
- ], plane)).toEqual(false);
57
- expect(Ratchet2d.planeContainsPoints([
58
- { x: 10, y: 10 },
59
- { x: 11, y: 10 },
60
- ], plane)).toEqual(true);
61
- expect(Ratchet2d.planeContainsLine({
62
- p1: { x: 10, y: 10 },
63
- p2: { x: 100, y: 10 },
64
- }, plane)).toEqual(false);
65
- expect(Ratchet2d.planeContainsLine({
66
- p1: { x: 10, y: 10 },
67
- p2: { x: 11, y: 10 },
68
- }, plane)).toEqual(true);
69
- });
70
- it('should fit input to curve', function () {
71
- const curve = [
72
- { x: 0, y: 50 },
73
- { x: 0.5, y: 50 },
74
- { x: 0.8, y: 60 },
75
- { x: 1, y: 70 },
76
- { x: 1.2, y: 80 },
77
- { x: 1.5, y: 90 },
78
- { x: 1.6, y: 91 },
79
- { x: 1.7, y: 92 },
80
- { x: 1.8, y: 93 },
81
- { x: 1.9, y: 94 },
82
- { x: 2, y: 95 },
83
- {
84
- x: 3,
85
- y: 98,
86
- },
87
- { x: 4, y: 99 },
88
- { x: 5, y: 100 },
89
- ];
90
- expect(Ratchet2d.fitCurve(curve, -1)).toEqual(50);
91
- expect(Ratchet2d.fitCurve(curve, 0)).toEqual(50);
92
- expect(Ratchet2d.fitCurve(curve, 0.3)).toEqual(50);
93
- expect(Ratchet2d.fitCurve(curve, 0.5)).toEqual(50);
94
- expect(Ratchet2d.fitCurve(curve, 0.8)).toEqual(60);
95
- expect(Ratchet2d.fitCurve(curve, 1)).toEqual(70);
96
- expect(Ratchet2d.fitCurve(curve, 5)).toEqual(100);
97
- expect(Ratchet2d.fitCurve(curve, 6)).toEqual(100);
98
- expect(Ratchet2d.fitCurve(curve, 1.65)).toEqual(91.5);
99
- });
100
- it('rotate about origin', function () {
101
- const points = [
102
- { x: 1, y: 0 },
103
- { x: 2, y: 1 },
104
- { x: 3, y: 2 },
105
- { x: 4, y: 3 },
106
- { x: 4, y: 1 },
107
- { x: 6, y: 1 },
108
- ];
109
- const r1 = Ratchet2d.rotateRightAboutOrigin90Degrees(points);
110
- expect(r1.length).toEqual(6);
111
- const r3 = Ratchet2d.rotateRightAboutOrigin90Degrees(points, 3);
112
- const r2 = Ratchet2d.rotateRightAboutOrigin90Degrees(points, 4);
113
- expect(r2.length).toEqual(6);
114
- expect(r2[0].x).toEqual(points[0].x);
115
- expect(r2[0].y).toEqual(points[0].y);
116
- });
117
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,14 +0,0 @@
1
- export class RatchetInfo {
2
- constructor() { }
3
- static buildInformation() {
4
- const val = {
5
- version: 'LOCAL-SNAPSHOT',
6
- hash: 'LOCAL-HASH',
7
- branch: 'LOCAL-BRANCH',
8
- tag: 'LOCAL-TAG',
9
- timeBuiltISO: 'LOCAL-TIME-ISO',
10
- notes: 'LOCAL-NOTES',
11
- };
12
- return val;
13
- }
14
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,48 +0,0 @@
1
- export class Histogram {
2
- entries = [];
3
- update(val, addValue = 1) {
4
- if (val) {
5
- const entry = this.entries.find((e) => e.item === val);
6
- if (entry) {
7
- entry.count += addValue;
8
- }
9
- else {
10
- this.entries.push({
11
- item: val,
12
- count: addValue,
13
- });
14
- }
15
- }
16
- }
17
- sort() {
18
- this.entries.sort((a, b) => {
19
- let rval = b.count - a.count;
20
- if (rval === 0) {
21
- rval = String(b.item).localeCompare(String(a.item));
22
- }
23
- return rval;
24
- });
25
- }
26
- sortKeys() {
27
- this.entries.sort((a, b) => String(b.item).localeCompare(String(a.item)));
28
- }
29
- reverse() {
30
- this.entries.reverse();
31
- }
32
- getEntries() {
33
- return this.entries;
34
- }
35
- getTotalCount() {
36
- let rval = 0;
37
- this.entries.forEach((h) => (rval += h.count));
38
- return rval;
39
- }
40
- countForValue(val) {
41
- const entry = this.entries.find((test) => test.item === val);
42
- return entry ? entry.count : 0;
43
- }
44
- percentForValue(val) {
45
- const total = this.getTotalCount();
46
- return total === 0 ? 0 : this.countForValue(val) / total;
47
- }
48
- }
@@ -1,19 +0,0 @@
1
- import { Histogram } from './histogram.js';
2
- describe('#histogram', function () {
3
- it('should count the values correctly', function () {
4
- const histogram = new Histogram();
5
- histogram.update('a');
6
- histogram.update('a');
7
- histogram.update('b');
8
- histogram.update('c');
9
- expect(histogram.getTotalCount()).toEqual(4);
10
- expect(histogram.countForValue('a')).toEqual(2);
11
- expect(histogram.countForValue('b')).toEqual(1);
12
- expect(histogram.countForValue('c')).toEqual(1);
13
- expect(histogram.countForValue('d')).toEqual(0);
14
- expect(histogram.percentForValue('a')).toEqual(0.5);
15
- expect(histogram.percentForValue('b')).toEqual(0.25);
16
- expect(histogram.percentForValue('c')).toEqual(0.25);
17
- expect(histogram.percentForValue('d')).toEqual(0);
18
- });
19
- });
package/lib/index.js DELETED
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,6 +0,0 @@
1
- export var ExpiredJwtHandling;
2
- (function (ExpiredJwtHandling) {
3
- ExpiredJwtHandling[ExpiredJwtHandling["RETURN_NULL"] = 0] = "RETURN_NULL";
4
- ExpiredJwtHandling[ExpiredJwtHandling["THROW_EXCEPTION"] = 1] = "THROW_EXCEPTION";
5
- ExpiredJwtHandling[ExpiredJwtHandling["ADD_FLAG"] = 2] = "ADD_FLAG";
6
- })(ExpiredJwtHandling || (ExpiredJwtHandling = {}));
@@ -1 +0,0 @@
1
- export {};