@dereekb/util 8.8.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 +32 -0
- package/package.json +1 -1
- package/src/lib/array/array.string.d.ts +8 -20
- package/src/lib/array/array.string.js +14 -13
- package/src/lib/array/array.string.js.map +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 +3 -1
- package/src/lib/index.js +3 -1
- 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/number/number.d.ts +4 -0
- package/src/lib/number/number.js.map +1 -1
- package/src/lib/number/round.d.ts +36 -1
- package/src/lib/number/round.js +51 -1
- package/src/lib/number/round.js.map +1 -1
- 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 +4 -0
- package/src/lib/string/index.js +8 -0
- package/src/lib/string/index.js.map +1 -0
- 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/{string.d.ts → string/string.d.ts} +2 -2
- package/src/lib/{string.js → string/string.js} +0 -0
- package/src/lib/string/string.js.map +1 -0
- package/src/lib/string/transform.d.ts +24 -0
- package/src/lib/string/transform.js +43 -0
- package/src/lib/string/transform.js.map +1 -0
- package/src/lib/value/index.d.ts +1 -0
- package/src/lib/value/index.js +1 -0
- package/src/lib/value/index.js.map +1 -1
- package/src/lib/value/map.d.ts +29 -1
- package/src/lib/value/map.js +42 -1
- package/src/lib/value/map.js.map +1 -1
- package/src/lib/value/point.d.ts +192 -0
- package/src/lib/value/point.js +191 -0
- package/src/lib/value/point.js.map +1 -0
- package/test/CHANGELOG.md +12 -0
- package/test/package.json +2 -2
- package/src/lib/string.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,38 @@
|
|
|
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
|
+
|
|
19
|
+
## [8.9.1](https://github.com/dereekb/dbx-components/compare/v8.9.0-dev...v8.9.1) (2022-06-30)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Bug Fixes
|
|
23
|
+
|
|
24
|
+
* fixed LatLngStringRef ([88d9afe](https://github.com/dereekb/dbx-components/commit/88d9afe64e3b6847cf965e0243674e3b057719ee))
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
# [8.9.0](https://github.com/dereekb/dbx-components/compare/v8.8.1-dev...v8.9.0) (2022-06-30)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
### Features
|
|
32
|
+
|
|
33
|
+
* added firestoreLatLngString() ([2af3e5f](https://github.com/dereekb/dbx-components/commit/2af3e5fcbcae665994df5cc68d1c246b5417a07d))
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
5
37
|
## [8.8.1](https://github.com/dereekb/dbx-components/compare/v8.8.0-dev...v8.8.1) (2022-06-29)
|
|
6
38
|
|
|
7
39
|
|
package/package.json
CHANGED
|
@@ -1,25 +1,13 @@
|
|
|
1
1
|
import { ReadKeyFunction, ReadKeysFunction } from '../key';
|
|
2
|
-
import {
|
|
2
|
+
import { MapFunction } from '../value/map';
|
|
3
|
+
import { DecisionFunctionFactory } from '../value/decision';
|
|
4
|
+
import { TransformStringFunctionConfig } from '../string/transform';
|
|
3
5
|
export declare function hasDifferentStringsNoCase(a: string[], b: string[]): boolean;
|
|
4
|
-
export declare
|
|
5
|
-
export declare
|
|
6
|
-
export declare
|
|
7
|
-
/**
|
|
8
|
-
* Whether or not to store all values as lowercase. Ignored if transform is provided.
|
|
9
|
-
*/
|
|
10
|
-
toLowercase?: boolean;
|
|
11
|
-
/**
|
|
12
|
-
* Whether or not to store all values as uppercase. Ignored if transform is provided.
|
|
13
|
-
*/
|
|
14
|
-
toUppercase?: boolean;
|
|
15
|
-
/**
|
|
16
|
-
* Optional transform function for text.
|
|
17
|
-
*/
|
|
18
|
-
transform?: TransformSingleStringFunction;
|
|
19
|
-
};
|
|
20
|
-
export declare type TransformSingleStringFunction = MapFunction<string, string>;
|
|
6
|
+
export declare const trimArray: MapFunction<string[], string[]>;
|
|
7
|
+
export declare const arrayToUppercase: MapFunction<string[], string[]>;
|
|
8
|
+
export declare const arrayToLowercase: MapFunction<string[], string[]>;
|
|
21
9
|
export declare type TransformStringsFunction = MapFunction<string[], string[]>;
|
|
22
|
-
export declare function transformStrings(config:
|
|
10
|
+
export declare function transformStrings(config: TransformStringFunctionConfig): TransformStringsFunction;
|
|
23
11
|
export declare function toCaseInsensitiveStringArray(values: Iterable<string>): string[];
|
|
24
12
|
export declare function uniqueCaseInsensitiveStrings(values: Iterable<string>): string[];
|
|
25
13
|
export declare function uniqueCaseInsensitiveStringsSet(values: Iterable<string>): Set<string>;
|
|
@@ -28,7 +16,7 @@ export declare function findUniqueCaseInsensitiveStrings<T, K extends string = s
|
|
|
28
16
|
export declare function containsStringAnyCase(values: Iterable<string>, valueToFind: string): boolean;
|
|
29
17
|
export declare function containsAnyStringAnyCase(values: Iterable<string>, valuesToFind: Iterable<string>): boolean;
|
|
30
18
|
export declare function containsAllStringsAnyCase(values: Iterable<string>, valuesToFind: Iterable<string>): boolean;
|
|
31
|
-
export interface FindUniqueStringsTransformConfig extends
|
|
19
|
+
export interface FindUniqueStringsTransformConfig extends TransformStringFunctionConfig {
|
|
32
20
|
/**
|
|
33
21
|
* Whether or not to compare values as lowercase when finding uniqueness.
|
|
34
22
|
*
|
|
@@ -1,27 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.caseInsensitiveFilterByIndexOfDecisionFactory = exports.searchStringFilterFunction = exports.findUniqueTransform = exports.containsAllStringsAnyCase = exports.containsAnyStringAnyCase = exports.containsStringAnyCase = exports.findUniqueCaseInsensitiveStrings = exports.flattenArrayUniqueCaseInsensitiveStrings = exports.uniqueCaseInsensitiveStringsSet = exports.uniqueCaseInsensitiveStrings = exports.toCaseInsensitiveStringArray = exports.transformStrings = exports.arrayToLowercase = exports.arrayToUppercase = exports.hasDifferentStringsNoCase = void 0;
|
|
3
|
+
exports.caseInsensitiveFilterByIndexOfDecisionFactory = exports.searchStringFilterFunction = exports.findUniqueTransform = exports.containsAllStringsAnyCase = exports.containsAnyStringAnyCase = exports.containsStringAnyCase = exports.findUniqueCaseInsensitiveStrings = exports.flattenArrayUniqueCaseInsensitiveStrings = exports.uniqueCaseInsensitiveStringsSet = exports.uniqueCaseInsensitiveStrings = exports.toCaseInsensitiveStringArray = exports.transformStrings = exports.arrayToLowercase = exports.arrayToUppercase = exports.trimArray = exports.hasDifferentStringsNoCase = void 0;
|
|
4
4
|
const array_1 = require("./array");
|
|
5
5
|
const array_unique_1 = require("./array.unique");
|
|
6
|
-
const string_1 = require("../string");
|
|
6
|
+
const string_1 = require("../string/string");
|
|
7
7
|
const set_1 = require("../set/set");
|
|
8
8
|
const iterable_map_1 = require("../iterable/iterable.map");
|
|
9
|
-
const
|
|
9
|
+
const map_1 = require("../value/map");
|
|
10
|
+
const transform_1 = require("../string/transform");
|
|
10
11
|
function hasDifferentStringsNoCase(a, b) {
|
|
11
12
|
return (0, set_1.hasDifferentValues)(a.map(string_1.caseInsensitiveString), b.map(string_1.caseInsensitiveString));
|
|
12
13
|
}
|
|
13
14
|
exports.hasDifferentStringsNoCase = hasDifferentStringsNoCase;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
exports.arrayToUppercase = arrayToUppercase;
|
|
18
|
-
function arrayToLowercase(input) {
|
|
19
|
-
return input.map((x) => x.toLowerCase());
|
|
20
|
-
}
|
|
21
|
-
exports.arrayToLowercase = arrayToLowercase;
|
|
15
|
+
exports.trimArray = (0, map_1.mapArrayFunction)(transform_1.stringTrimFunction);
|
|
16
|
+
exports.arrayToUppercase = (0, map_1.mapArrayFunction)(transform_1.stringToUppercaseFunction);
|
|
17
|
+
exports.arrayToLowercase = (0, map_1.mapArrayFunction)(transform_1.stringToLowercaseFunction);
|
|
22
18
|
function transformStrings(config) {
|
|
23
|
-
const transform =
|
|
24
|
-
|
|
19
|
+
const transform = (0, transform_1.transformStringFunction)(config);
|
|
20
|
+
if ((0, map_1.isMapIdentityFunction)(transform)) {
|
|
21
|
+
return (0, map_1.mapIdentityFunction)();
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
return (0, map_1.mapArrayFunction)(transform);
|
|
25
|
+
}
|
|
25
26
|
}
|
|
26
27
|
exports.transformStrings = transformStrings;
|
|
27
28
|
function toCaseInsensitiveStringArray(values) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array.string.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/array/array.string.ts"],"names":[],"mappings":";;;AAAA,mCAAuC;AACvC,iDAAoD;AAEpD,
|
|
1
|
+
{"version":3,"file":"array.string.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/array/array.string.ts"],"names":[],"mappings":";;;AAAA,mCAAuC;AACvC,iDAAoD;AAEpD,6CAAyD;AACzD,oCAAqF;AACrF,2DAAuD;AACvD,sCAAyG;AAEzG,mDAAuK;AAEvK,SAAgB,yBAAyB,CAAC,CAAW,EAAE,CAAW;IAChE,OAAO,IAAA,wBAAkB,EAAC,CAAC,CAAC,GAAG,CAAC,8BAAqB,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,8BAAqB,CAAC,CAAC,CAAC;AACxF,CAAC;AAFD,8DAEC;AAEY,QAAA,SAAS,GAAG,IAAA,sBAAgB,EAAC,8BAAkB,CAAC,CAAC;AACjD,QAAA,gBAAgB,GAAG,IAAA,sBAAgB,EAAC,qCAAyB,CAAC,CAAC;AAC/D,QAAA,gBAAgB,GAAG,IAAA,sBAAgB,EAAC,qCAAyB,CAAC,CAAC;AAI5E,SAAgB,gBAAgB,CAAC,MAAqC;IACpE,MAAM,SAAS,GAAG,IAAA,mCAAuB,EAAC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AG,WAAW,CAAC,KAAK,CAAC,CAAC;YACnC,MAAM,IAAI,GAAG,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;YAChD,OAAO,IAAI,CAAC;QACd,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC;AAZD,gEAYC;AAEM,MAAM,6CAA6C,GAA4C,CAAC,UAAkB,EAAE,EAAE;IAC3H,MAAM,YAAY,GAAG,UAAU,CAAC,iBAAiB,EAAE,CAAC;IACpD,OAAO,CAAC,MAAc,EAAE,EAAE,CAAC,MAAM,CAAC,iBAAiB,EAAE,CAAC,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC;AACrF,CAAC,CAAC;AAHW,QAAA,6CAA6C,iDAGxD"}
|
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","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/error/error.ts"],"names":[],"mappings":";;;AAAA,2CAAuC;AACvC,+CAAyD;AA2BzD,SAAgB,aAAa,CAAC,IAAqB,EAAE,OAAgB;IACnE,OAAO;QACL,IAAI;QACJ,OAAO;KACR,CAAC;AACJ,CAAC;AALD,sCAKC;AAYD;;;;;GAKG;AACH,SAAgB,eAAe,CAAC,UAA6B;IAC3D,IAAI,KAAwC,CAAC;IAE7C,IAAI,UAAU,EAAE;QACd,IAAK,UAAyB,CAAC,IAAI,EAAE;YACnC,KAAK,GAAG,UAA2B,CAAC;SACrC;aAAM,IAAK,UAA2B,CAAC,IAAI,EA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|
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';
|
|
15
16
|
export * from './service';
|
|
16
17
|
export * from './set';
|
|
17
18
|
export * from './storage';
|
|
19
|
+
export * from './string';
|
|
18
20
|
export * from './tree';
|
|
19
21
|
export * from './value';
|
|
20
22
|
export * from './boolean';
|
|
@@ -27,6 +29,6 @@ export * from './key';
|
|
|
27
29
|
export * from './number';
|
|
28
30
|
export * from './object';
|
|
29
31
|
export * from './page';
|
|
32
|
+
export * from './path';
|
|
30
33
|
export * from './sort';
|
|
31
|
-
export * from './string';
|
|
32
34
|
export * from './type';
|
package/src/lib/index.js
CHANGED
|
@@ -12,12 +12,14 @@ 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);
|
|
18
19
|
tslib_1.__exportStar(require("./service"), exports);
|
|
19
20
|
tslib_1.__exportStar(require("./set"), exports);
|
|
20
21
|
tslib_1.__exportStar(require("./storage"), exports);
|
|
22
|
+
tslib_1.__exportStar(require("./string"), exports);
|
|
21
23
|
tslib_1.__exportStar(require("./tree"), exports);
|
|
22
24
|
tslib_1.__exportStar(require("./value"), exports);
|
|
23
25
|
tslib_1.__exportStar(require("./boolean"), exports);
|
|
@@ -30,7 +32,7 @@ tslib_1.__exportStar(require("./key"), exports);
|
|
|
30
32
|
tslib_1.__exportStar(require("./number"), exports);
|
|
31
33
|
tslib_1.__exportStar(require("./object"), exports);
|
|
32
34
|
tslib_1.__exportStar(require("./page"), exports);
|
|
35
|
+
tslib_1.__exportStar(require("./path"), exports);
|
|
33
36
|
tslib_1.__exportStar(require("./sort"), exports);
|
|
34
|
-
tslib_1.__exportStar(require("./string"), 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,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,
|
|
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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"number.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/number/number.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"number.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/number/number.ts"],"names":[],"mappings":";;;AAOA;;;;;;GAMG;AACH,SAAgB,mBAAmB,CAAC,KAAoB,EAAE,OAAe;IACvE,MAAM,SAAS,GAAG,CAAC,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,CAAC,CAAC,GAAG,OAAO,CAAC;IACzC,OAAO,SAAS,KAAK,CAAC,CAAC;AACzB,CAAC;AAHD,kDAGC;AASD;;;;;;GAMG;AACH,SAAgB,sBAAsB,CAAC,KAAa,EAAE,OAAe;IACnE,MAAM,KAAK,GAAG,KAAK,GAAG,OAAO,CAAC;IAC9B,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACnC,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAErC,OAAO;QACL,KAAK;QACL,OAAO;QACP,WAAW,EAAE,SAAS,GAAG,OAAO;QAChC,YAAY,EAAE,UAAU,GAAG,OAAO;KACnC,CAAC;AACJ,CAAC;AAXD,wDAWC"}
|
|
@@ -1,3 +1,30 @@
|
|
|
1
|
+
import { Maybe } from '../value/maybe.type';
|
|
2
|
+
import { NumberString } from './number';
|
|
3
|
+
/**
|
|
4
|
+
* The number of decimal places ot use.
|
|
5
|
+
*/
|
|
6
|
+
export declare type NumberPrecision = number;
|
|
7
|
+
/**
|
|
8
|
+
* Same as cutToPrecision, but can take in a string or null/undefined.
|
|
9
|
+
*
|
|
10
|
+
* @param input
|
|
11
|
+
* @param precision
|
|
12
|
+
* @returns
|
|
13
|
+
*/
|
|
14
|
+
export declare function cutValueToPrecision(input: Maybe<number | NumberString>, precision: NumberPrecision): number;
|
|
15
|
+
/**
|
|
16
|
+
* Rounds the input
|
|
17
|
+
*/
|
|
18
|
+
export declare type CutValueToPrecisionFunction = ((input: Maybe<number | NumberString>) => number) & {
|
|
19
|
+
readonly _precision: number;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Creates a CutValueToPrecisionFunction
|
|
23
|
+
*
|
|
24
|
+
* @param precision
|
|
25
|
+
* @returns
|
|
26
|
+
*/
|
|
27
|
+
export declare function cutValueToPrecisionFunction(precision: NumberPrecision): CutValueToPrecisionFunction;
|
|
1
28
|
/**
|
|
2
29
|
* Rounds the input number to the given precision.
|
|
3
30
|
*
|
|
@@ -5,7 +32,15 @@
|
|
|
5
32
|
* @param precision
|
|
6
33
|
* @returns
|
|
7
34
|
*/
|
|
8
|
-
export declare function roundToPrecision(value: number, precision:
|
|
35
|
+
export declare function roundToPrecision(value: number, precision: NumberPrecision): number;
|
|
36
|
+
/**
|
|
37
|
+
* Cuts the input number to the given precision. For example, 1.25 with precision 1 will not be rounded up to 1.3, but instead be "cut" to 1.2
|
|
38
|
+
*
|
|
39
|
+
* @param value
|
|
40
|
+
* @param precision
|
|
41
|
+
* @returns
|
|
42
|
+
*/
|
|
43
|
+
export declare function cutToPrecision(value: number, precision: NumberPrecision): number;
|
|
9
44
|
/**
|
|
10
45
|
* Rounds the number up to a specific "step" that contains it.
|
|
11
46
|
*
|
package/src/lib/number/round.js
CHANGED
|
@@ -1,6 +1,43 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.roundNumberUpToStep = exports.roundToPrecision = void 0;
|
|
3
|
+
exports.roundNumberUpToStep = exports.cutToPrecision = exports.roundToPrecision = exports.cutValueToPrecisionFunction = exports.cutValueToPrecision = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Same as cutToPrecision, but can take in a string or null/undefined.
|
|
6
|
+
*
|
|
7
|
+
* @param input
|
|
8
|
+
* @param precision
|
|
9
|
+
* @returns
|
|
10
|
+
*/
|
|
11
|
+
function cutValueToPrecision(input, precision) {
|
|
12
|
+
return cutValueToPrecisionFunction(precision)(input);
|
|
13
|
+
}
|
|
14
|
+
exports.cutValueToPrecision = cutValueToPrecision;
|
|
15
|
+
/**
|
|
16
|
+
* Creates a CutValueToPrecisionFunction
|
|
17
|
+
*
|
|
18
|
+
* @param precision
|
|
19
|
+
* @returns
|
|
20
|
+
*/
|
|
21
|
+
function cutValueToPrecisionFunction(precision) {
|
|
22
|
+
const fn = ((input) => {
|
|
23
|
+
let value;
|
|
24
|
+
switch (typeof input) {
|
|
25
|
+
case 'number':
|
|
26
|
+
value = input;
|
|
27
|
+
break;
|
|
28
|
+
case 'string':
|
|
29
|
+
value = Number(input);
|
|
30
|
+
break;
|
|
31
|
+
default:
|
|
32
|
+
value = 0;
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
return cutToPrecision(value, precision);
|
|
36
|
+
});
|
|
37
|
+
fn._precision = precision;
|
|
38
|
+
return fn;
|
|
39
|
+
}
|
|
40
|
+
exports.cutValueToPrecisionFunction = cutValueToPrecisionFunction;
|
|
4
41
|
// MARK: Number/Math
|
|
5
42
|
/**
|
|
6
43
|
* Rounds the input number to the given precision.
|
|
@@ -13,6 +50,19 @@ function roundToPrecision(value, precision) {
|
|
|
13
50
|
return +(Math.round(Number(value + 'e+' + precision)) + 'e-' + precision);
|
|
14
51
|
}
|
|
15
52
|
exports.roundToPrecision = roundToPrecision;
|
|
53
|
+
/**
|
|
54
|
+
* Cuts the input number to the given precision. For example, 1.25 with precision 1 will not be rounded up to 1.3, but instead be "cut" to 1.2
|
|
55
|
+
*
|
|
56
|
+
* @param value
|
|
57
|
+
* @param precision
|
|
58
|
+
* @returns
|
|
59
|
+
*/
|
|
60
|
+
function cutToPrecision(value, precision) {
|
|
61
|
+
// use floor for positive numbers, ceil for negative numbers
|
|
62
|
+
const rndFn = value > 0 ? Math.floor : Math.ceil;
|
|
63
|
+
return +(rndFn(Number(value + 'e+' + precision)) + 'e-' + precision);
|
|
64
|
+
}
|
|
65
|
+
exports.cutToPrecision = cutToPrecision;
|
|
16
66
|
/**
|
|
17
67
|
* Rounds the number up to a specific "step" that contains it.
|
|
18
68
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"round.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/number/round.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"round.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/number/round.ts"],"names":[],"mappings":";;;AAWA;;;;;;GAMG;AACH,SAAgB,mBAAmB,CAAC,KAAmC,EAAE,SAA0B;IACjG,OAAO,2BAA2B,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,CAAC;AACvD,CAAC;AAFD,kDAEC;AASD;;;;;GAKG;AACH,SAAgB,2BAA2B,CAAC,SAA0B;IACpE,MAAM,EAAE,GAA0C,CAAC,CAAC,KAAmC,EAAE,EAAE;QACzF,IAAI,KAAa,CAAC;QAElB,QAAQ,OAAO,KAAK,EAAE;YACpB,KAAK,QAAQ;gBACX,KA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/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;
|