@fgv/ts-extras 5.0.0-8 → 5.0.1-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/CHANGELOG.json +9 -3
- package/dist/ts-extras.d.ts +111 -21
- package/dist/tsdoc-metadata.json +1 -1
- package/eslint.config.js +16 -0
- package/lib/index.browser.d.ts +6 -0
- package/lib/index.browser.js +69 -0
- package/lib/packlets/csv/csvFileHelpers.d.ts +21 -0
- package/lib/packlets/csv/csvFileHelpers.js +92 -0
- package/lib/packlets/csv/csvHelpers.d.ts +4 -4
- package/lib/packlets/csv/csvHelpers.js +5 -43
- package/lib/packlets/csv/index.d.ts +1 -0
- package/lib/packlets/csv/index.js +3 -0
- package/lib/packlets/hash/index.browser.d.ts +2 -0
- package/lib/packlets/hash/index.browser.js +40 -0
- package/lib/packlets/hash/index.node.d.ts +2 -0
- package/lib/packlets/hash/index.node.js +42 -0
- package/lib/packlets/hash/md5Normalizer.browser.d.ts +13 -0
- package/lib/packlets/hash/md5Normalizer.browser.js +38 -0
- package/lib/packlets/record-jar/index.d.ts +1 -0
- package/lib/packlets/record-jar/index.js +3 -0
- package/lib/packlets/record-jar/recordJarFileHelpers.d.ts +23 -0
- package/lib/packlets/record-jar/recordJarFileHelpers.js +97 -0
- package/lib/packlets/record-jar/recordJarHelpers.d.ts +0 -9
- package/lib/packlets/record-jar/recordJarHelpers.js +0 -53
- package/lib/packlets/zip-file-tree/zipFileTreeAccessors.d.ts +75 -18
- package/lib/packlets/zip-file-tree/zipFileTreeAccessors.js +109 -52
- package/package.json +46 -23
- package/CHANGELOG.md +0 -98
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/packlets/conversion/converters.d.ts.map +0 -1
- package/lib/packlets/conversion/converters.js.map +0 -1
- package/lib/packlets/conversion/index.d.ts.map +0 -1
- package/lib/packlets/conversion/index.js.map +0 -1
- package/lib/packlets/csv/csvHelpers.d.ts.map +0 -1
- package/lib/packlets/csv/csvHelpers.js.map +0 -1
- package/lib/packlets/csv/index.d.ts.map +0 -1
- package/lib/packlets/csv/index.js.map +0 -1
- package/lib/packlets/experimental/extendedArray.d.ts.map +0 -1
- package/lib/packlets/experimental/extendedArray.js.map +0 -1
- package/lib/packlets/experimental/formatter.d.ts.map +0 -1
- package/lib/packlets/experimental/formatter.js.map +0 -1
- package/lib/packlets/experimental/index.d.ts.map +0 -1
- package/lib/packlets/experimental/index.js.map +0 -1
- package/lib/packlets/experimental/rangeOf.d.ts.map +0 -1
- package/lib/packlets/experimental/rangeOf.js.map +0 -1
- package/lib/packlets/hash/index.d.ts.map +0 -1
- package/lib/packlets/hash/index.js.map +0 -1
- package/lib/packlets/hash/md5Normalizer.d.ts.map +0 -1
- package/lib/packlets/hash/md5Normalizer.js.map +0 -1
- package/lib/packlets/record-jar/index.d.ts.map +0 -1
- package/lib/packlets/record-jar/index.js.map +0 -1
- package/lib/packlets/record-jar/recordJarHelpers.d.ts.map +0 -1
- package/lib/packlets/record-jar/recordJarHelpers.js.map +0 -1
- package/lib/packlets/zip-file-tree/index.d.ts.map +0 -1
- package/lib/packlets/zip-file-tree/index.js.map +0 -1
- package/lib/packlets/zip-file-tree/zipFileTreeAccessors.d.ts.map +0 -1
- package/lib/packlets/zip-file-tree/zipFileTreeAccessors.js.map +0 -1
|
@@ -20,18 +20,25 @@
|
|
|
20
20
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
21
|
* SOFTWARE.
|
|
22
22
|
*/
|
|
23
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
24
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
25
|
-
};
|
|
26
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
24
|
exports.ZipFileTreeAccessors = exports.ZipDirectoryItem = exports.ZipFileItem = void 0;
|
|
28
|
-
const
|
|
25
|
+
const fflate_1 = require("fflate");
|
|
29
26
|
const ts_utils_1 = require("@fgv/ts-utils");
|
|
30
27
|
/**
|
|
31
28
|
* Implementation of `FileTree.IFileTreeFileItem` for files in a ZIP archive.
|
|
32
29
|
* @public
|
|
33
30
|
*/
|
|
34
31
|
class ZipFileItem {
|
|
32
|
+
/**
|
|
33
|
+
* The content type of the file.
|
|
34
|
+
*/
|
|
35
|
+
get contentType() {
|
|
36
|
+
if (this._contentType === undefined && this._shouldInferContentType) {
|
|
37
|
+
this._contentType = this._accessors.getFileContentType(this.absolutePath).orDefault();
|
|
38
|
+
this._shouldInferContentType = false;
|
|
39
|
+
}
|
|
40
|
+
return this._contentType;
|
|
41
|
+
}
|
|
35
42
|
/**
|
|
36
43
|
* Constructor for ZipFileItem.
|
|
37
44
|
* @param zipFilePath - The path of the file within the ZIP.
|
|
@@ -43,6 +50,10 @@ class ZipFileItem {
|
|
|
43
50
|
* Indicates that this `FileTree.FileTreeItem` is a file.
|
|
44
51
|
*/
|
|
45
52
|
this.type = 'file';
|
|
53
|
+
/**
|
|
54
|
+
* Flag to track if content type should be inferred on first access.
|
|
55
|
+
*/
|
|
56
|
+
this._shouldInferContentType = true;
|
|
46
57
|
this._contents = contents;
|
|
47
58
|
this._accessors = accessors;
|
|
48
59
|
this.absolutePath = '/' + zipFilePath;
|
|
@@ -50,21 +61,25 @@ class ZipFileItem {
|
|
|
50
61
|
this.extension = accessors.getExtension(zipFilePath);
|
|
51
62
|
this.baseName = accessors.getBaseName(zipFilePath, this.extension);
|
|
52
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* Sets the content type of the file.
|
|
66
|
+
* @param contentType - The content type of the file.
|
|
67
|
+
*/
|
|
68
|
+
setContentType(contentType) {
|
|
69
|
+
this._contentType = contentType;
|
|
70
|
+
this._shouldInferContentType = false;
|
|
71
|
+
}
|
|
53
72
|
getContents(converter) {
|
|
54
73
|
return this.getRawContents()
|
|
55
74
|
.onSuccess((contents) => {
|
|
56
|
-
return (0, ts_utils_1.captureResult)(() =>
|
|
57
|
-
|
|
75
|
+
return (0, ts_utils_1.captureResult)(() => JSON.parse(contents))
|
|
76
|
+
.onSuccess((parsed) => {
|
|
58
77
|
if (converter) {
|
|
59
|
-
|
|
60
|
-
return converter.convert(parsed);
|
|
61
|
-
} /* c8 ignore next 3 - validator branch functionally tested but coverage tool misses due to interface complexity */
|
|
62
|
-
else {
|
|
63
|
-
return converter.validate(parsed);
|
|
64
|
-
}
|
|
78
|
+
return converter.convert(parsed);
|
|
65
79
|
}
|
|
66
80
|
return (0, ts_utils_1.succeed)(parsed);
|
|
67
|
-
})
|
|
81
|
+
})
|
|
82
|
+
.onFailure(() => {
|
|
68
83
|
return (0, ts_utils_1.fail)(`Failed to parse JSON from file: ${this.absolutePath}`);
|
|
69
84
|
});
|
|
70
85
|
})
|
|
@@ -114,45 +129,77 @@ exports.ZipDirectoryItem = ZipDirectoryItem;
|
|
|
114
129
|
class ZipFileTreeAccessors {
|
|
115
130
|
/**
|
|
116
131
|
* Constructor for ZipFileTreeAccessors.
|
|
117
|
-
* @param
|
|
118
|
-
* @param
|
|
132
|
+
* @param files - The unzipped file data from fflate.
|
|
133
|
+
* @param params - Optional initialization parameters.
|
|
119
134
|
*/
|
|
120
|
-
constructor(
|
|
135
|
+
constructor(files, params) {
|
|
136
|
+
var _a;
|
|
121
137
|
/**
|
|
122
138
|
* Cache of all items in the ZIP for efficient lookups.
|
|
123
139
|
*/
|
|
124
140
|
this._itemCache = new Map();
|
|
125
|
-
this.
|
|
126
|
-
this._prefix = prefix || '';
|
|
141
|
+
this._files = files;
|
|
142
|
+
this._prefix = (params === null || params === void 0 ? void 0 : params.prefix) || '';
|
|
143
|
+
this._inferContentType = (_a = params === null || params === void 0 ? void 0 : params.inferContentType) !== null && _a !== void 0 ? _a : ZipFileTreeAccessors.defaultInferContentType;
|
|
127
144
|
this._buildItemCache();
|
|
128
145
|
}
|
|
129
146
|
/**
|
|
130
|
-
*
|
|
131
|
-
* @param
|
|
132
|
-
* @param
|
|
133
|
-
* @returns
|
|
147
|
+
* Default function to infer the content type of a file.
|
|
148
|
+
* @param filePath - The path of the file.
|
|
149
|
+
* @param provided - Optional supplied content type.
|
|
150
|
+
* @returns `Success` with the content type of the file if successful, or
|
|
151
|
+
* `Failure` with an error message otherwise.
|
|
152
|
+
* @remarks This default implementation always returns `Success` with `undefined`.
|
|
153
|
+
* @public
|
|
134
154
|
*/
|
|
135
|
-
static
|
|
155
|
+
static defaultInferContentType(__filePath, __provided) {
|
|
156
|
+
return (0, ts_utils_1.succeed)(undefined);
|
|
157
|
+
}
|
|
158
|
+
static fromBuffer(zipBuffer, params) {
|
|
136
159
|
try {
|
|
137
|
-
|
|
138
|
-
const
|
|
139
|
-
|
|
160
|
+
/* c8 ignore next 1 - defense in depth */
|
|
161
|
+
const uint8Buffer = zipBuffer instanceof Uint8Array ? zipBuffer : new Uint8Array(zipBuffer);
|
|
162
|
+
const files = (0, fflate_1.unzipSync)(uint8Buffer);
|
|
163
|
+
const normalizedParams = typeof params === 'string' ? { prefix: params } : params;
|
|
164
|
+
return (0, ts_utils_1.succeed)(new ZipFileTreeAccessors(files, normalizedParams));
|
|
140
165
|
}
|
|
141
166
|
catch (error) {
|
|
142
|
-
/* c8 ignore next 1 - defensive coding:
|
|
167
|
+
/* c8 ignore next 1 - defensive coding: fflate always throws Error objects in practice */
|
|
143
168
|
return (0, ts_utils_1.fail)(`Failed to load ZIP archive: ${error instanceof Error ? error.message : String(error)}`);
|
|
144
169
|
}
|
|
145
170
|
}
|
|
171
|
+
static async fromBufferAsync(zipBuffer, params) {
|
|
172
|
+
return new Promise((resolve) => {
|
|
173
|
+
try {
|
|
174
|
+
/* c8 ignore next 1 - defense in depth */
|
|
175
|
+
const uint8Buffer = zipBuffer instanceof Uint8Array ? zipBuffer : new Uint8Array(zipBuffer);
|
|
176
|
+
(0, fflate_1.unzip)(uint8Buffer, (err, files) => {
|
|
177
|
+
if (err) {
|
|
178
|
+
resolve((0, ts_utils_1.fail)(`Failed to load ZIP archive: ${err.message}`));
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
const normalizedParams = typeof params === 'string' ? { prefix: params } : params;
|
|
182
|
+
resolve((0, ts_utils_1.succeed)(new ZipFileTreeAccessors(files, normalizedParams)));
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
catch (error) {
|
|
187
|
+
/* c8 ignore next 5 - defensive coding: fflate always throws Error objects in practice */
|
|
188
|
+
resolve((0, ts_utils_1.fail)(`Failed to load ZIP archive: ${error instanceof Error ? error.message : String(error)}`));
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
}
|
|
146
192
|
/**
|
|
147
193
|
* Creates a new ZipFileTreeAccessors instance from a File object (browser environment).
|
|
148
194
|
* @param file - The File object containing ZIP data.
|
|
149
|
-
* @param
|
|
195
|
+
* @param params - Optional initialization parameters.
|
|
150
196
|
* @returns Result containing the ZipFileTreeAccessors instance.
|
|
151
197
|
*/
|
|
152
|
-
static async fromFile(file,
|
|
198
|
+
static async fromFile(file, params) {
|
|
153
199
|
try {
|
|
154
200
|
const arrayBuffer = await file.arrayBuffer();
|
|
155
|
-
|
|
201
|
+
const uint8Buffer = new Uint8Array(arrayBuffer);
|
|
202
|
+
return await ZipFileTreeAccessors.fromBufferAsync(uint8Buffer, params);
|
|
156
203
|
}
|
|
157
204
|
catch (error) {
|
|
158
205
|
return (0, ts_utils_1.fail)(`Failed to read file: ${error instanceof Error ? error.message : String(error)}`);
|
|
@@ -163,40 +210,38 @@ class ZipFileTreeAccessors {
|
|
|
163
210
|
*/
|
|
164
211
|
_buildItemCache() {
|
|
165
212
|
const directories = new Set();
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
const
|
|
172
|
-
|
|
173
|
-
const dirPath = pathParts.slice(0, i).join('/');
|
|
213
|
+
// Process all files and collect directory paths
|
|
214
|
+
for (const [relativePath, fileData] of Object.entries(this._files)) {
|
|
215
|
+
// Skip directories in fflate output (they have null data)
|
|
216
|
+
/* c8 ignore next 5 - handles explicit directory entries from external ZIP tools (fflate doesn't create these) */
|
|
217
|
+
if (fileData === null || fileData === undefined) {
|
|
218
|
+
const dirPath = relativePath.replace(/\/$/, '');
|
|
219
|
+
if (dirPath) {
|
|
174
220
|
directories.add(dirPath);
|
|
175
221
|
}
|
|
176
222
|
}
|
|
177
223
|
else {
|
|
178
|
-
//
|
|
179
|
-
const
|
|
180
|
-
|
|
181
|
-
|
|
224
|
+
// Extract directory paths from file paths
|
|
225
|
+
const pathParts = relativePath.split('/');
|
|
226
|
+
for (let i = 1; i < pathParts.length; i++) {
|
|
227
|
+
const dirPath = pathParts.slice(0, i).join('/');
|
|
228
|
+
if (dirPath) {
|
|
229
|
+
directories.add(dirPath);
|
|
230
|
+
}
|
|
182
231
|
}
|
|
232
|
+
// Add the file item with its contents
|
|
233
|
+
const absolutePath = this.resolveAbsolutePath(relativePath);
|
|
234
|
+
const contents = new TextDecoder().decode(fileData);
|
|
235
|
+
const item = new ZipFileItem(relativePath, contents, this);
|
|
236
|
+
this._itemCache.set(absolutePath, item);
|
|
183
237
|
}
|
|
184
|
-
}
|
|
238
|
+
}
|
|
185
239
|
// Add directory items to cache
|
|
186
240
|
directories.forEach((dirPath) => {
|
|
187
241
|
const absolutePath = this.resolveAbsolutePath(dirPath);
|
|
188
242
|
const item = new ZipDirectoryItem(dirPath, this);
|
|
189
243
|
this._itemCache.set(absolutePath, item);
|
|
190
244
|
});
|
|
191
|
-
// Add file items to cache
|
|
192
|
-
entries.forEach((entry) => {
|
|
193
|
-
if (!entry.isDirectory) {
|
|
194
|
-
const absolutePath = this.resolveAbsolutePath(entry.entryName);
|
|
195
|
-
const contents = entry.getData().toString('utf8');
|
|
196
|
-
const item = new ZipFileItem(entry.entryName, contents, this);
|
|
197
|
-
this._itemCache.set(absolutePath, item);
|
|
198
|
-
}
|
|
199
|
-
});
|
|
200
245
|
}
|
|
201
246
|
/**
|
|
202
247
|
* Resolves paths to an absolute path.
|
|
@@ -258,6 +303,18 @@ class ZipFileTreeAccessors {
|
|
|
258
303
|
return item.getRawContents();
|
|
259
304
|
});
|
|
260
305
|
}
|
|
306
|
+
/**
|
|
307
|
+
* Gets the content type of a file in the file tree.
|
|
308
|
+
*/
|
|
309
|
+
getFileContentType(path, provided) {
|
|
310
|
+
// If provided contentType is given, use it directly (highest priority)
|
|
311
|
+
if (provided !== undefined) {
|
|
312
|
+
return (0, ts_utils_1.succeed)(provided);
|
|
313
|
+
}
|
|
314
|
+
// For files that exist in the ZIP, we don't store explicit contentType
|
|
315
|
+
// so we always fall back to inference
|
|
316
|
+
return this._inferContentType(path);
|
|
317
|
+
}
|
|
261
318
|
/**
|
|
262
319
|
* Gets the children of a directory in the file tree.
|
|
263
320
|
*/
|
package/package.json
CHANGED
|
@@ -1,9 +1,32 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fgv/ts-extras",
|
|
3
|
-
"version": "5.0.0
|
|
3
|
+
"version": "5.0.1-0",
|
|
4
4
|
"description": "Assorted Typescript Utilities",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "dist/ts-extras.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"node": {
|
|
10
|
+
"import": "./lib/index.js",
|
|
11
|
+
"require": "./lib/index.js"
|
|
12
|
+
},
|
|
13
|
+
"default": {
|
|
14
|
+
"import": "./lib/index.browser.js",
|
|
15
|
+
"require": "./lib/index.browser.js"
|
|
16
|
+
},
|
|
17
|
+
"types": "./dist/ts-extras.d.ts"
|
|
18
|
+
},
|
|
19
|
+
"./hash": {
|
|
20
|
+
"node": {
|
|
21
|
+
"import": "./lib/packlets/hash/index.node.js",
|
|
22
|
+
"require": "./lib/packlets/hash/index.node.js"
|
|
23
|
+
},
|
|
24
|
+
"default": {
|
|
25
|
+
"import": "./lib/packlets/hash/index.browser.js",
|
|
26
|
+
"require": "./lib/packlets/hash/index.browser.js"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
},
|
|
7
30
|
"sideEffects": false,
|
|
8
31
|
"keywords": [
|
|
9
32
|
"typescript",
|
|
@@ -17,49 +40,49 @@
|
|
|
17
40
|
"homepage": "https://github.com/ErikFortune/fgv/tree/main/libraries/ts-extras#ts-utils",
|
|
18
41
|
"devDependencies": {
|
|
19
42
|
"@jest/expect-utils": "^29.7.0",
|
|
20
|
-
"@microsoft/api-documenter": "^7.26.
|
|
21
|
-
"@microsoft/api-extractor": "^7.
|
|
43
|
+
"@microsoft/api-documenter": "^7.26.31",
|
|
44
|
+
"@microsoft/api-extractor": "^7.52.10",
|
|
22
45
|
"@types/jest": "^29.5.14",
|
|
23
|
-
"@types/luxon": "^3.
|
|
46
|
+
"@types/luxon": "^3.7.1",
|
|
24
47
|
"@types/mustache": "^4.2.5",
|
|
25
48
|
"@types/node": "^20.14.9",
|
|
26
49
|
"@types/papaparse": "^5.3.14",
|
|
27
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
28
|
-
"@typescript-eslint/parser": "^
|
|
29
|
-
"eslint": "^
|
|
50
|
+
"@typescript-eslint/eslint-plugin": "^8.42.0",
|
|
51
|
+
"@typescript-eslint/parser": "^8.42.0",
|
|
52
|
+
"eslint": "^9.35.0",
|
|
30
53
|
"eslint-plugin-import": "^2.32.0",
|
|
31
54
|
"eslint-plugin-node": "^11.1.0",
|
|
32
|
-
"eslint-plugin-promise": "^
|
|
55
|
+
"eslint-plugin-promise": "^7.2.1",
|
|
33
56
|
"jest": "^29.7.0",
|
|
34
57
|
"jest-extended": "^4.0.2",
|
|
35
58
|
"jest-matcher-utils": "^29.7.0",
|
|
36
|
-
"rimraf": "^
|
|
37
|
-
"ts-jest": "^29.4.
|
|
59
|
+
"rimraf": "^6.0.1",
|
|
60
|
+
"ts-jest": "^29.4.1",
|
|
38
61
|
"ts-node": "^10.9.2",
|
|
39
|
-
"typescript": "
|
|
40
|
-
"eslint-plugin-n": "^
|
|
62
|
+
"typescript": "5.8.3",
|
|
63
|
+
"eslint-plugin-n": "^17.21.3",
|
|
41
64
|
"jest-snapshot": "~29.7.0",
|
|
42
|
-
"@rushstack/heft": "
|
|
43
|
-
"@rushstack/heft-node-rig": "
|
|
44
|
-
"@rushstack/eslint-config": "
|
|
65
|
+
"@rushstack/heft": "0.74.4",
|
|
66
|
+
"@rushstack/heft-node-rig": "2.9.5",
|
|
67
|
+
"@rushstack/eslint-config": "4.4.0",
|
|
45
68
|
"@types/heft-jest": "1.0.6",
|
|
46
|
-
"@rushstack/heft-jest-plugin": "
|
|
69
|
+
"@rushstack/heft-jest-plugin": "0.16.13",
|
|
47
70
|
"eslint-plugin-tsdoc": "~0.4.0",
|
|
48
|
-
"@fgv/ts-utils-jest": "5.0.0
|
|
49
|
-
"@fgv/ts-utils": "5.0.0
|
|
71
|
+
"@fgv/ts-utils-jest": "5.0.1-0",
|
|
72
|
+
"@fgv/ts-utils": "5.0.1-0"
|
|
50
73
|
},
|
|
51
74
|
"dependencies": {
|
|
52
|
-
"luxon": "^3.
|
|
75
|
+
"luxon": "^3.7.2",
|
|
53
76
|
"mustache": "^4.2.0",
|
|
54
77
|
"papaparse": "^5.4.1",
|
|
55
|
-
"
|
|
56
|
-
"
|
|
78
|
+
"fflate": "~0.8.2",
|
|
79
|
+
"@fgv/ts-json-base": "5.0.1-0"
|
|
57
80
|
},
|
|
58
81
|
"peerDependencies": {
|
|
59
|
-
"@fgv/ts-utils": "5.0.0
|
|
82
|
+
"@fgv/ts-utils": "5.0.1-0"
|
|
60
83
|
},
|
|
61
84
|
"scripts": {
|
|
62
|
-
"build": "heft
|
|
85
|
+
"build": "heft build --clean",
|
|
63
86
|
"clean": "heft clean",
|
|
64
87
|
"test": "heft test --clean",
|
|
65
88
|
"build-docs": "api-documenter markdown --input-folder ./temp --output-folder docs",
|
package/CHANGELOG.md
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
# Change Log - @fgv/ts-extras
|
|
2
|
-
|
|
3
|
-
This log was last generated on Thu, 17 Jul 2025 00:13:24 GMT and should not be manually modified.
|
|
4
|
-
|
|
5
|
-
## 5.0.0
|
|
6
|
-
Thu, 17 Jul 2025 00:13:24 GMT
|
|
7
|
-
|
|
8
|
-
### Updates
|
|
9
|
-
|
|
10
|
-
- upgrade dependencies
|
|
11
|
-
- bump version
|
|
12
|
-
|
|
13
|
-
## 4.6.0
|
|
14
|
-
Wed, 02 Jul 2025 05:48:16 GMT
|
|
15
|
-
|
|
16
|
-
_Version update only_
|
|
17
|
-
|
|
18
|
-
## 4.5.1
|
|
19
|
-
Wed, 02 Jul 2025 05:47:11 GMT
|
|
20
|
-
|
|
21
|
-
### Updates
|
|
22
|
-
|
|
23
|
-
- update rushstack
|
|
24
|
-
|
|
25
|
-
## 4.5.0
|
|
26
|
-
Tue, 01 Jul 2025 03:26:11 GMT
|
|
27
|
-
|
|
28
|
-
_Version update only_
|
|
29
|
-
|
|
30
|
-
## 4.4.0
|
|
31
|
-
Sat, 01 Feb 2025 17:13:10 GMT
|
|
32
|
-
|
|
33
|
-
_Version update only_
|
|
34
|
-
|
|
35
|
-
## 4.3.0
|
|
36
|
-
Thu, 30 Jan 2025 00:35:17 GMT
|
|
37
|
-
|
|
38
|
-
_Version update only_
|
|
39
|
-
|
|
40
|
-
## 4.2.2
|
|
41
|
-
Thu, 23 Jan 2025 06:19:32 GMT
|
|
42
|
-
|
|
43
|
-
_Version update only_
|
|
44
|
-
|
|
45
|
-
## 4.2.1
|
|
46
|
-
Tue, 21 Jan 2025 04:19:21 GMT
|
|
47
|
-
|
|
48
|
-
_Version update only_
|
|
49
|
-
|
|
50
|
-
## 4.2.0
|
|
51
|
-
Mon, 20 Jan 2025 09:46:53 GMT
|
|
52
|
-
|
|
53
|
-
_Version update only_
|
|
54
|
-
|
|
55
|
-
## 4.1.0
|
|
56
|
-
Thu, 09 Jan 2025 05:33:39 GMT
|
|
57
|
-
|
|
58
|
-
### Updates
|
|
59
|
-
|
|
60
|
-
- update dependencies
|
|
61
|
-
|
|
62
|
-
## 4.0.2
|
|
63
|
-
Tue, 14 May 2024 14:45:53 GMT
|
|
64
|
-
|
|
65
|
-
_Version update only_
|
|
66
|
-
|
|
67
|
-
## 4.0.1
|
|
68
|
-
Tue, 14 May 2024 05:02:20 GMT
|
|
69
|
-
|
|
70
|
-
### Updates
|
|
71
|
-
|
|
72
|
-
- publish
|
|
73
|
-
|
|
74
|
-
## 4.0.0
|
|
75
|
-
Tue, 14 May 2024 03:09:27 GMT
|
|
76
|
-
|
|
77
|
-
### Updates
|
|
78
|
-
|
|
79
|
-
- move templateString, rangeOf and isoDate converters from ts-utils
|
|
80
|
-
- update generated api docs
|
|
81
|
-
|
|
82
|
-
## 3.0.0
|
|
83
|
-
Mon, 22 Jan 2024 07:00:18 GMT
|
|
84
|
-
|
|
85
|
-
### Updates
|
|
86
|
-
|
|
87
|
-
- refactor hash implementation
|
|
88
|
-
- refactor and cleanup
|
|
89
|
-
- Factor extras into their own package
|
|
90
|
-
|
|
91
|
-
## 2.2.0
|
|
92
|
-
Thu, 18 Jan 2024 05:45:04 GMT
|
|
93
|
-
|
|
94
|
-
### Updates
|
|
95
|
-
|
|
96
|
-
- refactor and cleanup
|
|
97
|
-
- Factor extras into their own package
|
|
98
|
-
|
package/lib/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAC;AACtC,OAAO,KAAK,YAAY,MAAM,yBAAyB,CAAC;AACxD,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,KAAK,SAAS,MAAM,uBAAuB,CAAC;AACnD,OAAO,KAAK,WAAW,MAAM,0BAA0B,CAAC;AAExD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,YAAY,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC"}
|
package/lib/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,oDAAsC;AAQjB,kBAAG;AAPxB,sEAAwD;AAO9B,oCAAY;AANtC,sDAAwC;AAMA,oBAAI;AAL5C,iEAAmD;AAKL,8BAAS;AAJvD,sEAAwD;AAIC,kCAAW;AAFpE,sDAAmD;AAE1C,2FAFA,uBAAU,OAEA","sourcesContent":["/*\n * Copyright (c) 2020 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 * as Csv from './packlets/csv';\nimport * as Experimental from './packlets/experimental';\nimport * as Hash from './packlets/hash';\nimport * as RecordJar from './packlets/record-jar';\nimport * as ZipFileTree from './packlets/zip-file-tree';\n\nimport { Converters } from './packlets/conversion';\n\nexport { Converters, Csv, Experimental, Hash, RecordJar, ZipFileTree };\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"converters.d.ts","sourceRoot":"","sources":["../../../src/packlets/conversion/converters.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAc,MAAM,EAAgC,MAAM,eAAe,CAAC;AAGxG,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAE5E;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,cAAc,CAAC,EAAE,OAAO,GAAG,UAAU,CAAC,eAAe,CAAC,MAAM,EAAE,OAAO,CAAC,CAWpG;AAED;;;;GAIG;AACH,eAAO,MAAM,OAAO,EAAE,SAAS,CAAC,IAAI,EAAE,OAAO,CAa3C,CAAC;AAEH;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,EAAE,GAAG,SAAS,EAC/C,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,EAC3B,OAAO,GAAE,UAAU,CAAC,OAAuB,GAC1C,SAAS,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAIjC;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,EAAE,SAAS,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,GAAG,OAAO,EAChE,SAAS,EAAE,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,EAC3B,WAAW,EAAE,CAAC,IAAI,EAAE,iBAAiB,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,EAAE,CAAC,GACtD,SAAS,CAAC,EAAE,EAAE,EAAE,CAAC,CAcnB;AAED;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,EAAE,GAAG,OAAO,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC,EAAE,EAAE,CA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AAC,CAAC;QACvE,CAAC;QACD,OAAO,IAAA,eAAI,EAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAC9B,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;;GAKG;AACH,SAAgB,OAAO,CAAkB,SAA2B;IAClE,OAAO,WAAW,CAAoB,SAAS,EAAE,sBAAO,CAAC,WAAW,CAAC,CAAC;AACxE,CAAC","sourcesContent":["/*\n * Copyright (c) 2020 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 { Conversion, Converter, Converters, Result, captureResult, fail, succeed } from '@fgv/ts-utils';\nimport { DateTime } from 'luxon';\nimport Mustache from 'mustache';\nimport { ExtendedArray, RangeOf, RangeOfProperties } from '../experimental';\n\n/**\n * Helper function to create a `StringConverter` which converts\n * `unknown` to `string`, applying template conversions supplied at construction time or at\n * runtime as context.\n * @remarks\n * Template conversions are applied using `mustache` syntax.\n * @param defaultContext - Optional default context to use for template values.\n * @returns A new `Converter` returning `string`.\n * @public\n */\nexport function templateString(defaultContext?: unknown): Conversion.StringConverter<string, unknown> {\n return new Conversion.StringConverter<string, unknown>(\n defaultContext,\n undefined,\n (from: unknown, __self: Converter<string, unknown>, context?: unknown) => {\n if (typeof from !== 'string') {\n return fail(`Not a string: ${JSON.stringify(from)}`);\n }\n return captureResult(() => Mustache.render(from, context));\n }\n );\n}\n\n/**\n * A `Converter` which converts an iso formatted string, a number or a `Date` object to\n * a `Date` object.\n * @public\n */\nexport const isoDate: Converter<Date, unknown> = new Conversion.BaseConverter<Date>((from: unknown) => {\n if (typeof from === 'string') {\n const dt = DateTime.fromISO(from);\n if (dt.isValid) {\n return succeed(dt.toJSDate());\n }\n return fail(`Invalid date: ${dt.invalidExplanation}`);\n } else if (typeof from === 'number') {\n return succeed(new Date(from));\n } else if (from instanceof Date) {\n return succeed(from);\n }\n return fail(`Cannot convert ${JSON.stringify(from)} to Date`);\n});\n\n/**\n * A helper function to create a `Converter` which converts `unknown` to {@link Experimental.ExtendedArray | ExtendedArray<T>}.\n * @remarks\n * If `onError` is `'failOnError'` (default), then the entire conversion fails if any element cannot\n * be converted. If `onError` is `'ignoreErrors'`, then failing elements are silently ignored.\n * @param converter - `Converter` used to convert each item in the array\n * @param ignoreErrors - Specifies treatment of unconvertible elements\n * @beta\n */\nexport function extendedArrayOf<T, TC = undefined>(\n label: string,\n converter: Converter<T, TC>,\n onError: Conversion.OnError = 'failOnError'\n): Converter<ExtendedArray<T>, TC> {\n return Converters.arrayOf(converter, onError).map((items: T[]) => {\n return captureResult(() => new ExtendedArray(label, ...items));\n });\n}\n\n/**\n * A helper wrapper to construct a `Converter` which converts to an arbitrary strongly-typed\n * range of some comparable type.\n * @param converter - `Converter` used to convert `min` and `max` extent of the range.\n * @param constructor - Static constructor to instantiate the object.\n * @public\n */\nexport function rangeTypeOf<T, RT extends RangeOf<T>, TC = unknown>(\n converter: Converter<T, TC>,\n constructor: (init: RangeOfProperties<T>) => Result<RT>\n): Converter<RT, TC> {\n return new Conversion.BaseConverter((from: unknown, __self, context?: TC) => {\n const result = Converters.object(\n {\n min: converter,\n max: converter\n },\n { optionalFields: ['min', 'max'] }\n ).convert(from, context);\n if (result.isSuccess()) {\n return constructor({ min: result.value.min, max: result.value.max });\n }\n return fail(result.message);\n });\n}\n\n/**\n * A helper wrapper to construct a `Converter` which converts to {@link Experimental.RangeOf | RangeOf<T>}\n * where `<T>` is some comparable type.\n * @param converter - `Converter` used to convert `min` and `max` extent of the range.\n * @public\n */\nexport function rangeOf<T, TC = unknown>(converter: Converter<T, TC>): Converter<RangeOf<T>, TC> {\n return rangeTypeOf<T, RangeOf<T>, TC>(converter, RangeOf.createRange);\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/packlets/conversion/index.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,UAAU,MAAM,cAAc,CAAC;AAE3C,OAAO,EAAE,UAAU,EAAE,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/packlets/conversion/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,yDAA2C;AAElC,gCAAU","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 * as Converters from './converters';\n\nexport { Converters };\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"csvHelpers.d.ts","sourceRoot":"","sources":["../../../src/packlets/csv/csvHelpers.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,MAAM,EAAiB,MAAM,eAAe,CAAC;AAKtD;;;GAGG;AAEH,MAAM,WAAW,UAAU;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC,CActF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"csvHelpers.js","sourceRoot":"","sources":["../../../src/packlets/csv/csvHelpers.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuBH,0CAcC;AAnCD,4CAAsD;AACtD,uCAAyB;AACzB,yCAAkC;AAClC,2CAA6B;AAW7B;;;;;;GAMG;AACH,SAAgB,eAAe,CAAC,OAAe,EAAE,OAAoB;IACnE,OAAO,IAAA,wBAAa,EAAC,GAAG,EAAE;QACxB,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QACvC,MAAM,IAAI,GAAG,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,QAAQ,EAAE,CAAC;QAC1D,OAAO,GAAG,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,EAAE,CAAC;QACxB,2BAA2B;QAC3B,OAAO,IAAA,iBAAK,EAAC,IAAI,kBACf,SAAS,EAAE,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,EAClC,MAAM,EAAE,KAAK,EACb,aAAa,EAAE,KAAK,EACpB,cAAc,EAAE,QAAQ,IACrB,OAAO,EACV,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACnB,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["/*\n * Copyright (c) 2020 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 { Result, captureResult } from '@fgv/ts-utils';\nimport * as fs from 'fs';\nimport { parse } from 'papaparse';\nimport * as path from 'path';\n\n/**\n * Options for {@link Csv.readCsvFileSync | readCsvFileSync}\n * @beta\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport interface CsvOptions {\n delimiter?: string;\n}\n\n/**\n * Reads a CSV file from a supplied path.\n * @param srcPath - Source path from which the file is read.\n * @param options - optional parameters to control the processing\n * @returns The contents of the file.\n * @beta\n */\nexport function readCsvFileSync(srcPath: string, options?: CsvOptions): Result<unknown> {\n return captureResult(() => {\n const fullPath = path.resolve(srcPath);\n const body = fs.readFileSync(fullPath, 'utf8').toString();\n options = options ?? {};\n // eslint-disable-next-line\n return parse(body, {\n transform: (s: string) => s.trim(),\n header: false,\n dynamicTyping: false,\n skipEmptyLines: 'greedy',\n ...options\n }).data.slice(1);\n });\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/packlets/csv/index.ts"],"names":[],"mappings":"AAsBA,cAAc,cAAc,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/packlets/csv/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;AAEH,+CAA6B","sourcesContent":["/*\n * Copyright (c) 2020 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\nexport * from './csvHelpers';\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extendedArray.d.ts","sourceRoot":"","sources":["../../../src/packlets/experimental/extendedArray.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,MAAM,EAAiB,MAAM,eAAe,CAAC;AAEtD;;;;GAIG;AACH,qBAAa,aAAa,CAAC,CAAC,CAAE,SAAQ,KAAK,CAAC,CAAC,CAAC;IAC5C,SAAgB,eAAe,EAAE,MAAM,CAAC;IAExC;;;;OAIG;gBACgB,eAAe,EAAE,MAAM,EAAE,GAAG,KAAK,EAAE,CAAC,EAAE;IAKzD;;;;;;OAMG;WACW,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,IAAI,aAAa,CAAC,CAAC,CAAC;IAIhE;;;;;;;OAOG;IACI,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,OAAO,GAAG,MAAM,CAAC,CAAC,CAAC;IAW1D;;;;;;OAMG;IACI,KAAK,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC;IAO7C;;;;;;;OAOG;IACI,UAAU,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC,EAAE,CAAC;IAOpD;;;;OAIG;IACI,GAAG,IAAI,CAAC,EAAE;CAGlB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extendedArray.js","sourceRoot":"","sources":["../../../src/packlets/experimental/extendedArray.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAEH,4CAAsD;AAEtD;;;;GAIG;AACH,MAAa,aAAiB,SAAQ,KAAQ;IAG5C;;;;OAIG;IACH,YAAmB,eAAuB,EAAE,G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,OAAO,IAAA,eAAI,EAAC,WAAW,aAAX,WAAW,cAAX,WAAW,GAAI,GAAG,IAAI,CAAC,eAAe,YAAY,CAAC,CAAC;IAClE,CAAC;IAED;;;;OAIG;IACI,GAAG;QACR,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;CACF;AAhFD,sCAgFC","sourcesContent":["/*\r\n * Copyright (c) 2020 Erik Fortune\r\n *\r\n * Permission is hereby granted, free of charge, to any person obtaining a copy\r\n * of this software and associated documentation files (the \"Software\"), to deal\r\n * in the Software without restriction, including without limitation the rights\r\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n * copies of the Software, and to permit persons to whom the Software is\r\n * furnished to do so, subject to the following conditions:\r\n *\r\n * The above copyright notice and this permission notice shall be included in all\r\n * copies or substantial portions of the Software.\r\n *\r\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r\n * SOFTWARE.\r\n */\r\n\r\nimport { Result, fail, succeed } from '@fgv/ts-utils';\r\n\r\n/**\r\n * An experimental array template which extend built-in `Array` to include a handful\r\n * of predicates which return `Result<T>`.\r\n * @beta\r\n */\r\nexport class ExtendedArray<T> extends Array<T> {\r\n public readonly itemDescription: string;\r\n\r\n /**\r\n * Constructs an {@link Experimental.ExtendedArray | ExtendedArray}.\r\n * @param itemDescription - Brief description of the type of each item in this array.\r\n * @param items - The initial contents of the array.\r\n */\r\n public constructor(itemDescription: string, ...items: T[]) {\r\n super(...items);\r\n this.itemDescription = itemDescription;\r\n }\r\n\r\n /**\r\n * Type guard to determine if some arbitrary array is an\r\n * {@link Experimental.ExtendedArray}\r\n * @param a - The `Array` to be tested.\r\n * @returns Returns `true` if `a` is an {@link Experimental.ExtendedArray | ExtendedArray},\r\n * `false` otherwise.\r\n */\r\n public static isExtendedArray<T>(a?: T[]): a is ExtendedArray<T> {\r\n return a instanceof ExtendedArray;\r\n }\r\n\r\n /**\r\n * Determines if this array contains exactly one element which matches\r\n * a supplied predicate.\r\n * @param predicate - The predicate function to be applied.\r\n * @returns Returns `Success<T>` with the single matching\r\n * result if exactly one item matches `predicate`. Returns `Failure<T>`\r\n * with an error message if there are no matches or more than one match.\r\n */\r\n public single(predicate?: (item: T) => boolean): Result<T> {\r\n const match = predicate ? this.filter(predicate) : this;\r\n if (match.length === 1) {\r\n return succeed(match[0]);\r\n }\r\n if (match.length === 0) {\r\n return fail(`${this.itemDescription} not found`);\r\n }\r\n return fail(`${this.itemDescription} matches ${match.length} items`);\r\n }\r\n\r\n /**\r\n * Returns the first element of an {@link Experimental.ExtendedArray | ExtendedArray}. Fails with an\r\n * error message if the array is empty.\r\n * @param failMessage - Optional message to be displayed in the event of failure.\r\n * @returns Returns `Success<T>` with the value of the first element\r\n * in the array, or `Failure<T>` with an error message if the array is empty.\r\n */\r\n public first(failMessage?: string): Result<T> {\r\n if (this.length > 0) {\r\n return succeed(this[0]);\r\n }\r\n return fail(failMessage ?? `${this.itemDescription} not found`);\r\n }\r\n\r\n /**\r\n * Returns an array containing all elements of an {@link Experimental.ExtendedArray | ExtendedArray}.\r\n * Fails with an error message if the array is empty.\r\n * @param failMessage - Optional message to be displayed in the event of failure.\r\n * @returns Returns `Success<T>` with a new (non-extended) `Array`\r\n * containing the elements of this array, or `Failure<T>` with an error message\r\n * if the array is empty.\r\n */\r\n public atLeastOne(failMessage?: string): Result<T[]> {\r\n if (this.length > 0) {\r\n return succeed(Array.from(this));\r\n }\r\n return fail(failMessage ?? `${this.itemDescription} not found`);\r\n }\r\n\r\n /**\r\n * Gets a new (non-extended) `Array` containing all of the elements from this\r\n * {@link Experimental.ExtendedArray | ExtendedArray}.\r\n * @returns A new (non-extended) `Array<T>`.\r\n */\r\n public all(): T[] {\r\n return Array.from(this);\r\n }\r\n}\r\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"formatter.d.ts","sourceRoot":"","sources":["../../../src/packlets/experimental/formatter.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,MAAM,EAAsC,MAAM,eAAe,CAAC;AAK3E;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,UAAU,GAAG,OAAO,CAAC;AAE1D;;;GAGG;AAEH,MAAM,WAAW,WAAW;IAC1B;;;;;OAKG;IACH,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;CACxC;AAED;;;GAGG;AACH,qBAAa,eAAe;IAC1B;;;;;;OAMG;IACH,SAAS,CAAC,MAAM,CAAC,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI;IAOjG;;OAEG;IACI,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;CAGhD;AAED;;;;GAIG;AACH,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,KAAK,MAAM,CAAC,MAAM,CAAC,CAAC;AAEvE;;;;GAIG;AACH,MAAM,MAAM,0BAA0B,CAAC,GAAG,SAAS,aAAa,EAAE,CAAC,IAAI,MAAM,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;AACjG;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,CAAC,CAAC,IAAI,0BAA0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;IACrC,CAAC,CAAC,CACH,CAAC,SAAS,CAAC,CAAC,OAAiB,EAAE,EAAE;QAChC,MAAM,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC;QACjD,OAAO,IAAA,kBAAO,EAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACtC,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["/*\n * Copyright (c) 2020 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 { Result, captureResult, mapResults, succeed } from '@fgv/ts-utils';\nimport Mustache from 'mustache';\n\nMustache.escape = (s: string) => s;\n\n/**\n * Destination format for some formatted string.\n * @beta\n */\nexport type FormatTargets = 'text' | 'markdown' | 'embed';\n\n/**\n * Interface for an object that can be formatted.\n * @beta\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport interface Formattable {\n /**\n * Formats an object using the supplied mustache template.\n * @param format - A mustache template used to format the object.\n * @returns `Success<string>` with the resulting string, or `Failure<string>`\n * with an error message if an error occurs.\n */\n format(format: string): Result<string>;\n}\n\n/**\n * Base class which adds common formatting.\n * @beta\n */\nexport class FormattableBase {\n /**\n * Helper enables derived classes to add named details to a formatted presentation.\n * @param details - An array of detail description strings.\n * @param label - Label to use for the new detail.\n * @param value - Value to use for the new detail.\n * @internal\n */\n protected static _tryAddDetail(details: string[], label: string, value: string | undefined): void {\n if (value !== undefined) {\n const padded = ` ${label}:`.padEnd(20, ' ');\n details.push(`${padded} ${value}`);\n }\n }\n\n /**\n * {@inheritdoc Experimental.Formattable.format}\n */\n public format(template: string): Result<string> {\n return captureResult(() => Mustache.render(template, this));\n }\n}\n\n/**\n * Type definition for a formatting function, which takes a `string` and an\n * item and returns `Result<string>`.\n * @beta\n */\nexport type Formatter<T> = (format: string, item: T) => Result<string>;\n\n/**\n * A collection of {@link Experimental.Formatter | formatters} indexed by target name, to enable\n * different format methods per output target.\n * @beta\n */\nexport type FormattersByExtendedTarget<TFT extends FormatTargets, T> = Record<TFT, Formatter<T>>;\n/**\n * A collection of {@link Experimental.Formatter | formatters} indexed by the\n * {@link Experimental.FormatTargets | default supported target formats}.\n * @beta\n */\nexport type FormattersByTarget<T> = FormattersByExtendedTarget<FormatTargets, T>;\n\n/**\n * Formats a list of items using the supplied template and formatter, one result\n * per output line.\n * @param format - A mustache template used to format each item.\n * @param items - The items to be formatted.\n * @param itemFormatter - The {@link Experimental.Formatter | Formatter<T>} used to format each item.\n * @returns The resulting string.\n * @beta\n */\nexport function formatList<T>(format: string, items: T[], itemFormatter: Formatter<T>): Result<string> {\n return mapResults(\n items.map((item) => {\n return itemFormatter(format, item);\n })\n ).onSuccess((results: string[]) => {\n const filtered = results.filter((s) => s !== '');\n return succeed(filtered.join('\\n'));\n });\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/packlets/experimental/index.ts"],"names":[],"mappings":"AAsBA,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/packlets/experimental/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;AAEH,kDAAgC;AAChC,8CAA4B;AAC5B,4CAA0B","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\nexport * from './extendedArray';\nexport * from './formatter';\nexport * from './rangeOf';\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rangeOf.d.ts","sourceRoot":"","sources":["../../../src/packlets/experimental/rangeOf.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,MAAM,EAAiB,MAAM,eAAe,CAAC;AAGtD;;;GAGG;AAEH,MAAM,WA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wB;QAC9E,OAAO,OAAO,CAAC,kBAAkB,CAAC,IAAI,CAAC,qBAAqB,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,CAAC;IACjF,CAAC;IAED;;;;;;;OAOG;IACO,QAAQ,CAAC,EAAK,EAAE,EAAK;QAC7B,OAAO,OAAO,CAAC,eAAe,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;IACzC,CAAC;CACF;AA7JD,0BA6JC","sourcesContent":["/*\n * Copyright (c) 2020 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 { Result, captureResult } from '@fgv/ts-utils';\nimport Mustache from 'mustache';\n\n/**\n * Represents a generic range of some comparable type `<T>`.\n * @public\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport interface RangeOfProperties<T> {\n readonly min?: T;\n readonly max?: T;\n}\n\n/**\n * Format strings (in mustache format) to\n * use for both open-ended and complete\n * {@link Experimental.RangeOf | RangeOf<T>}.\n * @public\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport interface RangeOfFormats {\n minOnly: string;\n maxOnly: string;\n minMax: string;\n}\n\n/**\n * Default {@link Experimental.RangeOfFormats | formats} to use for both\n * open-ended and complete {@link Experimental.RangeOf | RangeOf<T>}.\n * @public\n */\nexport const DEFAULT_RANGEOF_FORMATS: RangeOfFormats = {\n minOnly: '{{min}}-',\n maxOnly: '-{{max}}',\n minMax: '{{min}}-{{max}}'\n};\n\n/**\n * Simple implementation of a possibly open-ended range of some comparable\n * type `<T>` with test and formatting.\n * @public\n */\nexport class RangeOf<T> implements RangeOfProperties<T> {\n /**\n * Minimum extent of the range.\n */\n public readonly min?: T;\n /**\n * Maximum extent of the range.\n */\n public readonly max?: T;\n\n /**\n * Creates a new {@link Experimental.RangeOf | RangeOf<T>}.\n * @param min - Optional minimum extent of the range.\n * @param max - Optional maximum extent of the range.\n */\n public constructor(min?: T, max?: T) {\n if (min !== undefined && max !== undefined && this._compare(min, max) === 'greater') {\n throw new Error(`Inverted range - ${JSON.stringify(min)} must be <= ${JSON.stringify(max)}.`);\n }\n this.min = min;\n this.max = max;\n }\n\n /**\n * Static constructor for a {@link Experimental.RangeOf | RangeOf<T>}.\n * @param init - {@link Experimental.RangeOfProperties | Range initializer}.\n * @returns A new {@link Experimental.RangeOf | RangeOf<T>}.\n */\n public static createRange<T>(init?: RangeOfProperties<T>): Result<RangeOf<T>> {\n return captureResult(() => new RangeOf<T>(init?.min, init?.max));\n }\n\n /**\n * Gets a formatted description of a {@link Experimental.RangeOfProperties | RangeOfProperties<T>} given an\n * optional set of formats and 'empty' value to use.\n * @param range - The {@link Experimental.RangeOfProperties | RangeOfProperties<T>} to be formatted.\n * @param formats - Optional {@link Experimental.RangeOfFormats | formats} to use. Default is\n * {@link Experimental.DEFAULT_RANGEOF_FORMATS | DEFAULT_RANGEOF_FORMATS}.\n * @param emptyValue - Value which represents unbounded minimum or maximum for this range. Default is `undefined`.\n * @returns A string representation of the range.\n */\n public static propertiesToString<T>(\n range: RangeOfProperties<T>,\n formats?: RangeOfFormats,\n emptyValue?: T\n ): string | undefined {\n formats = formats ?? DEFAULT_RANGEOF_FORMATS;\n if (range.min !== undefined && range.min !== emptyValue) {\n if (range.max !== undefined && range.max !== emptyValue) {\n return Mustache.render(formats.minMax, range);\n } else {\n return Mustache.render(formats.minOnly, range);\n }\n } else if (range.max !== undefined && range.max !== emptyValue) {\n return Mustache.render(formats.maxOnly, range);\n }\n return undefined;\n }\n\n /**\n * Default comparison uses javascript built-in comparison.\n * @param t1 - First value to be compared.\n * @param t2 - Second value to be compared.\n * @returns `'less'` if `t1` is less than `t2`, `'greater'` if `t1` is larger\n * and `'equal'` if `t1` and `t2` are equal.\n * @internal\n */\n protected static _defaultCompare<T>(t1: T, t2: T): 'less' | 'equal' | 'greater' {\n if (t1 < t2) {\n return 'less';\n } else if (t1 > t2) {\n return 'greater';\n }\n return 'equal';\n }\n\n /**\n * Checks if a supplied value is within this range.\n * @param t - The value to be tested.\n * @returns `'included'` if `t` falls within the range, `'less'` if `t` falls\n * below the minimum extent of the range and `'greater'` if `t` is above the\n * maximum extent.\n */\n public check(t: T): 'less' | 'included' | 'greater' {\n if (this.min !== undefined && this._compare(t, this.min) === 'less') {\n return 'less';\n }\n if (this.max !== undefined && this._compare(t, this.max) !== 'less') {\n return 'greater';\n }\n return 'included';\n }\n\n /**\n * Determines if a supplied value is within this range.\n * @param t - The value to be tested.\n * @returns Returns `true` if `t` falls within the range, `false` otherwise.\n */\n public includes(t: T): boolean {\n return this.check(t) === 'included';\n }\n\n /**\n * Finds the transition value that would bring a supplied value `t` into\n * range.\n * @param t - The value to be tested.\n * @returns The minimum extent of the range if `t` is below the range or\n * the maximum extent of the range if `t` is above the range. Returns\n * `undefined` if `t` already falls within the range.\n */\n public findTransition(t: T): T | undefined {\n switch (this.check(t)) {\n case 'less':\n return this.min;\n case 'included':\n return this.max;\n }\n return undefined;\n }\n\n /**\n * Formats the minimum and maximum values of this range.\n * @param format - A format function used to format the values.\n * @returns A {@link Experimental.RangeOfProperties | RangeOfProperties<string>} containing the\n * formatted representation of the {@link Experimental.RangeOf.min | minimum} and\n * {@link Experimental.RangeOf.max | maximum}\n * extent of the range, or `undefined` for an extent that is not present.\n */\n public toFormattedProperties(format: (value: T) => string | undefined): RangeOfProperties<string> {\n return {\n min: this.min !== undefined ? format(this.min) : undefined,\n max: this.max !== undefined ? format(this.max) : undefined\n };\n }\n\n /**\n * Formats this range using the supplied format function.\n * @param format - Format function used to format minimum and maximum extent values.\n * @param formats - The {@link Experimental.RangeOfFormats | format strings} used to format the range\n * (default {@link Experimental.DEFAULT_RANGEOF_FORMATS}).\n * @returns Returns a formatted representation of this range.\n */\n public format(format: (value: T) => string | undefined, formats?: RangeOfFormats): string | undefined {\n return RangeOf.propertiesToString(this.toFormattedProperties(format), formats);\n }\n\n /**\n * Inner compare method can be overridden by a derived class.\n * @param t1 - First value to compare.\n * @param t2 - Second value to compare.\n * @returns `'less'` if `t1` is less than `t2`, `'greater'` if `t1` is larger\n * and `'equal'` if `t1` and `t2` are equal.\n * @internal\n */\n protected _compare(t1: T, t2: T): 'less' | 'equal' | 'greater' {\n return RangeOf._defaultCompare(t1, t2);\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/packlets/hash/index.ts"],"names":[],"mappings":"AAsBA,cAAc,iBAAiB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/packlets/hash/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;AAEH,kDAAgC","sourcesContent":["/*\n * Copyright (c) 2020 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\nexport * from './md5Normalizer';\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"md5Normalizer.d.ts","sourceRoot":"","sources":["../../../src/packlets/hash/md5Normalizer.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAErC;;;;GAIG;AACH,qBAAa,aAAc,SAAQ,IAAI,CAAC,iBAAiB;;WAKzC,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM;CAG/C"}
|