@dereekb/util 8.9.1 → 8.10.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.md +14 -0
- package/package.json +1 -1
- package/src/lib/error/error.d.ts +4 -0
- package/src/lib/error/error.js +18 -1
- package/src/lib/error/error.js.map +1 -1
- package/src/lib/index.d.ts +2 -0
- package/src/lib/index.js +2 -0
- package/src/lib/index.js.map +1 -1
- package/src/lib/nodejs/index.d.ts +1 -0
- package/src/lib/nodejs/index.js +5 -0
- package/src/lib/nodejs/index.js.map +1 -0
- package/src/lib/nodejs/stream.d.ts +22 -0
- package/src/lib/nodejs/stream.js +34 -0
- package/src/lib/nodejs/stream.js.map +1 -0
- package/src/lib/path/index.d.ts +1 -0
- package/src/lib/path/index.js +5 -0
- package/src/lib/path/index.js.map +1 -0
- package/src/lib/path/path.d.ts +157 -0
- package/src/lib/path/path.js +226 -0
- package/src/lib/path/path.js.map +1 -0
- package/src/lib/promise/callback.d.ts +4 -0
- package/src/lib/promise/callback.js +21 -0
- package/src/lib/promise/callback.js.map +1 -0
- package/src/lib/promise/index.d.ts +1 -0
- package/src/lib/promise/index.js +1 -0
- package/src/lib/promise/index.js.map +1 -1
- package/src/lib/string/char.d.ts +34 -0
- package/src/lib/string/char.js +66 -0
- package/src/lib/string/char.js.map +1 -0
- package/src/lib/string/index.d.ts +2 -0
- package/src/lib/string/index.js +2 -0
- package/src/lib/string/index.js.map +1 -1
- package/src/lib/string/replace.d.ts +30 -0
- package/src/lib/string/replace.js +78 -0
- package/src/lib/string/replace.js.map +1 -0
- package/src/lib/value/map.d.ts +28 -1
- package/src/lib/value/map.js +38 -1
- package/src/lib/value/map.js.map +1 -1
- package/src/lib/value/point.d.ts +1 -2
- package/src/lib/value/point.js +1 -1
- package/src/lib/value/point.js.map +1 -1
- package/test/CHANGELOG.md +4 -0
- package/test/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
# [8.10.0](https://github.com/dereekb/dbx-components/compare/v8.9.1-dev...v8.10.0) (2022-07-04)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* added exists(), uploadStream(), getBytes(), getStream() ([e3fe97e](https://github.com/dereekb/dbx-components/commit/e3fe97e5e985125a5ca653c40fd79c7980845863))
|
|
11
|
+
* added FirebaseStorageContext ([5a30d46](https://github.com/dereekb/dbx-components/commit/5a30d465181d91ce92e7405636fb5414787ac8aa))
|
|
12
|
+
* added list() and list exists() ([388c593](https://github.com/dereekb/dbx-components/commit/388c59350897fcc42d61eb723896e23c42211507))
|
|
13
|
+
* added SlashPath ([8c902ab](https://github.com/dereekb/dbx-components/commit/8c902ab0eb379783320f8a9375486a4e9ce0cd44))
|
|
14
|
+
* added string functions ([1866db5](https://github.com/dereekb/dbx-components/commit/1866db58d96a1d893d01ff2890a9bccb38e2ca61))
|
|
15
|
+
* added upload byte types, delete() ([655088b](https://github.com/dereekb/dbx-components/commit/655088b238ef80097a2f09c539a1282a608f246b))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
5
19
|
## [8.9.1](https://github.com/dereekb/dbx-components/compare/v8.9.0-dev...v8.9.1) (2022-06-30)
|
|
6
20
|
|
|
7
21
|
|
package/package.json
CHANGED
package/src/lib/error/error.d.ts
CHANGED
|
@@ -37,3 +37,7 @@ export declare type ErrorInput = ErrorWrapper | CodedError | ReadableError | Rea
|
|
|
37
37
|
* @returns
|
|
38
38
|
*/
|
|
39
39
|
export declare function toReadableError(inputError: Maybe<ErrorInput>): Maybe<CodedError | ReadableError>;
|
|
40
|
+
export declare function errorMessageContainsString(input: Maybe<ErrorInput | string>, target: string): boolean;
|
|
41
|
+
export declare type ErrorMessageContainsStringFunction = (input: Maybe<ErrorInput | string>) => boolean;
|
|
42
|
+
export declare function errorMessageContainsStringFunction(target: string): ErrorMessageContainsStringFunction;
|
|
43
|
+
export declare function messageFromError(input: Maybe<ErrorInput | string>): Maybe<string>;
|
package/src/lib/error/error.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.toReadableError = exports.readableError = void 0;
|
|
3
|
+
exports.messageFromError = exports.errorMessageContainsStringFunction = exports.errorMessageContainsString = exports.toReadableError = exports.readableError = void 0;
|
|
4
4
|
const make_error_1 = require("make-error");
|
|
5
|
+
const replace_1 = require("../string/replace");
|
|
5
6
|
function readableError(code, message) {
|
|
6
7
|
return {
|
|
7
8
|
code,
|
|
@@ -42,4 +43,20 @@ function toReadableError(inputError) {
|
|
|
42
43
|
return error;
|
|
43
44
|
}
|
|
44
45
|
exports.toReadableError = toReadableError;
|
|
46
|
+
function errorMessageContainsString(input, target) {
|
|
47
|
+
return input ? errorMessageContainsStringFunction(target)(input) : false;
|
|
48
|
+
}
|
|
49
|
+
exports.errorMessageContainsString = errorMessageContainsString;
|
|
50
|
+
function errorMessageContainsStringFunction(target) {
|
|
51
|
+
const regex = new RegExp((0, replace_1.escapeStringForRegex)(target));
|
|
52
|
+
return (input) => {
|
|
53
|
+
const message = messageFromError(input);
|
|
54
|
+
return message ? regex.test(message) : false;
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
exports.errorMessageContainsStringFunction = errorMessageContainsStringFunction;
|
|
58
|
+
function messageFromError(input) {
|
|
59
|
+
return (typeof input === 'object' ? input.message : input) || input;
|
|
60
|
+
}
|
|
61
|
+
exports.messageFromError = messageFromError;
|
|
45
62
|
//# sourceMappingURL=error.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/error/error.ts"],"names":[],"mappings":";;;AAAA,2CAAuC;
|
|
1
|
+
{"version":3,"file":"error.js","source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C;QACvD,OAAO,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IAC/C,CAAC,CAAC;AACJ,CAAC;AAPD,gFAOC;AAED,SAAgB,gBAAgB,CAAC,KAAiC;IAChE,OAAO,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAE,KAAuB,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,IAAK,KAAmC,CAAC;AACxH,CAAC;AAFD,4CAEC"}
|
package/src/lib/index.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export * from './getter';
|
|
|
9
9
|
export * from './iterable';
|
|
10
10
|
export * from './map';
|
|
11
11
|
export * from './model';
|
|
12
|
+
export * from './nodejs';
|
|
12
13
|
export * from './misc';
|
|
13
14
|
export * from './promise';
|
|
14
15
|
export * from './relation';
|
|
@@ -28,5 +29,6 @@ export * from './key';
|
|
|
28
29
|
export * from './number';
|
|
29
30
|
export * from './object';
|
|
30
31
|
export * from './page';
|
|
32
|
+
export * from './path';
|
|
31
33
|
export * from './sort';
|
|
32
34
|
export * from './type';
|
package/src/lib/index.js
CHANGED
|
@@ -12,6 +12,7 @@ tslib_1.__exportStar(require("./getter"), exports);
|
|
|
12
12
|
tslib_1.__exportStar(require("./iterable"), exports);
|
|
13
13
|
tslib_1.__exportStar(require("./map"), exports);
|
|
14
14
|
tslib_1.__exportStar(require("./model"), exports);
|
|
15
|
+
tslib_1.__exportStar(require("./nodejs"), exports);
|
|
15
16
|
tslib_1.__exportStar(require("./misc"), exports);
|
|
16
17
|
tslib_1.__exportStar(require("./promise"), exports);
|
|
17
18
|
tslib_1.__exportStar(require("./relation"), exports);
|
|
@@ -31,6 +32,7 @@ tslib_1.__exportStar(require("./key"), exports);
|
|
|
31
32
|
tslib_1.__exportStar(require("./number"), exports);
|
|
32
33
|
tslib_1.__exportStar(require("./object"), exports);
|
|
33
34
|
tslib_1.__exportStar(require("./page"), exports);
|
|
35
|
+
tslib_1.__exportStar(require("./path"), exports);
|
|
34
36
|
tslib_1.__exportStar(require("./sort"), exports);
|
|
35
37
|
tslib_1.__exportStar(require("./type"), exports);
|
|
36
38
|
//# sourceMappingURL=index.js.map
|
package/src/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/util/src/lib/index.ts"],"names":[],"mappings":";;;AAAA,kDAAwB;AACxB,sDAA4B;AAC5B,iDAAuB;AACvB,oDAA0B;AAC1B,kDAAwB;AACxB,mDAAyB;AACzB,qDAA2B;AAC3B,mDAAyB;AACzB,qDAA2B;AAC3B,gDAAsB;AACtB,kDAAwB;AACxB,iDAAuB;AACvB,oDAA0B;AAC1B,qDAA2B;AAC3B,oDAA0B;AAC1B,gDAAsB;AACtB,oDAA0B;AAC1B,mDAAyB;AACzB,iDAAuB;AACvB,kDAAwB;AACxB,oDAA0B;AAC1B,iDAAuB;AACvB,sDAA4B;AAC5B,qDAA2B;AAC3B,iDAAuB;AACvB,oDAA0B;AAC1B,gDAAsB;AACtB,mDAAyB;AACzB,mDAAyB;AACzB,iDAAuB;AACvB,iDAAuB;AACvB,iDAAuB"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/util/src/lib/index.ts"],"names":[],"mappings":";;;AAAA,kDAAwB;AACxB,sDAA4B;AAC5B,iDAAuB;AACvB,oDAA0B;AAC1B,kDAAwB;AACxB,mDAAyB;AACzB,qDAA2B;AAC3B,mDAAyB;AACzB,qDAA2B;AAC3B,gDAAsB;AACtB,kDAAwB;AACxB,mDAAyB;AACzB,iDAAuB;AACvB,oDAA0B;AAC1B,qDAA2B;AAC3B,oDAA0B;AAC1B,gDAAsB;AACtB,oDAA0B;AAC1B,mDAAyB;AACzB,iDAAuB;AACvB,kDAAwB;AACxB,oDAA0B;AAC1B,iDAAuB;AACvB,sDAA4B;AAC5B,qDAA2B;AAC3B,iDAAuB;AACvB,oDAA0B;AAC1B,gDAAsB;AACtB,mDAAyB;AACzB,mDAAyB;AACzB,iDAAuB;AACvB,iDAAuB;AACvB,iDAAuB;AACvB,iDAAuB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './stream';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/nodejs/index.ts"],"names":[],"mappings":";;;AAAA,mDAAyB"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/**
|
|
3
|
+
* Reads the input stream and encodes the data to a string.
|
|
4
|
+
*/
|
|
5
|
+
export declare type ReadableStreamToStringFunction = (stream: NodeJS.ReadableStream) => Promise<string>;
|
|
6
|
+
/**
|
|
7
|
+
* Creates a new ReadableStreamToStringFunction
|
|
8
|
+
* @param encoding
|
|
9
|
+
* @returns
|
|
10
|
+
*/
|
|
11
|
+
export declare function readableStreamToStringFunction(encoding: BufferEncoding): ReadableStreamToStringFunction;
|
|
12
|
+
/**
|
|
13
|
+
* ReadableStreamToStringFunction for Base64
|
|
14
|
+
*/
|
|
15
|
+
export declare const readableStreamToBase64: ReadableStreamToStringFunction;
|
|
16
|
+
/**
|
|
17
|
+
* Converts a ReadableStream to a Buffer promise.
|
|
18
|
+
*
|
|
19
|
+
* @param encoding
|
|
20
|
+
* @returns
|
|
21
|
+
*/
|
|
22
|
+
export declare function readableStreamToBuffer(stream: NodeJS.ReadableStream): Promise<Buffer>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.readableStreamToBuffer = exports.readableStreamToBase64 = exports.readableStreamToStringFunction = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Creates a new ReadableStreamToStringFunction
|
|
6
|
+
* @param encoding
|
|
7
|
+
* @returns
|
|
8
|
+
*/
|
|
9
|
+
function readableStreamToStringFunction(encoding) {
|
|
10
|
+
return (stream) => {
|
|
11
|
+
return readableStreamToBuffer(stream).then((x) => x.toString(encoding));
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
exports.readableStreamToStringFunction = readableStreamToStringFunction;
|
|
15
|
+
/**
|
|
16
|
+
* ReadableStreamToStringFunction for Base64
|
|
17
|
+
*/
|
|
18
|
+
exports.readableStreamToBase64 = readableStreamToStringFunction('base64');
|
|
19
|
+
/**
|
|
20
|
+
* Converts a ReadableStream to a Buffer promise.
|
|
21
|
+
*
|
|
22
|
+
* @param encoding
|
|
23
|
+
* @returns
|
|
24
|
+
*/
|
|
25
|
+
function readableStreamToBuffer(stream) {
|
|
26
|
+
const chunks = [];
|
|
27
|
+
return new Promise((resolve, reject) => {
|
|
28
|
+
stream.on('data', (chunk) => chunks.push(Buffer.from(chunk)));
|
|
29
|
+
stream.on('error', (err) => reject(err));
|
|
30
|
+
stream.on('end', () => resolve(Buffer.concat(chunks)));
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
exports.readableStreamToBuffer = readableStreamToBuffer;
|
|
34
|
+
//# sourceMappingURL=stream.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stream.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/nodejs/stream.ts"],"names":[],"mappings":";;;AAKA;;;;GAIG;AACH,SAAgB,8BAA8B,CAAC,QAAwB;IACrE,OAAO,CAAC,MAA6B,EAAE,EAAE;QACvC,OAAO,sBAAsB,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC1E,CAAC,CAAC;AACJ,CAAC;AAJD,wEAIC;AAED;;GAEG;AACU,QAAA,sBAAsB,GAAG,8BAA8B,CAAC,QAAQ,CAAC,CAAC;AAE/E;;;;;GAKG;AACH,SAAgB,sBAAsB,CAAC,MAA6B;IAClE,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAC9D,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;QACzC,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IACzD,CAAC,CAAC,CAAC;AACL,CAAC;AAPD,wDAOC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './path';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/path/index.ts"],"names":[],"mappings":";;;AAAA,iDAAuB"}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { MapSameFunction } from '../value/map';
|
|
2
|
+
import { ArrayOrValue } from '../array/array';
|
|
3
|
+
import { FactoryWithRequiredInput } from '../getter/getter';
|
|
4
|
+
export declare const SLASH_PATH_SEPARATOR = "/";
|
|
5
|
+
export declare const SLASH_PATH_FILE_TYPE_SEPARATOR = ".";
|
|
6
|
+
export declare type SlashPathSeparatorString = typeof SLASH_PATH_SEPARATOR;
|
|
7
|
+
export declare type SlashFileTypeSeparatorString = typeof SLASH_PATH_FILE_TYPE_SEPARATOR;
|
|
8
|
+
export declare const DEFAULT_SLASH_PATH_ILLEGAL_CHARACTERS: string[];
|
|
9
|
+
/**
|
|
10
|
+
* Default replacement character for illegal characters.
|
|
11
|
+
*/
|
|
12
|
+
export declare const DEFAULT_SLASH_PATH_ILLEGAL_CHARACTER_REPLACEMENT = "_";
|
|
13
|
+
/**
|
|
14
|
+
* A forward-slash path string.
|
|
15
|
+
*/
|
|
16
|
+
export declare type SlashPathFolder = `${SlashPathSeparatorString}${string}${SlashPathSeparatorString}` | `${string}${SlashPathSeparatorString}`;
|
|
17
|
+
/**
|
|
18
|
+
* A file name without a type.
|
|
19
|
+
*/
|
|
20
|
+
export declare type SlashPathFile = string;
|
|
21
|
+
/**
|
|
22
|
+
* A file name
|
|
23
|
+
*/
|
|
24
|
+
export declare type SlashPathTypedFile = `${string}${SlashFileTypeSeparatorString}${string}`;
|
|
25
|
+
/**
|
|
26
|
+
* A simple path made up of UTF-8 characters and slashes
|
|
27
|
+
*/
|
|
28
|
+
export declare type SlashPath = SlashPathFolder | SlashPathFile | SlashPathTypedFile;
|
|
29
|
+
/**
|
|
30
|
+
* Function that modifies the input SlashPath
|
|
31
|
+
*/
|
|
32
|
+
export declare type SlashPathFunction = MapSameFunction<SlashPath>;
|
|
33
|
+
/**
|
|
34
|
+
* Slash path type
|
|
35
|
+
* - folder: is a folder
|
|
36
|
+
* - file: is a file without a type
|
|
37
|
+
* - typedfile: is a file with a type
|
|
38
|
+
* - invalid: is an invalid slash path that might contain multiple '.' values, or is an empty string.
|
|
39
|
+
*/
|
|
40
|
+
export declare type SlashPathType = 'folder' | 'file' | 'typedfile' | 'invalid';
|
|
41
|
+
/**
|
|
42
|
+
* Returns the SlashPathType for the input.
|
|
43
|
+
*
|
|
44
|
+
* @param input
|
|
45
|
+
* @returns
|
|
46
|
+
*/
|
|
47
|
+
export declare function slashPathType(input: SlashPath): SlashPathType;
|
|
48
|
+
export declare function isSlashPathFile(input: string): input is SlashPathTypedFile;
|
|
49
|
+
export declare function isSlashPathFolder(input: string): input is SlashPathFolder;
|
|
50
|
+
export declare function isValidSlashPath(input: string): input is SlashPath;
|
|
51
|
+
/**
|
|
52
|
+
* Returns the last part of the slash path.
|
|
53
|
+
*
|
|
54
|
+
* @param slashPath
|
|
55
|
+
*/
|
|
56
|
+
export declare function slashPathName(slashPath: SlashPath): string;
|
|
57
|
+
/**
|
|
58
|
+
* Returns each section of a SlashPath
|
|
59
|
+
*
|
|
60
|
+
* @param slashPath
|
|
61
|
+
* @returns
|
|
62
|
+
*/
|
|
63
|
+
export declare function slashPathParts(slashPath: SlashPath): string[];
|
|
64
|
+
/**
|
|
65
|
+
* Slash path type to enforce.
|
|
66
|
+
* - relative: path that does not start with a slash
|
|
67
|
+
* - absolute: path that starts with a slash
|
|
68
|
+
* - any: either relative or absolute
|
|
69
|
+
*/
|
|
70
|
+
export declare type SlashPathStartType = 'relative' | 'absolute' | 'any';
|
|
71
|
+
/**
|
|
72
|
+
* Factory use to set the slash path type of the input.
|
|
73
|
+
*/
|
|
74
|
+
export declare type SlashPathStartTypeFactory = SlashPathFunction;
|
|
75
|
+
export declare function slashPathStartTypeFactory(type: SlashPathStartType): SlashPathStartTypeFactory;
|
|
76
|
+
export declare const LEADING_SLASHES_REGEX: RegExp;
|
|
77
|
+
export declare const TRAILING_SLASHES_REGEX: RegExp;
|
|
78
|
+
export declare const TRAILING_FILE_TYPE_SEPARATORS_REGEX: RegExp;
|
|
79
|
+
export declare const ALL_SLASHES_REGEX: RegExp;
|
|
80
|
+
export declare const ALL_DOUBLE_SLASHES_REGEX: RegExp;
|
|
81
|
+
export declare const ALL_SLASH_PATH_FILE_TYPE_SEPARATORS_REGEX: RegExp;
|
|
82
|
+
export declare function toRelativeSlashPathStartType(input: SlashPath): SlashPath;
|
|
83
|
+
/**
|
|
84
|
+
*
|
|
85
|
+
* @param input
|
|
86
|
+
* @returns
|
|
87
|
+
*/
|
|
88
|
+
export declare function toAbsoluteSlashPathStartType(input: SlashPath): SlashPath;
|
|
89
|
+
export declare function fixMultiSlashesInSlashPath(input: SlashPath): SlashPath;
|
|
90
|
+
export declare function replaceMultipleFilePathsInSlashPath(input: SlashPath): SlashPath;
|
|
91
|
+
export declare function removeTrailingFileTypeSeparators(input: SlashPath): SlashPath;
|
|
92
|
+
/**
|
|
93
|
+
* Replaces all extra and invalidate FilePathTypeSeparator values from the SlashPath, returning a valid SlashPath.
|
|
94
|
+
*
|
|
95
|
+
* @param input
|
|
96
|
+
* @param replaceWith
|
|
97
|
+
* @returns
|
|
98
|
+
*/
|
|
99
|
+
export declare function replaceInvalidFilePathTypeSeparatorsInSlashPath(input: SlashPath, replaceWith?: string): SlashPath;
|
|
100
|
+
/**
|
|
101
|
+
* Creates a function that replaces all extra and invalidate FilePathTypeSeparator values from the SlashPath, returning a valid SlashPath.
|
|
102
|
+
*
|
|
103
|
+
* @param input
|
|
104
|
+
* @param replaceWith
|
|
105
|
+
* @returns
|
|
106
|
+
*/
|
|
107
|
+
export declare function replaceInvalidFilePathTypeSeparatorsInSlashPathFunction(replaceWith?: string): SlashPathFunction;
|
|
108
|
+
/**
|
|
109
|
+
* Factory used to validate and fix invalid SlashPath input.
|
|
110
|
+
*/
|
|
111
|
+
export declare type SlashPathValidationFactory = SlashPathFunction;
|
|
112
|
+
export interface SlashPathValidationFactoryConfig {
|
|
113
|
+
/**
|
|
114
|
+
* Set of illegal characters to find/replace. If not provided, used the DEFAULT_SLASH_PATH_ILLEGAL_CHARACTERS
|
|
115
|
+
*/
|
|
116
|
+
illegalStrings?: ArrayOrValue<string>;
|
|
117
|
+
/**
|
|
118
|
+
* String used to replace all encountered illegal characters.
|
|
119
|
+
*
|
|
120
|
+
* Is true by default.
|
|
121
|
+
*/
|
|
122
|
+
replaceIllegalCharacters?: string | boolean;
|
|
123
|
+
/**
|
|
124
|
+
* Whether or not to replace extra dots by treating them as illegal characters.
|
|
125
|
+
*
|
|
126
|
+
* Will replace extra dots with the input value, or if true, will replace them with the value for replaceIllegalCharacters.
|
|
127
|
+
*/
|
|
128
|
+
replaceIllegalDots?: string | boolean;
|
|
129
|
+
/**
|
|
130
|
+
* Whether or not to validate a final time after replacing elements and throw an error if it is still not valid.
|
|
131
|
+
*
|
|
132
|
+
* Disabled by default unless replaceIllegalCharacters and replaceIllegalDots are false.
|
|
133
|
+
*/
|
|
134
|
+
throwError?: boolean;
|
|
135
|
+
}
|
|
136
|
+
export declare function slashPathValidationFactory(config?: SlashPathValidationFactoryConfig): SlashPathValidationFactory;
|
|
137
|
+
/**
|
|
138
|
+
* Factory use to generate/merge file paths together.
|
|
139
|
+
*/
|
|
140
|
+
export declare type SlashPathFactory = FactoryWithRequiredInput<SlashPath, ArrayOrValue<SlashPath>>;
|
|
141
|
+
export interface SlashPathFactoryConfig {
|
|
142
|
+
/**
|
|
143
|
+
* SlashPath start type to enforce
|
|
144
|
+
*/
|
|
145
|
+
startType?: SlashPathStartType;
|
|
146
|
+
/**
|
|
147
|
+
* Prefix paths to append
|
|
148
|
+
*/
|
|
149
|
+
basePath?: ArrayOrValue<SlashPathFolder>;
|
|
150
|
+
/**
|
|
151
|
+
* SlashPathValidationFactoryConfig to use for validation.
|
|
152
|
+
*/
|
|
153
|
+
validate?: boolean | SlashPathValidationFactoryConfig;
|
|
154
|
+
}
|
|
155
|
+
export declare function slashPathFactory(config?: SlashPathFactoryConfig): SlashPathFactory;
|
|
156
|
+
export declare function mergeSlashPaths(paths: SlashPath[]): SlashPath;
|
|
157
|
+
export declare function slashPathInvalidError(): Error;
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.slashPathInvalidError = exports.mergeSlashPaths = exports.slashPathFactory = exports.slashPathValidationFactory = exports.replaceInvalidFilePathTypeSeparatorsInSlashPathFunction = exports.replaceInvalidFilePathTypeSeparatorsInSlashPath = exports.removeTrailingFileTypeSeparators = exports.replaceMultipleFilePathsInSlashPath = exports.fixMultiSlashesInSlashPath = exports.toAbsoluteSlashPathStartType = exports.toRelativeSlashPathStartType = exports.ALL_SLASH_PATH_FILE_TYPE_SEPARATORS_REGEX = exports.ALL_DOUBLE_SLASHES_REGEX = exports.ALL_SLASHES_REGEX = exports.TRAILING_FILE_TYPE_SEPARATORS_REGEX = exports.TRAILING_SLASHES_REGEX = exports.LEADING_SLASHES_REGEX = exports.slashPathStartTypeFactory = exports.slashPathParts = exports.slashPathName = exports.isValidSlashPath = exports.isSlashPathFolder = exports.isSlashPathFile = exports.slashPathType = exports.DEFAULT_SLASH_PATH_ILLEGAL_CHARACTER_REPLACEMENT = exports.DEFAULT_SLASH_PATH_ILLEGAL_CHARACTERS = exports.SLASH_PATH_FILE_TYPE_SEPARATOR = exports.SLASH_PATH_SEPARATOR = void 0;
|
|
4
|
+
const map_1 = require("../value/map");
|
|
5
|
+
const array_1 = require("../array/array");
|
|
6
|
+
const string_1 = require("../string");
|
|
7
|
+
const value_1 = require("../value");
|
|
8
|
+
exports.SLASH_PATH_SEPARATOR = '/';
|
|
9
|
+
exports.SLASH_PATH_FILE_TYPE_SEPARATOR = '.';
|
|
10
|
+
exports.DEFAULT_SLASH_PATH_ILLEGAL_CHARACTERS = ['#', '[', ']', '*', '?'];
|
|
11
|
+
/**
|
|
12
|
+
* Default replacement character for illegal characters.
|
|
13
|
+
*/
|
|
14
|
+
exports.DEFAULT_SLASH_PATH_ILLEGAL_CHARACTER_REPLACEMENT = '_';
|
|
15
|
+
/**
|
|
16
|
+
* Returns the SlashPathType for the input.
|
|
17
|
+
*
|
|
18
|
+
* @param input
|
|
19
|
+
* @returns
|
|
20
|
+
*/
|
|
21
|
+
function slashPathType(input) {
|
|
22
|
+
const dotCount = input.split(exports.SLASH_PATH_FILE_TYPE_SEPARATOR, 2).length;
|
|
23
|
+
let type;
|
|
24
|
+
switch (dotCount) {
|
|
25
|
+
case 0:
|
|
26
|
+
if (input.length === 0) {
|
|
27
|
+
type = 'invalid';
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
const lastValue = input[input.length - 1];
|
|
31
|
+
if (lastValue === exports.SLASH_PATH_SEPARATOR) {
|
|
32
|
+
type = 'folder';
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
type = 'file';
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
break;
|
|
39
|
+
case 1:
|
|
40
|
+
type = 'file';
|
|
41
|
+
break;
|
|
42
|
+
default:
|
|
43
|
+
type = 'invalid';
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
return type;
|
|
47
|
+
}
|
|
48
|
+
exports.slashPathType = slashPathType;
|
|
49
|
+
function isSlashPathFile(input) {
|
|
50
|
+
const type = slashPathType(input);
|
|
51
|
+
return type === 'file' || type === 'typedfile';
|
|
52
|
+
}
|
|
53
|
+
exports.isSlashPathFile = isSlashPathFile;
|
|
54
|
+
function isSlashPathFolder(input) {
|
|
55
|
+
return slashPathType(input) === 'folder';
|
|
56
|
+
}
|
|
57
|
+
exports.isSlashPathFolder = isSlashPathFolder;
|
|
58
|
+
function isValidSlashPath(input) {
|
|
59
|
+
return slashPathType(input) !== 'invalid';
|
|
60
|
+
}
|
|
61
|
+
exports.isValidSlashPath = isValidSlashPath;
|
|
62
|
+
/**
|
|
63
|
+
* Returns the last part of the slash path.
|
|
64
|
+
*
|
|
65
|
+
* @param slashPath
|
|
66
|
+
*/
|
|
67
|
+
function slashPathName(slashPath) {
|
|
68
|
+
const parts = slashPathParts(slashPath);
|
|
69
|
+
return parts[parts.length - 1];
|
|
70
|
+
}
|
|
71
|
+
exports.slashPathName = slashPathName;
|
|
72
|
+
/**
|
|
73
|
+
* Returns each section of a SlashPath
|
|
74
|
+
*
|
|
75
|
+
* @param slashPath
|
|
76
|
+
* @returns
|
|
77
|
+
*/
|
|
78
|
+
function slashPathParts(slashPath) {
|
|
79
|
+
return slashPath.split(exports.SLASH_PATH_SEPARATOR).filter((x) => Boolean(x));
|
|
80
|
+
}
|
|
81
|
+
exports.slashPathParts = slashPathParts;
|
|
82
|
+
function slashPathStartTypeFactory(type) {
|
|
83
|
+
let fn;
|
|
84
|
+
switch (type) {
|
|
85
|
+
case 'relative':
|
|
86
|
+
fn = toRelativeSlashPathStartType;
|
|
87
|
+
break;
|
|
88
|
+
case 'absolute':
|
|
89
|
+
fn = toAbsoluteSlashPathStartType;
|
|
90
|
+
break;
|
|
91
|
+
case 'any':
|
|
92
|
+
fn = (0, value_1.mapIdentityFunction)();
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
return fn;
|
|
96
|
+
}
|
|
97
|
+
exports.slashPathStartTypeFactory = slashPathStartTypeFactory;
|
|
98
|
+
exports.LEADING_SLASHES_REGEX = /^\/+/;
|
|
99
|
+
exports.TRAILING_SLASHES_REGEX = /\/+$/;
|
|
100
|
+
exports.TRAILING_FILE_TYPE_SEPARATORS_REGEX = /\.+$/;
|
|
101
|
+
exports.ALL_SLASHES_REGEX = /\/+/g;
|
|
102
|
+
exports.ALL_DOUBLE_SLASHES_REGEX = /\/{2,}/g;
|
|
103
|
+
exports.ALL_SLASH_PATH_FILE_TYPE_SEPARATORS_REGEX = /\.+/g;
|
|
104
|
+
function toRelativeSlashPathStartType(input) {
|
|
105
|
+
// remove all leading slashes
|
|
106
|
+
return input.replace(exports.LEADING_SLASHES_REGEX, '');
|
|
107
|
+
}
|
|
108
|
+
exports.toRelativeSlashPathStartType = toRelativeSlashPathStartType;
|
|
109
|
+
/**
|
|
110
|
+
*
|
|
111
|
+
* @param input
|
|
112
|
+
* @returns
|
|
113
|
+
*/
|
|
114
|
+
function toAbsoluteSlashPathStartType(input) {
|
|
115
|
+
// add a leading slash, and remove any multiple slashes if provided
|
|
116
|
+
return input.startsWith(exports.SLASH_PATH_SEPARATOR) ? input.replace(exports.LEADING_SLASHES_REGEX, exports.SLASH_PATH_SEPARATOR) : `${exports.SLASH_PATH_SEPARATOR}${input}`;
|
|
117
|
+
}
|
|
118
|
+
exports.toAbsoluteSlashPathStartType = toAbsoluteSlashPathStartType;
|
|
119
|
+
function fixMultiSlashesInSlashPath(input) {
|
|
120
|
+
return input.replace(exports.ALL_DOUBLE_SLASHES_REGEX, exports.SLASH_PATH_SEPARATOR);
|
|
121
|
+
}
|
|
122
|
+
exports.fixMultiSlashesInSlashPath = fixMultiSlashesInSlashPath;
|
|
123
|
+
function replaceMultipleFilePathsInSlashPath(input) {
|
|
124
|
+
return input.replace(exports.ALL_DOUBLE_SLASHES_REGEX, exports.SLASH_PATH_SEPARATOR);
|
|
125
|
+
}
|
|
126
|
+
exports.replaceMultipleFilePathsInSlashPath = replaceMultipleFilePathsInSlashPath;
|
|
127
|
+
function removeTrailingFileTypeSeparators(input) {
|
|
128
|
+
return input.replace(exports.TRAILING_FILE_TYPE_SEPARATORS_REGEX, '');
|
|
129
|
+
}
|
|
130
|
+
exports.removeTrailingFileTypeSeparators = removeTrailingFileTypeSeparators;
|
|
131
|
+
/**
|
|
132
|
+
* Replaces all extra and invalidate FilePathTypeSeparator values from the SlashPath, returning a valid SlashPath.
|
|
133
|
+
*
|
|
134
|
+
* @param input
|
|
135
|
+
* @param replaceWith
|
|
136
|
+
* @returns
|
|
137
|
+
*/
|
|
138
|
+
function replaceInvalidFilePathTypeSeparatorsInSlashPath(input, replaceWith) {
|
|
139
|
+
return replaceInvalidFilePathTypeSeparatorsInSlashPathFunction(replaceWith)(input);
|
|
140
|
+
}
|
|
141
|
+
exports.replaceInvalidFilePathTypeSeparatorsInSlashPath = replaceInvalidFilePathTypeSeparatorsInSlashPath;
|
|
142
|
+
/**
|
|
143
|
+
* Creates a function that replaces all extra and invalidate FilePathTypeSeparator values from the SlashPath, returning a valid SlashPath.
|
|
144
|
+
*
|
|
145
|
+
* @param input
|
|
146
|
+
* @param replaceWith
|
|
147
|
+
* @returns
|
|
148
|
+
*/
|
|
149
|
+
function replaceInvalidFilePathTypeSeparatorsInSlashPathFunction(replaceWith = exports.DEFAULT_SLASH_PATH_ILLEGAL_CHARACTER_REPLACEMENT) {
|
|
150
|
+
return (input) => {
|
|
151
|
+
const endsOnFileTypeSeparator = input[input.length - 1] === exports.SLASH_PATH_FILE_TYPE_SEPARATOR;
|
|
152
|
+
const inputToEvaluate = endsOnFileTypeSeparator ? removeTrailingFileTypeSeparators(input) : input;
|
|
153
|
+
const { first, last, occurences } = (0, string_1.firstAndLastCharacterOccurrence)(inputToEvaluate, exports.SLASH_PATH_FILE_TYPE_SEPARATOR);
|
|
154
|
+
let fixedPath;
|
|
155
|
+
switch (occurences) {
|
|
156
|
+
case 0:
|
|
157
|
+
fixedPath = inputToEvaluate;
|
|
158
|
+
break;
|
|
159
|
+
case 1:
|
|
160
|
+
const lastSlashPosition = inputToEvaluate.lastIndexOf('/');
|
|
161
|
+
if (lastSlashPosition === -1 || lastSlashPosition < last) {
|
|
162
|
+
// valid path
|
|
163
|
+
fixedPath = inputToEvaluate;
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
// the dot occurs before another slash, so we should replace it
|
|
167
|
+
fixedPath = (0, string_1.replaceCharacterAtIndexWith)(inputToEvaluate, last, replaceWith);
|
|
168
|
+
}
|
|
169
|
+
break;
|
|
170
|
+
default:
|
|
171
|
+
const [head, tail] = (0, string_1.splitStringAtIndex)(inputToEvaluate, last, true);
|
|
172
|
+
const headWithReplacedSeparators = head.replace(exports.ALL_SLASH_PATH_FILE_TYPE_SEPARATORS_REGEX, replaceWith);
|
|
173
|
+
fixedPath = headWithReplacedSeparators + tail;
|
|
174
|
+
break;
|
|
175
|
+
}
|
|
176
|
+
return fixedPath;
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
exports.replaceInvalidFilePathTypeSeparatorsInSlashPathFunction = replaceInvalidFilePathTypeSeparatorsInSlashPathFunction;
|
|
180
|
+
function slashPathValidationFactory(config) {
|
|
181
|
+
const { illegalStrings = exports.DEFAULT_SLASH_PATH_ILLEGAL_CHARACTERS, replaceIllegalCharacters: inputReplaceIllegalCharacters = true, replaceIllegalDots: inputReplaceIllegalDots = true, throwError } = config !== null && config !== void 0 ? config : {};
|
|
182
|
+
const fns = [];
|
|
183
|
+
const replaceIllegalCharacters = typeof inputReplaceIllegalCharacters === 'string' ? inputReplaceIllegalCharacters : exports.DEFAULT_SLASH_PATH_ILLEGAL_CHARACTER_REPLACEMENT;
|
|
184
|
+
if (inputReplaceIllegalCharacters != null) {
|
|
185
|
+
fns.push((0, string_1.replaceStringsFunction)({
|
|
186
|
+
replace: illegalStrings,
|
|
187
|
+
replaceWith: replaceIllegalCharacters
|
|
188
|
+
}));
|
|
189
|
+
}
|
|
190
|
+
if (inputReplaceIllegalDots != null) {
|
|
191
|
+
const replaceIllegalDotsWith = typeof inputReplaceIllegalDots === 'string' ? inputReplaceIllegalDots : replaceIllegalCharacters;
|
|
192
|
+
fns.push(replaceInvalidFilePathTypeSeparatorsInSlashPathFunction(replaceIllegalDotsWith));
|
|
193
|
+
}
|
|
194
|
+
if (throwError === true || !(inputReplaceIllegalCharacters || inputReplaceIllegalDots)) {
|
|
195
|
+
fns.push((x) => {
|
|
196
|
+
if (!isValidSlashPath(x)) {
|
|
197
|
+
throw slashPathInvalidError();
|
|
198
|
+
}
|
|
199
|
+
return x;
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
return (0, map_1.chainMapSameFunctions)(fns);
|
|
203
|
+
}
|
|
204
|
+
exports.slashPathValidationFactory = slashPathValidationFactory;
|
|
205
|
+
function slashPathFactory(config) {
|
|
206
|
+
const { startType: type = 'any', basePath: inputBasePaths, validate = true } = config !== null && config !== void 0 ? config : {};
|
|
207
|
+
const basePath = inputBasePaths ? mergeSlashPaths((0, array_1.asArray)(inputBasePaths)) : '';
|
|
208
|
+
const typeFactory = slashPathStartTypeFactory(type);
|
|
209
|
+
const validationFactory = validate ? (typeof validate === 'boolean' ? slashPathValidationFactory() : slashPathValidationFactory(validate)) : null;
|
|
210
|
+
const finalizeFn = (0, value_1.chainMapFunction)(typeFactory, validationFactory);
|
|
211
|
+
return (paths) => {
|
|
212
|
+
const merged = mergeSlashPaths((0, array_1.mergeArrayOrValueIntoArray)([basePath], paths));
|
|
213
|
+
return finalizeFn(merged);
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
exports.slashPathFactory = slashPathFactory;
|
|
217
|
+
function mergeSlashPaths(paths) {
|
|
218
|
+
const merge = paths.filter((x) => Boolean(x)).join(exports.SLASH_PATH_SEPARATOR);
|
|
219
|
+
return fixMultiSlashesInSlashPath(merge);
|
|
220
|
+
}
|
|
221
|
+
exports.mergeSlashPaths = mergeSlashPaths;
|
|
222
|
+
function slashPathInvalidError() {
|
|
223
|
+
return new Error('The slashPath is invalid.');
|
|
224
|
+
}
|
|
225
|
+
exports.slashPathInvalidError = slashPathInvalidError;
|
|
226
|
+
//# sourceMappingURL=path.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/path/path.ts"],"names":[],"mappings":";;;AAAA,sCAAsE;AACtE,0CAAmF;AACnF,sCAAqI;AACrI,oCAAiE;AAGpD,QAAA,oBAAoB,GAAG,GAAG,CAAC;AAC3B,QAAA,8BAA8B,GAAG,GAAG,CAAC;AAKrC,QAAA,qCAAqC,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;AAE/E;;GAEG;AACU,QAAA,gDAAgD,GAAG,GAAG,CAAC;AAoCpE;;;;;GAKG;AACH,SAAgB,aAAa,CAAC,KAAgB;IAC5C,MAAM,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC,sCAA8B,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;IACvE,IAAI,IAAmB,CAAC;IAExB,QAAQ,QAAQ,EAAE;QAChB,KAAK,CAAC;YACJ,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE;gBACtB,IAAI,GAAG,SAAS,CAAC;aAClB;iBAAM;gBACL,MAAM,SAAS,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;gBAE1C,IAAI,SAAS,KAAK,4BAAoB,EAAE;oBACtC,IAAI,GAAG,QAAQ,CAAC;iBACjB;qBAAM;oBACL,IAAI,GAAG,MAAM,CAAC;iBACf;aACF;YACD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useCallback = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
function useCallback(use) {
|
|
6
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
7
|
+
return new Promise((resolve, reject) => {
|
|
8
|
+
const callback = (err) => {
|
|
9
|
+
if (err != null) {
|
|
10
|
+
reject(err);
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
resolve();
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
use(callback);
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
exports.useCallback = useCallback;
|
|
21
|
+
//# sourceMappingURL=callback.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"callback.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/promise/callback.ts"],"names":[],"mappings":";;;;AAKA,SAAsB,WAAW,CAAC,GAAuB;;QACvD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,MAAM,QAAQ,GAAG,CAAC,GAAkB,EAAE,EAAE;gBACtC,IAAI,GAAG,IAAI,IAAI,EAAE;oBACf,MAAM,CAAC,GAAG,CAAC,CAAC;iBACb;qBAAM;oBACL,OAAO,EAAE,CAAC;iBACX;YACH,CAAC,CAAC;YAEF,GAAG,CAAC,QAAQ,CAAC,CAAC;QAChB,CAAC,CAAC,CAAC;IACL,CAAC;CAAA;AAZD,kCAYC"}
|
package/src/lib/promise/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./callback"), exports);
|
|
4
5
|
tslib_1.__exportStar(require("./is"), exports);
|
|
5
6
|
tslib_1.__exportStar(require("./poll"), exports);
|
|
6
7
|
tslib_1.__exportStar(require("./map"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/promise/index.ts"],"names":[],"mappings":";;;AAAA,+CAAqB;AACrB,iDAAuB;AACvB,gDAAsB;AACtB,oDAA0B;AAC1B,yDAA+B;AAC/B,wDAA8B;AAC9B,iDAAuB;AACvB,gDAAsB"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/promise/index.ts"],"names":[],"mappings":";;;AAAA,qDAA2B;AAC3B,+CAAqB;AACrB,iDAAuB;AACvB,gDAAsB;AACtB,oDAA0B;AAC1B,yDAA+B;AAC/B,wDAA8B;AAC9B,iDAAuB;AACvB,gDAAsB"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export interface FirstAndLastCharacterOccurrence {
|
|
2
|
+
readonly first: number | -1;
|
|
3
|
+
readonly last: number | -1;
|
|
4
|
+
/**
|
|
5
|
+
* Total number of occurrences.
|
|
6
|
+
*/
|
|
7
|
+
readonly occurences: number;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Find the first and last occurence of the input character in the input string.
|
|
11
|
+
*
|
|
12
|
+
* @param input string to find the character occurrences
|
|
13
|
+
* @param find character to find
|
|
14
|
+
* @returns
|
|
15
|
+
*/
|
|
16
|
+
export declare function firstAndLastCharacterOccurrence(input: string, find: string): FirstAndLastCharacterOccurrence;
|
|
17
|
+
/**
|
|
18
|
+
* Replaces the character at the given index with the replacement string.
|
|
19
|
+
*
|
|
20
|
+
* @param input
|
|
21
|
+
* @param index
|
|
22
|
+
* @param replacement
|
|
23
|
+
* @returns
|
|
24
|
+
*/
|
|
25
|
+
export declare function replaceCharacterAtIndexWith(input: string, index: number, replacement: string): string;
|
|
26
|
+
/**
|
|
27
|
+
* Splits the input string at the given character index.
|
|
28
|
+
*
|
|
29
|
+
* @param input
|
|
30
|
+
* @param index
|
|
31
|
+
* @param replacement
|
|
32
|
+
* @returns
|
|
33
|
+
*/
|
|
34
|
+
export declare function splitStringAtIndex(input: string, index: number, inclusive?: boolean): [string, string];
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.splitStringAtIndex = exports.replaceCharacterAtIndexWith = exports.firstAndLastCharacterOccurrence = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Find the first and last occurence of the input character in the input string.
|
|
6
|
+
*
|
|
7
|
+
* @param input string to find the character occurrences
|
|
8
|
+
* @param find character to find
|
|
9
|
+
* @returns
|
|
10
|
+
*/
|
|
11
|
+
function firstAndLastCharacterOccurrence(input, find) {
|
|
12
|
+
let first = -1;
|
|
13
|
+
let last = -1;
|
|
14
|
+
let occurences = 0;
|
|
15
|
+
if (find.length !== 1) {
|
|
16
|
+
throw new Error('firstAndLastCharacterOccurrence() expects a single character as find input.');
|
|
17
|
+
}
|
|
18
|
+
for (let i = 0; i < input.length; i += 1) {
|
|
19
|
+
if (input[i] === find) {
|
|
20
|
+
if (first === -1) {
|
|
21
|
+
first = i;
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
last = i;
|
|
25
|
+
}
|
|
26
|
+
occurences += 1;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
if (first !== -1 && last === -1) {
|
|
30
|
+
last = first;
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
first,
|
|
34
|
+
last,
|
|
35
|
+
occurences
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
exports.firstAndLastCharacterOccurrence = firstAndLastCharacterOccurrence;
|
|
39
|
+
/**
|
|
40
|
+
* Replaces the character at the given index with the replacement string.
|
|
41
|
+
*
|
|
42
|
+
* @param input
|
|
43
|
+
* @param index
|
|
44
|
+
* @param replacement
|
|
45
|
+
* @returns
|
|
46
|
+
*/
|
|
47
|
+
function replaceCharacterAtIndexWith(input, index, replacement) {
|
|
48
|
+
const [head, tail] = splitStringAtIndex(input, index, false);
|
|
49
|
+
return head + replacement + tail;
|
|
50
|
+
}
|
|
51
|
+
exports.replaceCharacterAtIndexWith = replaceCharacterAtIndexWith;
|
|
52
|
+
/**
|
|
53
|
+
* Splits the input string at the given character index.
|
|
54
|
+
*
|
|
55
|
+
* @param input
|
|
56
|
+
* @param index
|
|
57
|
+
* @param replacement
|
|
58
|
+
* @returns
|
|
59
|
+
*/
|
|
60
|
+
function splitStringAtIndex(input, index, inclusive = false) {
|
|
61
|
+
const head = input.substring(0, index);
|
|
62
|
+
const tail = input.substring(index + (inclusive ? 0 : 1));
|
|
63
|
+
return [head, tail];
|
|
64
|
+
}
|
|
65
|
+
exports.splitStringAtIndex = splitStringAtIndex;
|
|
66
|
+
//# sourceMappingURL=char.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"char.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/string/char.ts"],"names":[],"mappings":";;;AASA;;;;;;GAMG;AACH,SAAgB,+BAA+B,CAAC,KAAa,EAAE,IAAY;IACzE,IAAI,KAAK,GAAW,CAAC,CAAC,CAAC;IACvB,IAAI,IAAI,GAAW,CAAC,CAAC,CAAC;IACtB,IAAI,UAAU,GAAG,CAAC,CAAC;IAEnB,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE;QACrB,MAAM,IAAI,KAAK,CAAC,6EAA6E,CAAC,CAAC;KAChG;IAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE;QACxC,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE;YACrB,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE;gBAChB,KAAK,GAAG,CAAC,CAAC;aACX;iBAAM;gBACL,IAAI,GAAG,CAAC,CAAC;aACV;YAED,UAAU,IAAI,CAAC,CAAC;SACjB;KACF;IAED,IAAI,KAAK,KAAK,CAAC,CAAC,IAAI,IAAI,KAAK,CAAC,CAAC,EAAE;QAC/B,IAAI,GAAG,KAAK,CAAC;KACd;IAED,OAAO;QACL,KAAK;QACL,IAAI;QACJ,UAAU;KACX,CAAC;AACJ,CAAC;AA9BD,0EA8BC;AAED;;;;;;;GAOG;AACH,SAAgB,2BAA2B,CAAC,KAAa,EAAE,KAAa,EAAE,WAAmB;IAC3F,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,kBAAkB,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;IAC7D,OAAO,IAAI,GAAG,WAAW,GAAG,IAAI,CAAC;AACnC,CAAC;AAHD,kEAGC;AAED;;;;;;;GAOG;AACH,SAAgB,kBAAkB,CAAC,KAAa,EAAE,KAAa,EAAE,SAAS,GAAG,KAAK;IAChF,MAAM,IAAI,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;IACvC,MAAM,IAAI,GAAG,KAAK,CAAC,SAAS,CAAC,KAAK,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1D,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AACtB,CAAC;AAJD,gDAIC"}
|
package/src/lib/string/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./char"), exports);
|
|
4
5
|
tslib_1.__exportStar(require("./string"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./replace"), exports);
|
|
5
7
|
tslib_1.__exportStar(require("./transform"), exports);
|
|
6
8
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/string/index.ts"],"names":[],"mappings":";;;AAAA,mDAAyB;AACzB,sDAA4B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/string/index.ts"],"names":[],"mappings":";;;AAAA,iDAAuB;AACvB,mDAAyB;AACzB,oDAA0B;AAC1B,sDAA4B"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ArrayOrValue } from '@dereekb/util';
|
|
2
|
+
import { MapSameFunction } from '../value/map';
|
|
3
|
+
export declare type ReplaceStringsFunction = MapSameFunction<string>;
|
|
4
|
+
export interface ReplaceStringsConfig {
|
|
5
|
+
/**
|
|
6
|
+
* Strings to target/replace.
|
|
7
|
+
*/
|
|
8
|
+
replace: ArrayOrValue<string>;
|
|
9
|
+
/**
|
|
10
|
+
* Value to replace all recurrences with.
|
|
11
|
+
*/
|
|
12
|
+
replaceWith: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function replaceStringsFunction(config: ReplaceStringsConfig): (input: string) => string;
|
|
15
|
+
export declare const REGEX_SPECIAL_CHARACTERS: string[];
|
|
16
|
+
export declare const REGEX_SPECIAL_CHARACTERS_SET: Set<string>;
|
|
17
|
+
/**
|
|
18
|
+
* Creates an escaped regex string joined with or values that finds all of the input values.
|
|
19
|
+
*
|
|
20
|
+
* @param find
|
|
21
|
+
*/
|
|
22
|
+
export declare function findStringsRegexString(find: ArrayOrValue<string>): string;
|
|
23
|
+
/**
|
|
24
|
+
* Escapes the input string to be usable in a Regex value.
|
|
25
|
+
*
|
|
26
|
+
* For instance, 'hello.world' will be escaped to be 'hello\.world'
|
|
27
|
+
*
|
|
28
|
+
* @param input
|
|
29
|
+
*/
|
|
30
|
+
export declare function escapeStringForRegex(input: string): string;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.escapeStringForRegex = exports.findStringsRegexString = exports.REGEX_SPECIAL_CHARACTERS_SET = exports.REGEX_SPECIAL_CHARACTERS = exports.replaceStringsFunction = void 0;
|
|
4
|
+
const util_1 = require("@dereekb/util");
|
|
5
|
+
const char_1 = require("./char");
|
|
6
|
+
function replaceStringsFunction(config) {
|
|
7
|
+
const { replace: replaceInput, replaceWith } = config;
|
|
8
|
+
const replaceRegexString = findStringsRegexString(replaceInput);
|
|
9
|
+
const replaceRegex = new RegExp(replaceRegexString, 'g');
|
|
10
|
+
return (input) => input.replace(replaceRegex, replaceWith);
|
|
11
|
+
}
|
|
12
|
+
exports.replaceStringsFunction = replaceStringsFunction;
|
|
13
|
+
exports.REGEX_SPECIAL_CHARACTERS = ['\\', '^', '$', '.', '|', '?', '*', '+', '(', ')', '[', ']', '{', '}'];
|
|
14
|
+
exports.REGEX_SPECIAL_CHARACTERS_SET = new Set(exports.REGEX_SPECIAL_CHARACTERS);
|
|
15
|
+
/**
|
|
16
|
+
* Creates an escaped regex string joined with or values that finds all of the input values.
|
|
17
|
+
*
|
|
18
|
+
* @param find
|
|
19
|
+
*/
|
|
20
|
+
function findStringsRegexString(find) {
|
|
21
|
+
const input = (0, util_1.asArray)(find);
|
|
22
|
+
const escapedInput = input.map(escapeStringForRegex);
|
|
23
|
+
return escapedInput.join('|');
|
|
24
|
+
}
|
|
25
|
+
exports.findStringsRegexString = findStringsRegexString;
|
|
26
|
+
/**
|
|
27
|
+
* Escapes the input string to be usable in a Regex value.
|
|
28
|
+
*
|
|
29
|
+
* For instance, 'hello.world' will be escaped to be 'hello\.world'
|
|
30
|
+
*
|
|
31
|
+
* @param input
|
|
32
|
+
*/
|
|
33
|
+
function escapeStringForRegex(input) {
|
|
34
|
+
/**
|
|
35
|
+
* index of all occurences in the input to replace/merge together.
|
|
36
|
+
*/
|
|
37
|
+
const occurrences = [];
|
|
38
|
+
for (let i = 0; i < input.length; i += 1) {
|
|
39
|
+
const char = input[i];
|
|
40
|
+
if (exports.REGEX_SPECIAL_CHARACTERS_SET.has(char)) {
|
|
41
|
+
occurrences.push(i);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
let result;
|
|
45
|
+
function escapeCharacter(char) {
|
|
46
|
+
return `\\${char}`;
|
|
47
|
+
}
|
|
48
|
+
switch (occurrences.length) {
|
|
49
|
+
case 0:
|
|
50
|
+
result = input;
|
|
51
|
+
break;
|
|
52
|
+
case 1:
|
|
53
|
+
const charToReplace = input[occurrences[0]];
|
|
54
|
+
result = (0, char_1.replaceCharacterAtIndexWith)(input, occurrences[0], escapeCharacter(charToReplace)); //Add an escape to the character
|
|
55
|
+
break;
|
|
56
|
+
default:
|
|
57
|
+
const parts = [];
|
|
58
|
+
const endAt = occurrences.length;
|
|
59
|
+
let start = 0;
|
|
60
|
+
let occurrence = 0;
|
|
61
|
+
for (let i = 0; i < endAt; i += 1) {
|
|
62
|
+
occurrence = occurrences[i];
|
|
63
|
+
const char = input[occurrence];
|
|
64
|
+
const sub = input.substring(start, occurrence);
|
|
65
|
+
const part = sub + escapeCharacter(char);
|
|
66
|
+
parts.push(part);
|
|
67
|
+
start = occurrence + 1;
|
|
68
|
+
}
|
|
69
|
+
// add in the last substring
|
|
70
|
+
parts.push(input.substring(start));
|
|
71
|
+
// join all parts together
|
|
72
|
+
result = parts.join('');
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
return result;
|
|
76
|
+
}
|
|
77
|
+
exports.escapeStringForRegex = escapeStringForRegex;
|
|
78
|
+
//# sourceMappingURL=replace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"replace.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/string/replace.ts"],"names":[],"mappings":";;;AAAA,wCAAsD;AAEtD,iCAAqD;AAerD,SAAgB,sBAAsB,CAAC,MAA4B;IACjE,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,GAAG,MAAM,CAAC;IACtD,MAAM,kBAAkB,GAAG,sBAAsB,CAAC,YAAY,CAAC,CAAC;IAChE,MAAM,YAAY,GAAG,IAAI,MAAM,CAAC,kBAAkB,EAAE,GAAG,CAAC,CAA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KAAK,CAAC;YACJ,MAAM,aAAa,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;YAC5C,MAAM,GAAG,IAAA,kCAA2B,EAAC,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,eAAe,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,gCAAgC;YAC7H,MAAM;QACR;YACE,MAAM,KAAK,GAAa,EAAE,CAAC;YAC3B,MAAM,KAAK,GAAG,WAAW,CAAC,MAAM,CAAC;YAEjC,IAAI,KAAK,GAAW,CAAC,CAAC;YACtB,IAAI,UAAU,GAAW,CAAC,CAAC;YAE3B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,IAAI,CAAC,EAAE;gBACjC,UAAU,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;gBAE5B,MAAM,IAAI,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC;gBAC/B,MAAM,GAAG,GAAG,KAAK,CAAC,SAAS,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;gBAC/C,MAAM,IAAI,GAAG,GAAG,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;gBACzC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBAEjB,KAAK,GAAG,UAAU,GAAG,CAAC,CAAC;aACxB;YAED,4BAA4B;YAC5B,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;YAEnC,0BAA0B;YAC1B,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACxB,MAAM;KACT;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAvDD,oDAuDC"}
|
package/src/lib/value/map.d.ts
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
|
+
import { ArrayOrValue } from '../array/array';
|
|
1
2
|
import { PromiseOrValue } from '../promise/promise';
|
|
2
|
-
import { Maybe } from './maybe.type';
|
|
3
|
+
import { Maybe, MaybeNot } from './maybe.type';
|
|
3
4
|
/**
|
|
4
5
|
* Converts one value to another.
|
|
5
6
|
*/
|
|
6
7
|
export declare type MapFunction<I, O> = (input: I) => O;
|
|
8
|
+
/**
|
|
9
|
+
* MapFunction with the same input as output.
|
|
10
|
+
*/
|
|
11
|
+
export declare type MapSameFunction<I> = MapFunction<I, I>;
|
|
7
12
|
/**
|
|
8
13
|
* Converts a MapFunction into one that returns a promise.
|
|
9
14
|
*/
|
|
@@ -48,3 +53,25 @@ export declare type MapFunctionOutput<O extends object, I = unknown> = O & {
|
|
|
48
53
|
*/
|
|
49
54
|
export declare function wrapMapFunctionOutput<O extends object, I = unknown>(fn: MapFunction<I, O>): MapFunction<I, MapFunctionOutput<O, I>>;
|
|
50
55
|
export declare function mapFunctionOutput<O extends object, I = unknown>(output: O, input: I): MapFunctionOutput<O, I>;
|
|
56
|
+
/**
|
|
57
|
+
* Chains together multiple MapSameFunctions in the same order. Functions that are not defined are ignored.
|
|
58
|
+
*
|
|
59
|
+
* @param fns
|
|
60
|
+
*/
|
|
61
|
+
export declare function chainMapSameFunctions<I>(input: ArrayOrValue<Maybe<MapSameFunction<I>>>): MapSameFunction<I>;
|
|
62
|
+
/**
|
|
63
|
+
* Creates a single function that chains the two map functions together, if apply is true or undefined.
|
|
64
|
+
*
|
|
65
|
+
* If apply is false, or the second map function is not defined, returns the first map function.
|
|
66
|
+
*
|
|
67
|
+
* @param a
|
|
68
|
+
* @param b
|
|
69
|
+
*/
|
|
70
|
+
export declare function chainMapFunction<I>(a: MapSameFunction<I>, b: Maybe<MapSameFunction<I>>): MapSameFunction<I>;
|
|
71
|
+
export declare function chainMapFunction<I>(a: MapSameFunction<I>, b: Maybe<MapSameFunction<I>>, apply?: boolean): MapSameFunction<I>;
|
|
72
|
+
export declare function chainMapFunction<I, O, B>(a: MapFunction<I, O>, b: MapFunction<O, B>): MapFunction<I, B>;
|
|
73
|
+
export declare function chainMapFunction<I, O, B>(a: MapFunction<I, O>, b: MaybeNot): MapFunction<I, O>;
|
|
74
|
+
export declare function chainMapFunction<I, O, B>(a: MapFunction<I, O>, b: Maybe<MapFunction<O, B>>, apply: false): MapFunction<I, O>;
|
|
75
|
+
export declare function chainMapFunction<I, O, B>(a: MapFunction<I, O>, b: MaybeNot, apply: true): MapFunction<I, O>;
|
|
76
|
+
export declare function chainMapFunction<I, O, B>(a: MapFunction<I, O>, b: MapFunction<O, B>, apply: true): MapFunction<I, B>;
|
|
77
|
+
export declare function chainMapFunction<I, O, B>(a: MapFunction<I, O>, b: Maybe<MapFunction<O, B>>, apply: boolean): MapFunction<I, O> | MapFunction<I, B>;
|
package/src/lib/value/map.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.mapFunctionOutput = exports.wrapMapFunctionOutput = exports.mapFunctionOutputPair = exports.isMapIdentityFunction = exports.mapIdentityFunction = exports.MAP_IDENTITY = exports.mapArrayFunction = void 0;
|
|
3
|
+
exports.chainMapFunction = exports.chainMapSameFunctions = exports.mapFunctionOutput = exports.wrapMapFunctionOutput = exports.mapFunctionOutputPair = exports.isMapIdentityFunction = exports.mapIdentityFunction = exports.MAP_IDENTITY = exports.mapArrayFunction = void 0;
|
|
4
|
+
const array_1 = require("../array/array");
|
|
5
|
+
const array_value_1 = require("../array/array.value");
|
|
4
6
|
const build_1 = require("./build");
|
|
5
7
|
function mapArrayFunction(mapFunction) {
|
|
6
8
|
return (input) => input.map(mapFunction);
|
|
@@ -53,4 +55,39 @@ function mapFunctionOutput(output, input) {
|
|
|
53
55
|
});
|
|
54
56
|
}
|
|
55
57
|
exports.mapFunctionOutput = mapFunctionOutput;
|
|
58
|
+
// MARK: Chaining
|
|
59
|
+
/**
|
|
60
|
+
* Chains together multiple MapSameFunctions in the same order. Functions that are not defined are ignored.
|
|
61
|
+
*
|
|
62
|
+
* @param fns
|
|
63
|
+
*/
|
|
64
|
+
function chainMapSameFunctions(input) {
|
|
65
|
+
const fns = (0, array_value_1.filterMaybeValues)((0, array_1.asArray)(input).filter((x) => !isMapIdentityFunction(x))); // remove all identify functions too
|
|
66
|
+
let fn;
|
|
67
|
+
switch (fns.length) {
|
|
68
|
+
case 0:
|
|
69
|
+
fn = mapIdentityFunction();
|
|
70
|
+
break;
|
|
71
|
+
case 1:
|
|
72
|
+
fn = fns[0];
|
|
73
|
+
break;
|
|
74
|
+
default:
|
|
75
|
+
fn = fns[0];
|
|
76
|
+
for (let i = 1; i < fns.length; i += 1) {
|
|
77
|
+
fn = chainMapFunction(fn, fns[i]);
|
|
78
|
+
}
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
return fn;
|
|
82
|
+
}
|
|
83
|
+
exports.chainMapSameFunctions = chainMapSameFunctions;
|
|
84
|
+
function chainMapFunction(a, b, apply = true) {
|
|
85
|
+
if (apply && b != null) {
|
|
86
|
+
return (x) => b(a(x));
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
return a;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
exports.chainMapFunction = chainMapFunction;
|
|
56
93
|
//# sourceMappingURL=map.js.map
|
package/src/lib/value/map.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"map.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/value/map.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"map.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/value/map.ts"],"names":[],"mappings":";;;AAAA,0CAAuD;AACvD,sDAAyD;AAEzD,mCAAgC;AAmChC,SAAgB,gBAAgB,CAAO,WAA8B;IACnE,OAAO,CAAC,KAAU,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;AAChD,CAAC;AAFD,4CAEC;AAEM,MAAM,YAAY,GAAG,CAAC,KAAc,EAAE,EAAE,CAAC,KAAK,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;QAClB,KAAK,CAAC;YACJ,EAAE,GAAG,mBAAmB,EAAE,CAAC;YAC3B,MAAM;QACR,KAAK,CAAC;YACJ,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;YACZ,MAAM;QACR;YACE,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;YAEZ,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE;gBACtC,EAAE,GAAG,gBAAgB,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;aACnC;YACD,MAAM;KACT;IAED,OAAO,EAAE,CAAC;AACZ,CAAC;AArBD,sDAqBC;AAkBD,SAAgB,gBAAgB,CAAU,CAAoB,EAAE,CAA2B,EAAE,KAAK,GAAG,IAAI;IACvG,IAAI,KAAK,IAAI,CAAC,IAAI,IAAI,EAAE;QACtB,OAAO,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;KACvB;SAAM;QACL,OAAO,CAAC,CAAC;KACV;AACH,CAAC;AAND,4CAMC"}
|
package/src/lib/value/point.d.ts
CHANGED
|
@@ -108,8 +108,7 @@ export declare function latLngPointPrecisionFunction(precision: LatLngPrecision)
|
|
|
108
108
|
* Converts the input to a LatLngString
|
|
109
109
|
*/
|
|
110
110
|
export declare type LatLngStringFunction = ((lat: Latitude | LatLngPoint | LatLngString | string, lng?: Longitude) => LatLngString) & ((latLng: string | LatLngString) => LatLngString) & ((latLng: LatLngPoint) => LatLngString) & ((lat: Latitude, lng?: Longitude) => LatLngString);
|
|
111
|
-
export
|
|
112
|
-
}
|
|
111
|
+
export declare type LatLngStringFunctionConfig = LatLngPointFunctionConfig;
|
|
113
112
|
/**
|
|
114
113
|
* Creates a LatLngStringFunction
|
|
115
114
|
*
|
package/src/lib/value/point.js
CHANGED
|
@@ -116,7 +116,7 @@ exports.latLngPointPrecisionFunction = latLngPointPrecisionFunction;
|
|
|
116
116
|
function latLngStringFunction(config) {
|
|
117
117
|
const fn = latLngPointFunction(config);
|
|
118
118
|
return (lat, lng) => {
|
|
119
|
-
|
|
119
|
+
const latLng = fn(lat, lng);
|
|
120
120
|
return `${latLng.lat},${latLng.lng}`;
|
|
121
121
|
};
|
|
122
122
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"point.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/value/point.ts"],"names":[],"mappings":";;;AACA,2CAA+E;AAalE,QAAA,kBAAkB,GAAG,CAAC,IAAI,CAAC;AAC3B,QAAA,kBAAkB,GAAG,IAAI,CAAC;AAC1B,QAAA,mBAAmB,GAAG,CAAC,KAAK,CAAC;AAC7B,QAAA,mBAAmB,GAAG,KAAK,CAAC;AAOzC,SAAgB,WAAW,CAAC,GAAa,EAAE,GAAc;IACvD,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;AACtB,CAAC;AAFD,kCAEC;AAED,SAAgB,eAAe,CAAC,GAAa;IAC3C,OAAO,GAAG,IAAI,0BAAkB,IAAI,GAAG,IAAI,0BAAkB,CAAC;AAChE,CAAC;AAFD,0CAEC;AAED,SAAgB,gBAAgB,CAAC,GAAc;IAC7C,OAAO,GAAG,IAAI,2BAAmB,IAAI,GAAG,IAAI,2BAAmB,CAAC;AAClE,CAAC;AAFD,4CAEC;AAED,SAAgB,kBAAkB;IAChC,OAAO,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;AAC5B,CAAC;AAFD,gDAEC;AAED;;;;;GAKG;AACH,SAAgB,kBAAkB,CAAC,KAAkB;IACnD,OAAO,eAAe,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,gBAAgB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AACnE,CAAC;AAFD,gDAEC;AAkBD,SAAgB,YAAY,CAAC,GAA0C,EAAE,GAAe;IACtF,OAAO,o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CAAC;AACJ,CAAC;AAtBD,kDAsBC;AAED;;;;GAIG;AACH,SAAgB,qBAAqB,CAAC,YAAmC;IACvE,MAAM,CAAC,SAAS,EAAE,SAAS,CAAC,GAAG,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACvD,MAAM,GAAG,GAAG,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,yCAAyC;IAC7E,MAAM,GAAG,GAAG,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IACnC,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;AACtB,CAAC;AALD,sDAKC;AAED,SAAgB,gBAAgB,CAAC,WAAwB,EAAE,YAAmC;IAC5F,OAAO,wBAAwB,CAAC,YAAY,CAAC,CAAC,WAAW,CAAC,CAAC;AAC7D,CAAC;AAFD,4CAEC;AASD,SAAgB,wBAAwB,CAAC,eAAqC,kBAAkB;IAC9F,OAAO,CAAC,WAAwB,EAAE,EAAE,CAAC,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,YAAY,EAAE,CAAC,CAAC;AACxG,CAAC;AAFD,4DAEC;AAkCD;;;;;GAKG;AACH,SAAgB,uBAAuB,CAAsB,MAAkC;IAC7F,MAAM,EAAE,GAAG,mBAAmB,CAAC,MAAM,CAAC,CAAC;IACvC,OAAO,CAAC,IAAO,EAAE,EAAE;QACjB,MAAM,MAAM,GAAgB,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC5C,OAAO;YACL,MAAM;YACN,IAAI;SACL,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AATD,0DASC"}
|
package/test/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
# [8.10.0](https://github.com/dereekb/dbx-components/compare/v8.9.1-dev...v8.10.0) (2022-07-04)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
5
9
|
## [8.9.1](https://github.com/dereekb/dbx-components/compare/v8.9.0-dev...v8.9.1) (2022-06-30)
|
|
6
10
|
|
|
7
11
|
|
package/test/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dereekb/util/test",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.10.0",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"main": "./src/index.js",
|
|
6
6
|
"typings": "./src/index.d.ts",
|
|
7
7
|
"dependencies": {},
|
|
8
8
|
"peerDependencies": {
|
|
9
|
-
"@dereekb/util": "8.
|
|
9
|
+
"@dereekb/util": "8.10.0",
|
|
10
10
|
"make-error": "^1.3.0",
|
|
11
11
|
"ts-essentials": "^9.1.2",
|
|
12
12
|
"extra-set": "^2.2.11",
|