@fgv/ts-utils 3.0.1-alpha.6 → 4.0.1

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/CHANGELOG.json CHANGED
@@ -1,6 +1,54 @@
1
1
  {
2
2
  "name": "@fgv/ts-utils",
3
3
  "entries": [
4
+ {
5
+ "version": "4.0.1",
6
+ "tag": "@fgv/ts-utils_v4.0.1",
7
+ "date": "Tue, 14 May 2024 05:02:20 GMT",
8
+ "comments": {
9
+ "none": [
10
+ {
11
+ "comment": "publish"
12
+ },
13
+ {
14
+ "comment": "import TextEncoder to avoid globals race"
15
+ }
16
+ ]
17
+ }
18
+ },
19
+ {
20
+ "version": "4.0.0",
21
+ "tag": "@fgv/ts-utils_v4.0.0",
22
+ "date": "Tue, 14 May 2024 03:09:27 GMT",
23
+ "comments": {
24
+ "none": [
25
+ {
26
+ "comment": "rework validation/converter compatibility a bit"
27
+ },
28
+ {
29
+ "comment": "QoL improvement to simplify error aggregation"
30
+ },
31
+ {
32
+ "comment": "factor optional converters out to ts-extras package to eliminate large dependencies"
33
+ },
34
+ {
35
+ "comment": "update generated api docs"
36
+ },
37
+ {
38
+ "comment": "add convalidate helper"
39
+ },
40
+ {
41
+ "comment": "add defaulting converter"
42
+ },
43
+ {
44
+ "comment": "extend conversion to accept validators"
45
+ },
46
+ {
47
+ "comment": "export StringConverter at top level"
48
+ }
49
+ ]
50
+ }
51
+ },
4
52
  {
5
53
  "version": "3.0.0",
6
54
  "tag": "@fgv/ts-utils_v3.0.0",
package/CHANGELOG.md CHANGED
@@ -1,6 +1,28 @@
1
1
  # Change Log - @fgv/ts-utils
2
2
 
3
- This log was last generated on Mon, 22 Jan 2024 07:00:18 GMT and should not be manually modified.
3
+ This log was last generated on Tue, 14 May 2024 05:02:20 GMT and should not be manually modified.
4
+
5
+ ## 4.0.1
6
+ Tue, 14 May 2024 05:02:20 GMT
7
+
8
+ ### Updates
9
+
10
+ - publish
11
+ - import TextEncoder to avoid globals race
12
+
13
+ ## 4.0.0
14
+ Tue, 14 May 2024 03:09:27 GMT
15
+
16
+ ### Updates
17
+
18
+ - rework validation/converter compatibility a bit
19
+ - QoL improvement to simplify error aggregation
20
+ - factor optional converters out to ts-extras package to eliminate large dependencies
21
+ - update generated api docs
22
+ - add convalidate helper
23
+ - add defaulting converter
24
+ - extend conversion to accept validators
25
+ - export StringConverter at top level
4
26
 
5
27
  ## 3.0.0
6
28
  Mon, 22 Jan 2024 07:00:18 GMT
package/README.md CHANGED
@@ -11,12 +11,6 @@ Assorted typescript utilities that I'm tired of copying from project to project.
11
11
  * Result\<T\> - Easily combine inline and exception-based error handling
12
12
  * Converter\<T\> - Conversion framework especially useful for type-safe processing of JSON
13
13
 
14
- Also includes a few other much less-developed odds-and-ends borrowed from one project or another - much less polished and more likely change or disappear:
15
- * ExtendedArray\<T\> - adds a few useful operations to the built-in Array
16
- * Formattable\<T\> - simple helpers to create mustache wrappers for objects and make them easily printable
17
- * Logger - A very basic logger suitable for hobby projects
18
- * RangeOf\<T\> - Generic open or closed ranges of orderable items (numbers, dates, etc)
19
-
20
14
  ---
21
15
 
22
16
  - [Summary](#summary)
@@ -28,11 +22,6 @@ Also includes a few other much less-developed odds-and-ends borrowed from one pr
28
22
  - [API](#api)
29
23
  - [Result\<T\>](#resultt)
30
24
  - [Converter\<T\>](#convertert)
31
- - [Additional APIs](#additional-apis)
32
- - [ExtendedArray\<T\>](#extendedarrayt)
33
- - [Formattable\<T\>](#formattablet)
34
- - [Logger](#logger)
35
- - [RangeOf\<T\>](#rangeoft)
36
25
 
37
26
  ## Installation
38
27
 
@@ -139,15 +128,5 @@ Other helpers and methods enable optional values or fields, chaining of results
139
128
 
140
129
  ### Result\<T\>
141
130
 
142
-
143
131
  ### Converter\<T\>
144
132
 
145
- ## Additional APIs
146
-
147
- ### ExtendedArray\<T\>
148
-
149
- ### Formattable\<T\>
150
-
151
- ### Logger
152
-
153
- ### RangeOf\<T\>
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.42.1"
8
+ "packageVersion": "7.43.4"
9
9
  }
10
10
  ]
11
11
  }
@@ -1 +1 @@
1
- {"version":3,"file":"crcNormalizer.d.ts","sourceRoot":"","sources":["../../../src/packlets/hash/crcNormalizer.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAyCxD;;;;GAIG;AACH,qBAAa,eAAgB,SAAQ,iBAAiB;;WAKtC,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM;CAGjD"}
1
+ {"version":3,"file":"crcNormalizer.d.ts","sourceRoot":"","sources":["../../../src/packlets/hash/crcNormalizer.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAyCxD;;;;GAIG;AACH,qBAAa,eAAgB,SAAQ,iBAAiB;;WAKtC,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM;CAGjD"}
@@ -22,6 +22,7 @@
22
22
  */
23
23
  Object.defineProperty(exports, "__esModule", { value: true });
24
24
  exports.Crc32Normalizer = void 0;
25
+ const util_1 = require("util");
25
26
  const hashingNormalizer_1 = require("./hashingNormalizer");
26
27
  const POLYNOMIAL = 0xedb88320;
27
28
  const crc32Table = [];
@@ -68,7 +69,7 @@ class Crc32Normalizer extends hashingNormalizer_1.HashingNormalizer {
68
69
  super(Crc32Normalizer.crc32Hash);
69
70
  }
70
71
  static crc32Hash(parts) {
71
- return String(crc32(new TextEncoder().encode(parts.join('|'))));
72
+ return String(crc32(new util_1.TextEncoder().encode(parts.join('|'))));
72
73
  }
73
74
  }
74
75
  exports.Crc32Normalizer = Crc32Normalizer;
@@ -1 +1 @@
1
- {"version":3,"file":"crcNormalizer.js","sourceRoot":"","sources":["../../../src/packlets/hash/crcNormalizer.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;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C;qBAAM,CAAC;oBACN,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;gBACd,CAAC;YACH,CAAC;YACD,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;QAC/B,CAAC;IACH,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAa,eAAgB,SAAQ,qCAAiB;IACpD;QACE,KAAK,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;IACnC,CAAC;IAEM,MAAM,CAAC,SAAS,CAAC,KAAe;QACrC,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAClE,CAAC;CACF;AARD,0CAQC","sourcesContent":["/*\n * Copyright (c) 2023 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { HashingNormalizer } from './hashingNormalizer';\n\nconst POLYNOMIAL: number = 0xedb88320;\n\nconst crc32Table: number[] = [];\n\nfunction crc32(bytes: Uint8Array, crc: number = 0xffffffff): number {\n if (crc32Table.length === 0) {\n buildCrc32Table();\n }\n for (let i = 0; i < bytes.length; ++i) {\n // eslint-disable-next-line no-bitwise\n crc = crc32Table[(crc ^ bytes[i]) & 0xff] ^ (crc >>> 8);\n }\n return (crc ^ -1) >>> 0;\n}\n\nconst toUInt32 = (n: number): number => {\n if (n >= 0) {\n return n;\n }\n return 0xffffffff - n * -1 + 1;\n};\n\nfunction buildCrc32Table(): void {\n if (crc32Table.length === 0) {\n for (let n = 0; n < 256; n++) {\n let r = n;\n for (let i = 0; i < 8; i++) {\n // eslint-disable-next-line no-bitwise\n if (r & 1) {\n r = (r >>> 1) ^ POLYNOMIAL;\n } else {\n r = r >>> 1;\n }\n }\n crc32Table.push(toUInt32(r));\n }\n }\n}\n\n/**\n * A {@link Hash.HashingNormalizer | hashing normalizer} which computes object\n * hash using the CRC32 algorithm.\n * @public\n */\nexport class Crc32Normalizer extends HashingNormalizer {\n public constructor() {\n super(Crc32Normalizer.crc32Hash);\n }\n\n public static crc32Hash(parts: string[]): string {\n return String(crc32(new TextEncoder().encode(parts.join('|'))));\n }\n}\n"]}
1
+ {"version":3,"file":"crcNormalizer.js","sourceRoot":"","sources":["../../../src/packlets/hash/crcNormalizer.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAEH,+BAAmC;AACnC,2DAAwD;AAExD,MAAM,UAAU,GAAW,UAAU,CAAC;AAEtC,MAAM,UAAU,GAAa,EAAE,CAAC;AAEhC,SAAS,KAAK,CAAC,KAAiB,EAAE,MAAc,UAAU;IACxD,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC5B,eAAe,EAAE,CAAC;IACpB,CAAC;IACD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC;QACtC,sCAAsC;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IAAI,kBAAW,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAClE,CAAC;CACF;AARD,0CAQC","sourcesContent":["/*\n * Copyright (c) 2023 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { TextEncoder } from 'util';\nimport { HashingNormalizer } from './hashingNormalizer';\n\nconst POLYNOMIAL: number = 0xedb88320;\n\nconst crc32Table: number[] = [];\n\nfunction crc32(bytes: Uint8Array, crc: number = 0xffffffff): number {\n if (crc32Table.length === 0) {\n buildCrc32Table();\n }\n for (let i = 0; i < bytes.length; ++i) {\n // eslint-disable-next-line no-bitwise\n crc = crc32Table[(crc ^ bytes[i]) & 0xff] ^ (crc >>> 8);\n }\n return (crc ^ -1) >>> 0;\n}\n\nconst toUInt32 = (n: number): number => {\n if (n >= 0) {\n return n;\n }\n return 0xffffffff - n * -1 + 1;\n};\n\nfunction buildCrc32Table(): void {\n if (crc32Table.length === 0) {\n for (let n = 0; n < 256; n++) {\n let r = n;\n for (let i = 0; i < 8; i++) {\n // eslint-disable-next-line no-bitwise\n if (r & 1) {\n r = (r >>> 1) ^ POLYNOMIAL;\n } else {\n r = r >>> 1;\n }\n }\n crc32Table.push(toUInt32(r));\n }\n }\n}\n\n/**\n * A {@link Hash.HashingNormalizer | hashing normalizer} which computes object\n * hash using the CRC32 algorithm.\n * @public\n */\nexport class Crc32Normalizer extends HashingNormalizer {\n public constructor() {\n super(Crc32Normalizer.crc32Hash);\n }\n\n public static crc32Hash(parts: string[]): string {\n return String(crc32(new TextEncoder().encode(parts.join('|'))));\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fgv/ts-utils",
3
- "version": "3.0.1-alpha.6",
3
+ "version": "4.0.1",
4
4
  "description": "Assorted Typescript Utilities",
5
5
  "main": "lib/index.js",
6
6
  "types": "dist/ts-utils.d.ts",
@@ -29,14 +29,14 @@
29
29
  "homepage": "https://github.com/ErikFortune/fgv/tree/main/libraries/ts-utils#readme",
30
30
  "devDependencies": {
31
31
  "@jest/expect-utils": "^29.7.0",
32
- "@microsoft/api-documenter": "^7.23.34",
33
- "@microsoft/api-extractor": "^7.42.1",
32
+ "@microsoft/api-documenter": "^7.24.5",
33
+ "@microsoft/api-extractor": "^7.43.4",
34
34
  "@types/jest": "^29.5.12",
35
35
  "@types/luxon": "^3.4.2",
36
36
  "@types/mustache": "^4.2.5",
37
- "@types/node": "^20.11.24",
38
- "@typescript-eslint/eslint-plugin": "^7.1.0",
39
- "@typescript-eslint/parser": "^7.1.0",
37
+ "@types/node": "^20.12.11",
38
+ "@typescript-eslint/eslint-plugin": "^7.9.0",
39
+ "@typescript-eslint/parser": "^7.9.0",
40
40
  "eslint": "^8.57.0",
41
41
  "eslint-config-standard": "^17.1.0",
42
42
  "eslint-plugin-import": "^2.29.1",
@@ -45,17 +45,17 @@
45
45
  "jest": "^29.7.0",
46
46
  "jest-extended": "^4.0.2",
47
47
  "jest-matcher-utils": "^29.7.0",
48
- "rimraf": "^5.0.5",
48
+ "rimraf": "^5.0.7",
49
49
  "ts-jest": "^29.1.2",
50
50
  "ts-node": "^10.9.2",
51
- "typescript": "^5.3.3",
51
+ "typescript": "^5.4.5",
52
52
  "eslint-plugin-n": "^16.6.2",
53
53
  "jest-snapshot": "~29.7.0",
54
- "@rushstack/heft": "~0.65.8",
55
- "@rushstack/heft-node-rig": "~2.4.21",
56
- "@rushstack/eslint-config": "~3.6.4",
54
+ "@rushstack/heft": "~0.66.6",
55
+ "@rushstack/heft-node-rig": "~2.6.3",
56
+ "@rushstack/eslint-config": "~3.6.9",
57
57
  "@types/heft-jest": "1.0.6",
58
- "@rushstack/heft-jest-plugin": "~0.11.18",
58
+ "@rushstack/heft-jest-plugin": "~0.11.27",
59
59
  "eslint-plugin-tsdoc": "~0.2.17"
60
60
  }
61
61
  }