@pacem/pacem-foundation 1.0.0-bernoulli → 1.0.0-binet
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/dist/browser/pacem-foundation.js +296 -1
- package/dist/browser/pacem-foundation.js.map +1 -1
- package/dist/browser/pacem-foundation.min.js +1 -2
- package/dist/bundle/pacem-foundation.min.mjs +1 -1
- package/dist/bundle/pacem-foundation.mjs +258 -1
- package/dist/bundle/pacem-foundation.mjs.map +2 -2
- package/dist/docs/pacem-foundation.json +8941 -0
- package/dist/esm/array-extensions.js +1 -1
- package/dist/esm/arrays.js +8 -1
- package/dist/esm/blobs.js +24 -1
- package/dist/esm/browser.js +6 -1
- package/dist/esm/colors.js +15 -1
- package/dist/esm/dates.js +37 -1
- package/dist/esm/deepmerger.js +10 -1
- package/dist/esm/geom.js +33 -1
- package/dist/esm/history-svc.js +15 -1
- package/dist/esm/imaging.js +7 -1
- package/dist/esm/index-compile-markdown.js +1 -1
- package/dist/esm/index-compile.js +1 -1
- package/dist/esm/index-iife.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/keygenerator.js +15 -1
- package/dist/esm/matrix2d.js +36 -1
- package/dist/esm/null-checker.js +16 -1
- package/dist/esm/number-extensions.js +1 -1
- package/dist/esm/numbers.js +20 -1
- package/dist/esm/rect.js +12 -1
- package/dist/esm/strings.js +23 -1
- package/package.json +2 -1
- package/typings/index.d.ts +451 -0
- package/dist/browser/pacem-foundation.min.js.map +0 -1
package/dist/esm/rect.js
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @pacem/pacem-foundation v1.0.0-
|
|
2
|
+
* @pacem/pacem-foundation v1.0.0-binet (https://js.pacem.it)
|
|
3
3
|
* Pacem (https://pacem.it)
|
|
4
4
|
* Licensed under Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
import { Matrix2D } from './matrix2d';
|
|
7
7
|
import { parseAsNumericalArray, Point, Size } from "./geom";
|
|
8
|
+
/** Rectangle-related utilities (parsing, transform computation, intersection, bounding box). */
|
|
8
9
|
export class Rect {
|
|
10
|
+
/**
|
|
11
|
+
* Parses a string containing exactly four numbers into a {@link Rect}.
|
|
12
|
+
* @param rect String to parse (e.g. `"0 0 100 50"`, in `x y width height` order).
|
|
13
|
+
* @returns The parsed rect.
|
|
14
|
+
* @throws If `rect` does not contain exactly four numbers.
|
|
15
|
+
*/
|
|
9
16
|
static parse(rect) {
|
|
10
17
|
let arr = parseAsNumericalArray(rect);
|
|
11
18
|
if (arr && arr.length === 4) {
|
|
@@ -13,6 +20,10 @@ export class Rect {
|
|
|
13
20
|
}
|
|
14
21
|
throw new Error(`Cannot parse "${rect}" as a valid Rect.`);
|
|
15
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* Type-guards a value as a valid {@link Rect} object.
|
|
25
|
+
* @param obj Value to check.
|
|
26
|
+
*/
|
|
16
27
|
static isRect(obj) {
|
|
17
28
|
return Point.isPoint(obj) && Size.isSize(obj);
|
|
18
29
|
}
|
package/dist/esm/strings.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @pacem/pacem-foundation v1.0.0-
|
|
2
|
+
* @pacem/pacem-foundation v1.0.0-binet (https://js.pacem.it)
|
|
3
3
|
* Pacem (https://pacem.it)
|
|
4
4
|
* Licensed under Apache-2.0
|
|
5
5
|
*/
|
|
@@ -145,6 +145,7 @@ function diffLines(a, b) {
|
|
|
145
145
|
return diffInternal(aTokens, bTokens, dp, '\n');
|
|
146
146
|
}
|
|
147
147
|
//#endregion
|
|
148
|
+
/** String manipulation utilities. */
|
|
148
149
|
export class Strings {
|
|
149
150
|
/** @deprecated Use String.prototype.padStart() instead. */
|
|
150
151
|
static leftPad(v, targetLength, padChar) {
|
|
@@ -154,6 +155,14 @@ export class Strings {
|
|
|
154
155
|
// retval = padChar + retval;
|
|
155
156
|
//return retval;
|
|
156
157
|
}
|
|
158
|
+
/**
|
|
159
|
+
* Formats a template string, replacing `{0}`, `{1}`, ... placeholders with the corresponding arguments.
|
|
160
|
+
* Doubled braces (`{{`/`}}`) escape a placeholder.
|
|
161
|
+
* @param template Template string containing `{n}` placeholders.
|
|
162
|
+
* @param args Values to substitute into the placeholders, by index.
|
|
163
|
+
* @returns The formatted string.
|
|
164
|
+
* @throws If the template references an argument index that was not supplied.
|
|
165
|
+
*/
|
|
157
166
|
static format(template, ...args) {
|
|
158
167
|
const array = Array.from(args);
|
|
159
168
|
let retval = template;
|
|
@@ -169,6 +178,13 @@ export class Strings {
|
|
|
169
178
|
}
|
|
170
179
|
return retval;
|
|
171
180
|
}
|
|
181
|
+
/**
|
|
182
|
+
* Computes a diff between two strings, using the Longest Common Subsequence algorithm.
|
|
183
|
+
* @param a First (original) string.
|
|
184
|
+
* @param b Second (modified) string.
|
|
185
|
+
* @param mode Diffing granularity: `'char'` (default), `'word'` or `'line'`.
|
|
186
|
+
* @returns Array of {@link DiffToken}s describing unchanged, removed and added chunks.
|
|
187
|
+
*/
|
|
172
188
|
static diff(a, b, mode = 'char') {
|
|
173
189
|
switch (mode) {
|
|
174
190
|
case 'line':
|
|
@@ -179,6 +195,12 @@ export class Strings {
|
|
|
179
195
|
return diffChars(a, b);
|
|
180
196
|
}
|
|
181
197
|
}
|
|
198
|
+
/**
|
|
199
|
+
* Computes the cryptographic hash of a string using the SubtleCrypto API.
|
|
200
|
+
* @param input String to hash.
|
|
201
|
+
* @param algo Hash algorithm to use (defaults to `SHA-256`).
|
|
202
|
+
* @returns A promise resolving with the hash, hex-encoded.
|
|
203
|
+
*/
|
|
182
204
|
static async hash(input, algo = 'SHA-256') {
|
|
183
205
|
const hashBuffer = await crypto.subtle.digest(algo, new TextEncoder().encode(input));
|
|
184
206
|
return Array.from(new Uint8Array(hashBuffer))
|
package/package.json
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
"dist/browser/*.*",
|
|
5
5
|
"dist/bundle/*.*",
|
|
6
6
|
"dist/esm/*.*",
|
|
7
|
+
"dist/docs/*.*",
|
|
7
8
|
"typings/*.*",
|
|
8
9
|
"README.md",
|
|
9
10
|
"LICENSE",
|
|
@@ -24,7 +25,7 @@
|
|
|
24
25
|
"types": "./typings/index.d.ts"
|
|
25
26
|
}
|
|
26
27
|
},
|
|
27
|
-
"version": "1.0.0-
|
|
28
|
+
"version": "1.0.0-binet",
|
|
28
29
|
"author": {
|
|
29
30
|
"name": "Pacem",
|
|
30
31
|
"url": "https://pacem.it"
|