@duplojs/lang 0.0.1-beta.4 → 0.0.1-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/array/index.cjs +0 -3
- package/dist/array/index.d.ts +0 -1
- package/dist/array/index.mjs +1 -3
- package/dist/common/constraint/cast/number.d.ts +15 -0
- package/dist/common/constraint/cast/string.d.ts +9 -0
- package/dist/common/constraint/index.d.ts +1 -0
- package/dist/common/constraint/infer/array.d.ts +7 -0
- package/dist/{array/infer.cjs → common/constraint/infer/index.cjs} +1 -1
- package/dist/common/constraint/infer/index.d.ts +26 -0
- package/dist/{string/infer.mjs → common/constraint/infer/index.mjs} +1 -1
- package/dist/common/constraint/infer/number.d.ts +11 -0
- package/dist/common/constraint/infer/string.d.ts +10 -0
- package/dist/common/index.cjs +3 -0
- package/dist/common/index.mjs +3 -1
- package/dist/dataStructure/constraint/defaults/absolutePath.cjs +13 -0
- package/dist/dataStructure/constraint/defaults/absolutePath.d.ts +10 -0
- package/dist/dataStructure/constraint/defaults/absolutePath.mjs +12 -0
- package/dist/dataStructure/constraint/defaults/index.d.ts +2 -0
- package/dist/dataStructure/constraint/defaults/path.cjs +13 -0
- package/dist/dataStructure/constraint/defaults/path.d.ts +10 -0
- package/dist/dataStructure/constraint/defaults/path.mjs +12 -0
- package/dist/dataStructure/constraint/types/constraints.d.ts +2 -0
- package/dist/dataStructure/helpers/absolutePath.cjs +7 -0
- package/dist/dataStructure/helpers/absolutePath.d.ts +2 -0
- package/dist/dataStructure/helpers/absolutePath.mjs +7 -0
- package/dist/dataStructure/helpers/index.d.ts +2 -0
- package/dist/dataStructure/helpers/path.cjs +7 -0
- package/dist/dataStructure/helpers/path.d.ts +2 -0
- package/dist/dataStructure/helpers/path.mjs +7 -0
- package/dist/dataStructure/index.cjs +16 -0
- package/dist/dataStructure/index.mjs +11 -1
- package/dist/index.cjs +41 -39
- package/dist/index.mjs +3 -2
- package/dist/number/index.cjs +0 -3
- package/dist/number/index.d.ts +0 -1
- package/dist/number/index.mjs +1 -3
- package/dist/path/computeRelative.cjs +5 -6
- package/dist/path/computeRelative.d.ts +1 -1
- package/dist/path/computeRelative.mjs +5 -6
- package/dist/path/constraints/absolute.d.ts +1 -1
- package/dist/path/getBaseName.cjs +5 -7
- package/dist/path/getBaseName.d.ts +2 -2
- package/dist/path/getBaseName.mjs +5 -7
- package/dist/path/getExtensionName.cjs +7 -4
- package/dist/path/getExtensionName.d.ts +2 -2
- package/dist/path/getExtensionName.mjs +7 -4
- package/dist/path/getParentFolderPath.cjs +5 -4
- package/dist/path/getParentFolderPath.d.ts +1 -2
- package/dist/path/getParentFolderPath.mjs +5 -4
- package/dist/path/index.cjs +3 -3
- package/dist/path/index.d.ts +2 -2
- package/dist/path/index.mjs +3 -3
- package/dist/path/is.cjs +9 -4
- package/dist/path/is.d.ts +4 -2
- package/dist/path/is.mjs +9 -4
- package/dist/path/isAbsolute.cjs +3 -5
- package/dist/path/isAbsolute.d.ts +4 -2
- package/dist/path/isAbsolute.mjs +3 -5
- package/dist/path/normalize.cjs +18 -0
- package/dist/path/normalize.d.ts +2 -0
- package/dist/path/normalize.mjs +18 -0
- package/dist/path/resolveFrom.cjs +4 -5
- package/dist/path/resolveFrom.d.ts +9 -1
- package/dist/path/resolveFrom.mjs +4 -5
- package/dist/path/resolveRelative.cjs +17 -20
- package/dist/path/resolveRelative.d.ts +9 -2
- package/dist/path/resolveRelative.mjs +17 -20
- package/dist/path/types/index.d.ts +4 -0
- package/dist/path/types/isLiteralAbsolutePath.d.ts +2 -0
- package/dist/path/types/isLiteralPath.d.ts +20 -0
- package/dist/path/types/requireLiteralAbsolutePath.d.ts +3 -0
- package/dist/path/types/requireLiteralPath.d.ts +3 -0
- package/dist/string/index.cjs +0 -3
- package/dist/string/index.d.ts +0 -1
- package/dist/string/index.mjs +1 -3
- package/dist/string/types/split.d.ts +1 -1
- package/package.json +1 -1
- package/dist/array/infer.d.ts +0 -14
- package/dist/array/infer.mjs +0 -6
- package/dist/number/infer.cjs +0 -6
- package/dist/number/infer.d.ts +0 -12
- package/dist/number/infer.mjs +0 -6
- package/dist/path/fix.cjs +0 -8
- package/dist/path/fix.d.ts +0 -1
- package/dist/path/fix.mjs +0 -8
- package/dist/string/infer.cjs +0 -6
- package/dist/string/infer.d.ts +0 -12
package/dist/path/is.mjs
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
//#region scripts/path/is.ts
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
const dotSegmentRegExp = /(^|\/)\.(\/|$)/;
|
|
3
|
+
const endsWithSlash = /[^]+\/$/;
|
|
4
|
+
const dotDotRegExp = /(^|\/)\.\.(\/|$)/;
|
|
5
|
+
const invalidDotDotRegExp = /(^|\/)(?!\.\.(?:\/|$))[^/]+\/\.\.(?:\/|$)/;
|
|
6
|
+
function is(value) {
|
|
7
|
+
if (value === ".") return true;
|
|
8
|
+
if (value === "" || value.includes("\0") || value.includes("//") || endsWithSlash.test(value) || dotSegmentRegExp.test(value)) return false;
|
|
9
|
+
if (value.startsWith("/")) return !dotDotRegExp.test(value);
|
|
10
|
+
return !invalidDotDotRegExp.test(value);
|
|
6
11
|
}
|
|
7
12
|
//#endregion
|
|
8
13
|
export { is };
|
package/dist/path/isAbsolute.cjs
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
+
const require_is = require("./is.cjs");
|
|
1
2
|
//#region scripts/path/isAbsolute.ts
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const posixAbsolutePathRegex = /^\/(?:$|[^/]+(?:\/[^/]+)*(?:\/+)?$)/;
|
|
5
|
-
function isAbsolute(path) {
|
|
6
|
-
return !path.includes(nullCharacter) && posixAbsolutePathRegex.test(path) && !containBackPathRegex.test(path);
|
|
3
|
+
function isAbsolute(value) {
|
|
4
|
+
return value.startsWith("/") && require_is.is(value);
|
|
7
5
|
}
|
|
8
6
|
//#endregion
|
|
9
7
|
exports.isAbsolute = isAbsolute;
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
import { Absolute
|
|
2
|
-
|
|
1
|
+
import { Absolute } from './constraints';
|
|
2
|
+
import { IsLiteralAbsolutePath } from './types';
|
|
3
|
+
import type * as DString from '../string';
|
|
4
|
+
export declare function isAbsolute<GenericPath extends string>(value: GenericPath): value is (GenericPath extends Absolute ? GenericPath : IsLiteralAbsolutePath<GenericPath> extends true ? GenericPath : DString.IsLiteral<GenericPath> extends true ? never : GenericPath & Absolute);
|
package/dist/path/isAbsolute.mjs
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
+
import { is } from "./is.mjs";
|
|
1
2
|
//#region scripts/path/isAbsolute.ts
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const posixAbsolutePathRegex = /^\/(?:$|[^/]+(?:\/[^/]+)*(?:\/+)?$)/;
|
|
5
|
-
function isAbsolute(path) {
|
|
6
|
-
return !path.includes(nullCharacter) && posixAbsolutePathRegex.test(path) && !containBackPathRegex.test(path);
|
|
3
|
+
function isAbsolute(value) {
|
|
4
|
+
return value.startsWith("/") && is(value);
|
|
7
5
|
}
|
|
8
6
|
//#endregion
|
|
9
7
|
export { isAbsolute };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//#region scripts/path/normalize.ts
|
|
2
|
+
function normalize(path) {
|
|
3
|
+
if (path.includes("\0")) return null;
|
|
4
|
+
const absolute = path.startsWith("/");
|
|
5
|
+
const result = [];
|
|
6
|
+
for (const segment of path.split("/")) {
|
|
7
|
+
if (segment === "" || segment === ".") continue;
|
|
8
|
+
if (segment === "..") {
|
|
9
|
+
if (result.length !== 0 && result.at(-1) !== "..") result.pop();
|
|
10
|
+
else if (!absolute) result.push("..");
|
|
11
|
+
continue;
|
|
12
|
+
}
|
|
13
|
+
result.push(segment);
|
|
14
|
+
}
|
|
15
|
+
return absolute ? `/${result.join("/")}` : result.join("/") || ".";
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
exports.normalize = normalize;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//#region scripts/path/normalize.ts
|
|
2
|
+
function normalize(path) {
|
|
3
|
+
if (path.includes("\0")) return null;
|
|
4
|
+
const absolute = path.startsWith("/");
|
|
5
|
+
const result = [];
|
|
6
|
+
for (const segment of path.split("/")) {
|
|
7
|
+
if (segment === "" || segment === ".") continue;
|
|
8
|
+
if (segment === "..") {
|
|
9
|
+
if (result.length !== 0 && result.at(-1) !== "..") result.pop();
|
|
10
|
+
else if (!absolute) result.push("..");
|
|
11
|
+
continue;
|
|
12
|
+
}
|
|
13
|
+
result.push(segment);
|
|
14
|
+
}
|
|
15
|
+
return absolute ? `/${result.join("/")}` : result.join("/") || ".";
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
export { normalize };
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
const require_resolveRelative = require("./resolveRelative.cjs");
|
|
2
2
|
//#region scripts/path/resolveFrom.ts
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
return `/${result.replace(aboveRootRegex, "")}`;
|
|
3
|
+
function resolveFrom(origin, segments, params) {
|
|
4
|
+
const resultRelative = require_resolveRelative.resolveRelative(segments);
|
|
5
|
+
if (params?.stayInOrigin && (resultRelative === ".." || resultRelative.startsWith("../") || resultRelative.startsWith("/"))) return null;
|
|
6
|
+
return require_resolveRelative.resolveRelative([origin, resultRelative]);
|
|
8
7
|
}
|
|
9
8
|
//#endregion
|
|
10
9
|
exports.resolveFrom = resolveFrom;
|
|
@@ -1,3 +1,11 @@
|
|
|
1
1
|
import { Absolute, Path } from './constraints';
|
|
2
2
|
import { RequireSegments } from './types';
|
|
3
|
-
|
|
3
|
+
import type * as DCommon from '../common';
|
|
4
|
+
export interface ResolveFromParams {
|
|
5
|
+
stayInOrigin?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare function resolveFrom<const GenericSegments extends readonly (string & (Path | Absolute))[], const GenericParams extends ResolveFromParams>(origin: string & Absolute, segments: GenericSegments & RequireSegments<GenericSegments>, params?: GenericParams): (string & Absolute) | (DCommon.BreakGenericLink<DCommon.Or<[
|
|
8
|
+
DCommon.IsEqual<GenericParams["stayInOrigin"], ResolveFromParams["stayInOrigin"]>,
|
|
9
|
+
DCommon.IsEqual<GenericParams["stayInOrigin"], false>,
|
|
10
|
+
DCommon.IsEqual<GenericParams["stayInOrigin"], unknown>
|
|
11
|
+
]> extends true ? never : null>);
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { resolveRelative } from "./resolveRelative.mjs";
|
|
2
2
|
//#region scripts/path/resolveFrom.ts
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
return `/${result.replace(aboveRootRegex, "")}`;
|
|
3
|
+
function resolveFrom(origin, segments, params) {
|
|
4
|
+
const resultRelative = resolveRelative(segments);
|
|
5
|
+
if (params?.stayInOrigin && (resultRelative === ".." || resultRelative.startsWith("../") || resultRelative.startsWith("/"))) return null;
|
|
6
|
+
return resolveRelative([origin, resultRelative]);
|
|
8
7
|
}
|
|
9
8
|
//#endregion
|
|
10
9
|
export { resolveFrom };
|
|
@@ -1,26 +1,23 @@
|
|
|
1
1
|
//#region scripts/path/resolveRelative.ts
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
if (
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
function resolveRelative(paths) {
|
|
3
|
+
let absolute = false;
|
|
4
|
+
const result = [];
|
|
5
|
+
for (const path of paths) {
|
|
6
|
+
if (path === ".") continue;
|
|
7
|
+
if (path.startsWith("/")) {
|
|
8
|
+
absolute = true;
|
|
9
|
+
result.length = 0;
|
|
10
|
+
}
|
|
11
|
+
for (const segment of path.split("/")) {
|
|
12
|
+
if (segment === "") continue;
|
|
13
|
+
if (segment === "..") {
|
|
14
|
+
if (result.length && result.at(-1) !== "..") result.pop();
|
|
15
|
+
else if (!absolute) result.push("..");
|
|
16
|
+
} else result.push(segment);
|
|
11
17
|
}
|
|
12
|
-
const formattedSegment = segment.replace(segmentTrailingRegex, "").replace(segmentRelativeRegex, "");
|
|
13
|
-
if (formattedSegment.startsWith("/") || clearedPath === "") clearedPath = formattedSegment;
|
|
14
|
-
else if (clearedPath === "/") clearedPath += formattedSegment;
|
|
15
|
-
else clearedPath += `/${formattedSegment}`;
|
|
16
18
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
for (const element of clearedPath.split("/")) if (element === "..") {
|
|
20
|
-
if (!result.pop()) dotResult.push(element);
|
|
21
|
-
} else result.push(element);
|
|
22
|
-
if (dotResult.length === 0) return result.join("/");
|
|
23
|
-
return `${dotResult.join("/")}/${result.join("/")}`;
|
|
19
|
+
if (absolute) return `/${result.join("/")}`;
|
|
20
|
+
return result.join("/") || ".";
|
|
24
21
|
}
|
|
25
22
|
//#endregion
|
|
26
23
|
exports.resolveRelative = resolveRelative;
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
-
import { Path } from './constraints';
|
|
1
|
+
import { Absolute, Path } from './constraints';
|
|
2
2
|
import { RequireSegments } from './types';
|
|
3
|
-
|
|
3
|
+
import type * as DCommon from '../common';
|
|
4
|
+
type HasAbsolutePath<GenericSegments extends readonly (string & (Path | Absolute))[]> = DCommon.ContainExtends<{
|
|
5
|
+
[Prop in keyof GenericSegments]: [DCommon.IsExtends<GenericSegments[Prop], Absolute>];
|
|
6
|
+
}[Extract<keyof GenericSegments, number>], [
|
|
7
|
+
true
|
|
8
|
+
]>;
|
|
9
|
+
export declare function resolveRelative<const GenericSegments extends readonly (string & (Path | Absolute))[]>(segments: GenericSegments & RequireSegments<GenericSegments>): string & Path & (DCommon.BreakGenericLink<HasAbsolutePath<GenericSegments> extends true ? Absolute : unknown>);
|
|
10
|
+
export {};
|
|
@@ -1,26 +1,23 @@
|
|
|
1
1
|
//#region scripts/path/resolveRelative.ts
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
if (
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
function resolveRelative(paths) {
|
|
3
|
+
let absolute = false;
|
|
4
|
+
const result = [];
|
|
5
|
+
for (const path of paths) {
|
|
6
|
+
if (path === ".") continue;
|
|
7
|
+
if (path.startsWith("/")) {
|
|
8
|
+
absolute = true;
|
|
9
|
+
result.length = 0;
|
|
10
|
+
}
|
|
11
|
+
for (const segment of path.split("/")) {
|
|
12
|
+
if (segment === "") continue;
|
|
13
|
+
if (segment === "..") {
|
|
14
|
+
if (result.length && result.at(-1) !== "..") result.pop();
|
|
15
|
+
else if (!absolute) result.push("..");
|
|
16
|
+
} else result.push(segment);
|
|
11
17
|
}
|
|
12
|
-
const formattedSegment = segment.replace(segmentTrailingRegex, "").replace(segmentRelativeRegex, "");
|
|
13
|
-
if (formattedSegment.startsWith("/") || clearedPath === "") clearedPath = formattedSegment;
|
|
14
|
-
else if (clearedPath === "/") clearedPath += formattedSegment;
|
|
15
|
-
else clearedPath += `/${formattedSegment}`;
|
|
16
18
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
for (const element of clearedPath.split("/")) if (element === "..") {
|
|
20
|
-
if (!result.pop()) dotResult.push(element);
|
|
21
|
-
} else result.push(element);
|
|
22
|
-
if (dotResult.length === 0) return result.join("/");
|
|
23
|
-
return `${dotResult.join("/")}/${result.join("/")}`;
|
|
19
|
+
if (absolute) return `/${result.join("/")}`;
|
|
20
|
+
return result.join("/") || ".";
|
|
24
21
|
}
|
|
25
22
|
//#endregion
|
|
26
23
|
export { resolveRelative };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type * as DCommon from '../../common';
|
|
2
|
+
import type * as DString from '../../string';
|
|
3
|
+
type CheckSegment<GenericSegment extends readonly string[], GenericDotIsPass extends boolean, GenericIsFirst extends boolean = true> = GenericSegment extends readonly [] ? true : GenericSegment extends readonly [
|
|
4
|
+
infer InferredFirst extends string,
|
|
5
|
+
...infer InferredRest extends readonly string[]
|
|
6
|
+
] ? DCommon.Or<[
|
|
7
|
+
DCommon.IsEqual<".", InferredFirst>,
|
|
8
|
+
DString.Includes<InferredFirst, "/">,
|
|
9
|
+
DString.Includes<InferredFirst, "\0">,
|
|
10
|
+
DCommon.And<[
|
|
11
|
+
DCommon.IsEqual<GenericIsFirst, false>,
|
|
12
|
+
DCommon.IsEqual<"", InferredFirst>
|
|
13
|
+
]>,
|
|
14
|
+
DCommon.And<[
|
|
15
|
+
DCommon.IsEqual<GenericDotIsPass, true>,
|
|
16
|
+
DCommon.IsEqual<"..", InferredFirst>
|
|
17
|
+
]>
|
|
18
|
+
]> extends true ? false : CheckSegment<InferredRest, DCommon.Not<DCommon.IsEqual<InferredFirst, "..">>, false> : false;
|
|
19
|
+
export type IsLiteralPath<GenericValue extends string> = DString.IsLiteral<GenericValue> extends true ? GenericValue extends "" ? false : GenericValue extends "/" ? true : GenericValue extends "." ? true : DString.Split<GenericValue, "/"> extends infer InferredResult extends readonly string[] ? CheckSegment<InferredResult, false> : never : false;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { IsLiteralAbsolutePath } from './isLiteralAbsolutePath';
|
|
2
|
+
import type * as DCommon from '../../common';
|
|
3
|
+
export type RequireLiteralAbsolutePath<GenericValue extends string> = IsLiteralAbsolutePath<GenericValue> extends true ? unknown : DCommon.ComputedTypeError<"Value is not a absolute path.">;
|
package/dist/string/index.cjs
CHANGED
|
@@ -9,7 +9,6 @@ const require_extractAll = require("./extractAll.cjs");
|
|
|
9
9
|
const require_first = require("./first.cjs");
|
|
10
10
|
const require_includes = require("./includes.cjs");
|
|
11
11
|
const require_indexOf = require("./indexOf.cjs");
|
|
12
|
-
const require_infer = require("./infer.cjs");
|
|
13
12
|
const require_isComposedOf = require("./isComposedOf.cjs");
|
|
14
13
|
const require_isEmail = require("./isEmail.cjs");
|
|
15
14
|
const require_isIn = require("./isIn.cjs");
|
|
@@ -63,7 +62,6 @@ var string_exports = /* @__PURE__ */ require_runtime.__exportAll({
|
|
|
63
62
|
first: () => require_first.first,
|
|
64
63
|
includes: () => require_includes.includes,
|
|
65
64
|
indexOf: () => require_indexOf.indexOf,
|
|
66
|
-
infer: () => require_infer.infer,
|
|
67
65
|
isComposedOf: () => require_isComposedOf.isComposedOf,
|
|
68
66
|
isEmail: () => require_isEmail.isEmail,
|
|
69
67
|
isIn: () => require_isIn.isIn,
|
|
@@ -118,7 +116,6 @@ exports.extractAll = require_extractAll.extractAll;
|
|
|
118
116
|
exports.first = require_first.first;
|
|
119
117
|
exports.includes = require_includes.includes;
|
|
120
118
|
exports.indexOf = require_indexOf.indexOf;
|
|
121
|
-
exports.infer = require_infer.infer;
|
|
122
119
|
exports.isComposedOf = require_isComposedOf.isComposedOf;
|
|
123
120
|
exports.isEmail = require_isEmail.isEmail;
|
|
124
121
|
exports.isIn = require_isIn.isIn;
|
package/dist/string/index.d.ts
CHANGED
package/dist/string/index.mjs
CHANGED
|
@@ -9,7 +9,6 @@ import { extractAll } from "./extractAll.mjs";
|
|
|
9
9
|
import { first } from "./first.mjs";
|
|
10
10
|
import { includes } from "./includes.mjs";
|
|
11
11
|
import { indexOf } from "./indexOf.mjs";
|
|
12
|
-
import { infer } from "./infer.mjs";
|
|
13
12
|
import { isComposedOf } from "./isComposedOf.mjs";
|
|
14
13
|
import { emailRegex, isEmail } from "./isEmail.mjs";
|
|
15
14
|
import { isIn } from "./isIn.mjs";
|
|
@@ -63,7 +62,6 @@ var string_exports = /* @__PURE__ */ __exportAll({
|
|
|
63
62
|
first: () => first,
|
|
64
63
|
includes: () => includes,
|
|
65
64
|
indexOf: () => indexOf,
|
|
66
|
-
infer: () => infer,
|
|
67
65
|
isComposedOf: () => isComposedOf,
|
|
68
66
|
isEmail: () => isEmail,
|
|
69
67
|
isIn: () => isIn,
|
|
@@ -107,4 +105,4 @@ var string_exports = /* @__PURE__ */ __exportAll({
|
|
|
107
105
|
uuidRegex: () => uuidRegex
|
|
108
106
|
});
|
|
109
107
|
//#endregion
|
|
110
|
-
export { at, capitalize, charAt, concat, emailRegex, endsWith, extract, extractAll, first, includes, indexOf,
|
|
108
|
+
export { at, capitalize, charAt, concat, emailRegex, endsWith, extract, extractAll, first, includes, indexOf, isComposedOf, isEmail, isIn, isKeyof, isNotEmpty, isTrimmed, isUrl, isUuid, join, last, lastIndexOf, length, lengthEqual, maxCharacters, minCharacters, normalize, padEnd, padStart, pop, prepend, repeat, replace, replaceAll, search, shift, slice, sort, sortCompare, split, startsWith, string_exports, stringify, substring, test, to, toLowerCase, toUpperCase, trim, trimEnd, trimStart, uncapitalize, uuidRegex };
|
|
@@ -2,7 +2,7 @@ import { Includes } from './includes';
|
|
|
2
2
|
import { IsKeyPattern } from './isKeyPattern';
|
|
3
3
|
import type * as DCommon from '../../common';
|
|
4
4
|
import type * as DTuple from '../../tuple';
|
|
5
|
-
type _Split<GenericString extends string, GenericSeparator extends string, GenericLimit extends number = number, GenericLastResult extends readonly string[] = []> = GenericString extends `${infer InferredBefore}${GenericSeparator}${infer InferredAfter}` ? IsKeyPattern<InferredBefore> extends true ? GenericLastResult : readonly [...GenericLastResult, InferredBefore] extends infer InferredResult extends readonly any[] ? DCommon.IsEqual<InferredAfter, ""> extends true ? InferredResult : DCommon.IsEqual<InferredResult["length"], 250> extends true ? Includes<InferredAfter, GenericSeparator> extends true ? readonly [...InferredResult, ...string[]] : InferredResult : DCommon.IsEqual<InferredResult["length"], GenericLimit> extends true ? InferredResult : _Split<InferredAfter, GenericSeparator, GenericLimit, InferredResult> : never : readonly [...GenericLastResult, GenericString];
|
|
5
|
+
type _Split<GenericString extends string, GenericSeparator extends string, GenericLimit extends number = number, GenericLastResult extends readonly string[] = []> = GenericString extends `${infer InferredBefore}${GenericSeparator}${infer InferredAfter}` ? IsKeyPattern<InferredBefore> extends true ? GenericLastResult : readonly [...GenericLastResult, InferredBefore] extends infer InferredResult extends readonly any[] ? DCommon.IsEqual<InferredAfter, ""> extends true ? DCommon.IsEqual<GenericSeparator, ""> extends true ? InferredResult : readonly [...InferredResult, InferredAfter] : DCommon.IsEqual<InferredResult["length"], 250> extends true ? Includes<InferredAfter, GenericSeparator> extends true ? readonly [...InferredResult, ...string[]] : InferredResult : DCommon.IsEqual<InferredResult["length"], GenericLimit> extends true ? InferredResult : _Split<InferredAfter, GenericSeparator, GenericLimit, InferredResult> : never : readonly [...GenericLastResult, GenericString];
|
|
6
6
|
export type Split<GenericString extends string, GenericSeparator extends string, GenericLimit extends number = number> = DCommon.IsEqual<GenericLimit, 0> extends true ? readonly [] : IsKeyPattern<GenericSeparator> extends true ? readonly [string, ...string[]] : IsKeyPattern<GenericString> extends true ? readonly [
|
|
7
7
|
...DTuple.Create<string, DTuple.CountMinElement<_Split<GenericString, GenericSeparator, GenericLimit>>>,
|
|
8
8
|
...string[]
|
package/package.json
CHANGED
package/dist/array/infer.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { MaxElements, MinElements, LengthEqual, ComputeMaxElementsCompatibility, ComputeMinElementsCompatibility, ComputeLengthEqualCompatibility } from './constraints';
|
|
2
|
-
import type * as DCommon from '../common';
|
|
3
|
-
import type * as DTuple from '../tuple';
|
|
4
|
-
type ComputeCompatibilityOutputConstraint<GenericOutput extends readonly unknown[], GenericInput extends readonly unknown[]> = (DCommon.Or<[
|
|
5
|
-
DCommon.IsNever<GenericOutput>,
|
|
6
|
-
DCommon.IsNever<GenericInput>
|
|
7
|
-
]> extends true ? unknown : GenericOutput extends unknown ? ((ComputeMaxElementsCompatibility<GenericInput, GenericOutput, unknown> extends infer InferredResult extends DCommon.CompatibilityConstraintResult<boolean, number, number> ? InferredResult extends DCommon.CompatibilityConstraintResult<true> ? MaxElements<InferredResult["to"]> : DCommon.ComputedTypeError<`Impossible to cast on MaxElements<${InferredResult["to"]}> because constraint MaxElements<${InferredResult["from"]}> from the value is more than.`> : never) | (ComputeMinElementsCompatibility<GenericInput, GenericOutput, unknown> extends infer InferredResult extends DCommon.CompatibilityConstraintResult<boolean, number, number> ? InferredResult extends DCommon.CompatibilityConstraintResult<true> ? MinElements<InferredResult["to"]> : DCommon.ComputedTypeError<`Impossible to cast on MinElements<${InferredResult["to"]}> because constraint MinElements<${InferredResult["from"]}> from the value is less than.`> : never) | (ComputeLengthEqualCompatibility<GenericInput, GenericOutput, unknown> extends infer InferredResult extends DCommon.CompatibilityConstraintResult<boolean, number, number> ? InferredResult extends DCommon.CompatibilityConstraintResult<true> ? LengthEqual<InferredResult["to"]> : DCommon.ComputedTypeError<`Impossible to cast on LengthEqual<${InferredResult["to"]}> because constraint LengthEqual<${InferredResult["from"]}> from the value is not equal.`> : never)) extends infer InferredResult ? DCommon.ContainExtends<InferredResult, DCommon.ComputedTypeError<string>> extends true ? Extract<InferredResult, DCommon.ComputedTypeError<string>> : DCommon.UnionToIntersection<InferredResult> : never : never) extends infer InferredResult ? DCommon.ContainExtends<InferredResult, DCommon.BaseConstraint> extends true ? Extract<InferredResult, DCommon.BaseConstraint> : InferredResult : never;
|
|
8
|
-
export declare function infer<GenericOutput extends readonly unknown[], const GenericInput extends readonly [
|
|
9
|
-
...Extract<DCommon.RemoveConstraint<GenericOutput>, readonly unknown[]>
|
|
10
|
-
] = never, GenericConstraint = ComputeCompatibilityOutputConstraint<GenericOutput, GenericInput>>(input: (GenericInput & DTuple.Require<GenericInput> & DCommon.ForbiddenUnion<GenericInput> & DCommon.BreakGenericLink<DCommon.ContainExtends<GenericConstraint, DCommon.ComputedTypeError<string>> extends true ? GenericConstraint : unknown>)): DCommon.Or<[
|
|
11
|
-
DCommon.IsNever<GenericInput>,
|
|
12
|
-
DCommon.ContainExtends<GenericConstraint, DCommon.ComputedTypeError<string>>
|
|
13
|
-
]> extends true ? GenericOutput : DCommon.BreakGenericLink<GenericInput & GenericConstraint>;
|
|
14
|
-
export {};
|
package/dist/array/infer.mjs
DELETED
package/dist/number/infer.cjs
DELETED
package/dist/number/infer.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { ComputeGreaterThanCompatibility, ComputeGreaterThanOrEqualCompatibility, ComputeLessThanCompatibility, ComputeLessThanOrEqualCompatibility, GreaterThan, GreaterThanOrEqual, Integer, LessThan, LessThanOrEqual, NotZero, Safe } from './constraints';
|
|
2
|
-
import { IsZero, IsInteger, RequireLiteral, IsSafe } from './types';
|
|
3
|
-
import type * as DCommon from '../common';
|
|
4
|
-
type ComputeOutputBranchConstraint<GenericOutput extends number, GenericInput extends number> = (DCommon.Or<[
|
|
5
|
-
DCommon.IsNever<GenericOutput>,
|
|
6
|
-
DCommon.IsNever<GenericInput>
|
|
7
|
-
]> extends true ? unknown : GenericOutput extends unknown ? ((ComputeGreaterThanCompatibility<GenericInput, GenericOutput, unknown> extends infer InferredResult extends DCommon.CompatibilityConstraintResult<boolean, number, number> ? InferredResult extends DCommon.CompatibilityConstraintResult<true> ? GreaterThan<InferredResult["to"]> : DCommon.ComputedTypeError<`Impossible to cast on GreaterThan<${InferredResult["to"]}> because value ${InferredResult["from"]} is less than or equal.`> : never) | (ComputeGreaterThanOrEqualCompatibility<GenericInput, GenericOutput, unknown> extends infer InferredResult extends DCommon.CompatibilityConstraintResult<boolean, number, number> ? InferredResult extends DCommon.CompatibilityConstraintResult<true> ? GreaterThanOrEqual<InferredResult["to"]> : DCommon.ComputedTypeError<`Impossible to cast on GreaterThanOrEqual<${InferredResult["to"]}> because value ${InferredResult["from"]} is less than.`> : never) | (ComputeLessThanCompatibility<GenericInput, GenericOutput, unknown> extends infer InferredResult extends DCommon.CompatibilityConstraintResult<boolean, number, number> ? InferredResult extends DCommon.CompatibilityConstraintResult<true> ? LessThan<InferredResult["to"]> : DCommon.ComputedTypeError<`Impossible to cast on LessThan<${InferredResult["to"]}> because value ${InferredResult["from"]} is greater than or equal.`> : never) | (ComputeLessThanOrEqualCompatibility<GenericInput, GenericOutput, unknown> extends infer InferredResult extends DCommon.CompatibilityConstraintResult<boolean, number, number> ? InferredResult extends DCommon.CompatibilityConstraintResult<true> ? LessThanOrEqual<InferredResult["to"]> : DCommon.ComputedTypeError<`Impossible to cast on LessThanOrEqual<${InferredResult["to"]}> because value ${InferredResult["from"]} is greater than.`> : never) | (DCommon.IsExtends<GenericOutput, Integer> extends true ? IsInteger<GenericInput> extends true ? Integer : DCommon.ComputedTypeError<`Impossible to cast on Integer because value ${GenericInput} is not an integer.`> : never) | (DCommon.IsExtends<GenericOutput, NotZero> extends true ? IsZero<GenericInput> extends true ? DCommon.ComputedTypeError<"Impossible to cast on NotZero because value is equal to zero."> : NotZero : never) | (DCommon.IsExtends<GenericOutput, Safe> extends true ? IsSafe<GenericInput> extends true ? Safe : DCommon.ComputedTypeError<`Impossible to cast on Safe because value ${GenericInput} is not safe.`> : never)) extends infer InferredResult ? DCommon.ContainExtends<InferredResult, DCommon.ComputedTypeError<string>> extends true ? Extract<InferredResult, DCommon.ComputedTypeError<string>> : DCommon.UnionToIntersection<InferredResult> : never : never) extends infer InferredResult ? DCommon.ContainExtends<InferredResult, DCommon.BaseConstraint> extends true ? Extract<InferredResult, DCommon.BaseConstraint> : InferredResult : never;
|
|
8
|
-
export declare function infer<GenericOutput extends number, const GenericInput extends Extract<DCommon.RemoveConstraint<GenericOutput>, number> = never, GenericConstraint = ComputeOutputBranchConstraint<GenericOutput, GenericInput>>(input: (GenericInput & RequireLiteral<GenericInput> & DCommon.ForbiddenUnion<GenericInput> & DCommon.BreakGenericLink<DCommon.ContainExtends<GenericConstraint, DCommon.ComputedTypeError<string>> extends true ? GenericConstraint : unknown>)): DCommon.Or<[
|
|
9
|
-
DCommon.IsNever<GenericInput>,
|
|
10
|
-
DCommon.ContainExtends<GenericConstraint, DCommon.ComputedTypeError<string>>
|
|
11
|
-
]> extends true ? GenericOutput : DCommon.BreakGenericLink<GenericInput & GenericConstraint>;
|
|
12
|
-
export {};
|
package/dist/number/infer.mjs
DELETED
package/dist/path/fix.cjs
DELETED
package/dist/path/fix.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function fix<GenericPath extends string>(path: GenericPath): string;
|
package/dist/path/fix.mjs
DELETED
package/dist/string/infer.cjs
DELETED
package/dist/string/infer.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { MaxCharacters, MinCharacters, LengthEqual, ComputeMaxCharactersCompatibility, ComputeMinCharactersCompatibility, ComputeLengthEqualCompatibility } from './constraints';
|
|
2
|
-
import { RequireLiteral } from './types';
|
|
3
|
-
import type * as DCommon from '../common';
|
|
4
|
-
type ComputeCompatibilityOutputConstraint<GenericOutput extends string, GenericInput extends string> = (DCommon.Or<[
|
|
5
|
-
DCommon.IsNever<GenericOutput>,
|
|
6
|
-
DCommon.IsNever<GenericInput>
|
|
7
|
-
]> extends true ? unknown : GenericOutput extends unknown ? ((ComputeMaxCharactersCompatibility<GenericInput, GenericOutput, unknown> extends infer InferredResult extends DCommon.CompatibilityConstraintResult<boolean, number, number> ? InferredResult extends DCommon.CompatibilityConstraintResult<true> ? MaxCharacters<InferredResult["to"]> : DCommon.ComputedTypeError<`Impossible to cast on MaxCharacters<${InferredResult["to"]}> because constraint MaxCharacters<${InferredResult["from"]}> from the value is more than.`> : never) | (ComputeMinCharactersCompatibility<GenericInput, GenericOutput, unknown> extends infer InferredResult extends DCommon.CompatibilityConstraintResult<boolean, number, number> ? InferredResult extends DCommon.CompatibilityConstraintResult<true> ? MinCharacters<InferredResult["to"]> : DCommon.ComputedTypeError<`Impossible to cast on MinCharacters<${InferredResult["to"]}> because constraint MinCharacters<${InferredResult["from"]}> from the value is less than.`> : never) | (ComputeLengthEqualCompatibility<GenericInput, GenericOutput, unknown> extends infer InferredResult extends DCommon.CompatibilityConstraintResult<boolean, number, number> ? InferredResult extends DCommon.CompatibilityConstraintResult<true> ? LengthEqual<InferredResult["to"]> : DCommon.ComputedTypeError<`Impossible to cast on LengthEqual<${InferredResult["to"]}> because constraint LengthEqual<${InferredResult["from"]}> from the value is not equal.`> : never)) extends infer InferredResult ? DCommon.ContainExtends<InferredResult, DCommon.ComputedTypeError<string>> extends true ? Extract<InferredResult, DCommon.ComputedTypeError<string>> : DCommon.UnionToIntersection<InferredResult> : never : never) extends infer InferredResult ? DCommon.ContainExtends<InferredResult, DCommon.BaseConstraint> extends true ? Extract<InferredResult, DCommon.BaseConstraint> : InferredResult : never;
|
|
8
|
-
export declare function infer<GenericOutput extends string, const GenericInput extends Extract<DCommon.RemoveConstraint<GenericOutput>, string> = never, GenericConstraint = ComputeCompatibilityOutputConstraint<GenericOutput, GenericInput>>(input: (GenericInput & RequireLiteral<GenericInput> & DCommon.ForbiddenUnion<GenericInput> & DCommon.BreakGenericLink<DCommon.ContainExtends<GenericConstraint, DCommon.ComputedTypeError<string>> extends true ? GenericConstraint : unknown>)): DCommon.Or<[
|
|
9
|
-
DCommon.IsNever<GenericInput>,
|
|
10
|
-
DCommon.ContainExtends<GenericConstraint, DCommon.ComputedTypeError<string>>
|
|
11
|
-
]> extends true ? GenericOutput : DCommon.BreakGenericLink<GenericInput & GenericConstraint>;
|
|
12
|
-
export {};
|