@zinaid/str 0.0.5 → 0.0.7
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/ascii/index.d.ts +14 -0
- package/dist/ascii/index.d.ts.map +1 -0
- package/dist/ascii/index.js +7 -0
- package/dist/base64/index.d.ts +23 -0
- package/dist/base64/index.d.ts.map +1 -0
- package/dist/base64/index.js +124 -0
- package/dist/{convertcase.d.ts → convertcase/index.d.ts} +11 -1
- package/dist/convertcase/index.d.ts.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +136 -131
- package/dist/markdown/index.d.ts +49 -0
- package/dist/markdown/index.d.ts.map +1 -0
- package/dist/markdown/index.js +32 -0
- package/dist/pluralizer/index.d.ts +100 -0
- package/dist/pluralizer/index.d.ts.map +1 -0
- package/dist/{pluralizer.js → pluralizer/index.js} +39 -32
- package/dist/{random.d.ts → random/index.d.ts} +3 -3
- package/dist/random/index.d.ts.map +1 -0
- package/dist/{random.js → random/index.js} +2 -1
- package/dist/replacer/index.d.ts +31 -0
- package/dist/replacer/index.d.ts.map +1 -0
- package/dist/str.d.ts +308 -173
- package/dist/str.d.ts.map +1 -1
- package/dist/str.js +510 -661
- package/dist/stringable/index.d.ts +952 -0
- package/dist/stringable/index.d.ts.map +1 -0
- package/dist/{stringable.js → stringable/index.js} +400 -13
- package/dist/transliterate/index.d.ts +14 -0
- package/dist/transliterate/index.d.ts.map +1 -0
- package/dist/transliterate/index.js +7 -0
- package/dist/trimmer/index.d.ts +25 -0
- package/dist/trimmer/index.d.ts.map +1 -0
- package/dist/ulid/index.d.ts +79 -0
- package/dist/ulid/index.d.ts.map +1 -0
- package/dist/ulid/index.js +58 -0
- package/dist/uuid/index.d.ts +92 -0
- package/dist/uuid/index.d.ts.map +1 -0
- package/dist/uuid/index.js +50 -0
- package/package.json +78 -21
- package/dist/base64.d.ts +0 -7
- package/dist/base64.d.ts.map +0 -1
- package/dist/base64.js +0 -123
- package/dist/convertcase.d.ts.map +0 -1
- package/dist/markdown.d.ts +0 -26
- package/dist/markdown.d.ts.map +0 -1
- package/dist/markdown.js +0 -55
- package/dist/pluralizer.d.ts +0 -38
- package/dist/pluralizer.d.ts.map +0 -1
- package/dist/random.d.ts.map +0 -1
- package/dist/replacer.d.ts +0 -31
- package/dist/replacer.d.ts.map +0 -1
- package/dist/stringable.d.ts +0 -555
- package/dist/stringable.d.ts.map +0 -1
- package/dist/trimmer.d.ts +0 -4
- package/dist/trimmer.d.ts.map +0 -1
- /package/dist/{convertcase.js → convertcase/index.js} +0 -0
- /package/dist/{replacer.js → replacer/index.js} +0 -0
- /package/dist/{trimmer.js → trimmer/index.js} +0 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transliterate a string to its closest ASCII representation.
|
|
3
|
+
*
|
|
4
|
+
* @param value The value to transliterate.
|
|
5
|
+
* @return The transliterated ASCII string.
|
|
6
|
+
*
|
|
7
|
+
* @requires {@link https://www.npmjs.com/package/any-ascii any-ascii package}
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
*
|
|
11
|
+
* transliterate('ⓣⓔⓢⓣ@ⓛⓐⓡⓐⓥⓔⓛ.ⓒⓞⓜ'); -> 'test@laravel.com'
|
|
12
|
+
*/
|
|
13
|
+
export declare function transliterate(value: string): string;
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/transliterate/index.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEnD"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Remove all whitespace from both ends of a string.
|
|
3
|
+
*
|
|
4
|
+
* @param value - The string to trim.
|
|
5
|
+
* @param charlist - Optional list of characters to trim instead of whitespace.
|
|
6
|
+
* @returns The trimmed string.
|
|
7
|
+
*/
|
|
8
|
+
export declare function trim(value: string, charlist?: string | null): string;
|
|
9
|
+
/**
|
|
10
|
+
* Remove all whitespace from the beginning of a string.
|
|
11
|
+
*
|
|
12
|
+
* @param value - The string to trim.
|
|
13
|
+
* @param charlist - Optional list of characters to trim instead of whitespace.
|
|
14
|
+
* @returns The left-trimmed string.
|
|
15
|
+
*/
|
|
16
|
+
export declare function ltrim(value: string, charlist?: string | null): string;
|
|
17
|
+
/**
|
|
18
|
+
* Remove all whitespace from the end of a string.
|
|
19
|
+
*
|
|
20
|
+
* @param value - The string to trim.
|
|
21
|
+
* @param charlist - Optional list of characters to trim instead of whitespace.
|
|
22
|
+
* @returns The right-trimmed string.
|
|
23
|
+
*/
|
|
24
|
+
export declare function rtrim(value: string, charlist?: string | null): string;
|
|
25
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/trimmer/index.ts"],"names":[],"mappings":"AAkEA;;;;;;GAMG;AACH,wBAAgB,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAM,GAAG,IAAW,GAAG,MAAM,CA0B1E;AAED;;;;;;GAMG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAM,GAAG,IAAW,GAAG,MAAM,CAqB3E;AAED;;;;;;GAMG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAM,GAAG,IAAW,GAAG,MAAM,CAyB3E"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generate a ULID.
|
|
3
|
+
*
|
|
4
|
+
* @param time - Optional time component as a Date or number of milliseconds since epoch.
|
|
5
|
+
* @returns The generated ULID string.
|
|
6
|
+
*
|
|
7
|
+
* @requires {@link https://www.npmjs.com/package/ulid ulid package}
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
*
|
|
11
|
+
* ulid(); -> "01F8MECHZX2D7J8F8C8D4B8F8C"
|
|
12
|
+
*/
|
|
13
|
+
export declare function ulid(time?: Date | number | null): string;
|
|
14
|
+
/**
|
|
15
|
+
* Indicate that ULIDs should be created normally and not using a custom factory.
|
|
16
|
+
*
|
|
17
|
+
* @returns void.
|
|
18
|
+
*
|
|
19
|
+
* @requires {@link https://www.npmjs.com/package/ulid ulid package}
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
*
|
|
23
|
+
* createUlidsNormally();
|
|
24
|
+
*/
|
|
25
|
+
export declare function createUlidsNormally(): void;
|
|
26
|
+
/**
|
|
27
|
+
* Set the callable that will be used to generate ULIDs.
|
|
28
|
+
*
|
|
29
|
+
* @param factory - The callable ULID factory.
|
|
30
|
+
* @returns void.
|
|
31
|
+
*
|
|
32
|
+
* @requires {@link https://www.npmjs.com/package/ulid ulid package}
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
*
|
|
36
|
+
* createUlidsUsing(() => of("1234").toString());
|
|
37
|
+
*/
|
|
38
|
+
export declare function createUlidsUsing(factory?: (() => string) | null): void;
|
|
39
|
+
/**
|
|
40
|
+
* Set the sequence that will be used to generate ULIDs.
|
|
41
|
+
*
|
|
42
|
+
* @param sequence - The sequence of ULID strings to return.
|
|
43
|
+
* @param whenMissing - Optional callable to generate ULIDs when the sequence is exhausted.
|
|
44
|
+
* @returns void.
|
|
45
|
+
*
|
|
46
|
+
* @requires {@link https://www.npmjs.com/package/ulid ulid package}
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
*
|
|
50
|
+
* createUlidsUsingSequence(["ulid1", "ulid2"], () => "custom-ulid");
|
|
51
|
+
*/
|
|
52
|
+
export declare function createUlidsUsingSequence(sequence: string[], whenMissing?: (() => string) | null): void;
|
|
53
|
+
/**
|
|
54
|
+
* Always return the same ULID when generating new ULIDs.
|
|
55
|
+
*
|
|
56
|
+
* @param callback - Optional callable to execute while ULIDs are frozen.
|
|
57
|
+
* @returns The frozen ULID string.
|
|
58
|
+
*
|
|
59
|
+
* @requires {@link https://www.npmjs.com/package/ulid ulid package}
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
*
|
|
63
|
+
* freezeUlids(() => "custom-ulid");
|
|
64
|
+
*/
|
|
65
|
+
export declare function freezeUlids(callback?: ((value: string) => string) | null): string;
|
|
66
|
+
/**
|
|
67
|
+
* Determine if a given value is a valid ULID.
|
|
68
|
+
*
|
|
69
|
+
* @param value - The value to check.
|
|
70
|
+
* @returns True if the value is a valid ULID, false otherwise.
|
|
71
|
+
*
|
|
72
|
+
* @requires {@link https://www.npmjs.com/package/ulid ulid package}
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
*
|
|
76
|
+
* isUlid("01F8MECHZX2D7J8F8C8D4B8F8C"); -> true
|
|
77
|
+
*/
|
|
78
|
+
export declare function isUlid(value: unknown): boolean;
|
|
79
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ulid/index.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;GAWG;AACH,wBAAgB,IAAI,CAAC,IAAI,GAAE,IAAI,GAAG,MAAM,GAAG,IAAW,GAAG,MAAM,CAwB9D;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,IAAI,IAAI,CAE1C;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,GAAE,CAAC,MAAM,MAAM,CAAC,GAAG,IAAW,GAAG,IAAI,CAE5E;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,wBAAwB,CACpC,QAAQ,EAAE,MAAM,EAAE,EAClB,WAAW,GAAE,CAAC,MAAM,MAAM,CAAC,GAAG,IAAW,GAC1C,IAAI,CAwBN;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,WAAW,CACvB,QAAQ,GAAE,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC,GAAG,IAAW,GACpD,MAAM,CAcR;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAQ9C"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { isString as c } from "@zinaid/utils";
|
|
2
|
+
import { ulid as e } from "ulid";
|
|
3
|
+
let l = null;
|
|
4
|
+
function u(n = null) {
|
|
5
|
+
if (l)
|
|
6
|
+
return l();
|
|
7
|
+
if (n == null)
|
|
8
|
+
return e();
|
|
9
|
+
let t;
|
|
10
|
+
n instanceof Date ? t = n.getTime() : t = n;
|
|
11
|
+
const r = Date.now;
|
|
12
|
+
try {
|
|
13
|
+
return Date.now = () => t, e();
|
|
14
|
+
} finally {
|
|
15
|
+
Date.now = r;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function a() {
|
|
19
|
+
l = null;
|
|
20
|
+
}
|
|
21
|
+
function i(n = null) {
|
|
22
|
+
l = n;
|
|
23
|
+
}
|
|
24
|
+
function U(n, t = null) {
|
|
25
|
+
let r = 0;
|
|
26
|
+
t ??= function() {
|
|
27
|
+
const o = l;
|
|
28
|
+
l = null;
|
|
29
|
+
const f = u();
|
|
30
|
+
return l = o, r++, f;
|
|
31
|
+
}, i(function() {
|
|
32
|
+
return r < n.length ? n[r++] : t();
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
function p(n = null) {
|
|
36
|
+
const t = u();
|
|
37
|
+
if (i(() => t), n !== null)
|
|
38
|
+
try {
|
|
39
|
+
n(t);
|
|
40
|
+
} finally {
|
|
41
|
+
a();
|
|
42
|
+
}
|
|
43
|
+
return t;
|
|
44
|
+
}
|
|
45
|
+
function y(n) {
|
|
46
|
+
if (!c(n))
|
|
47
|
+
return !1;
|
|
48
|
+
const t = n.toUpperCase();
|
|
49
|
+
return /^[0-9A-HJKMNP-TV-Z]{26}$/.test(t);
|
|
50
|
+
}
|
|
51
|
+
export {
|
|
52
|
+
a as createUlidsNormally,
|
|
53
|
+
i as createUlidsUsing,
|
|
54
|
+
U as createUlidsUsingSequence,
|
|
55
|
+
p as freezeUlids,
|
|
56
|
+
y as isUlid,
|
|
57
|
+
u as ulid
|
|
58
|
+
};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generate a UUID (version 4).
|
|
3
|
+
*
|
|
4
|
+
* @return The generated UUID string.
|
|
5
|
+
*
|
|
6
|
+
* @requires {@link https://www.npmjs.com/package/uuid uuid package}
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
*
|
|
10
|
+
* uuid(); -> "550e8400-e29b-41d4-a716-446655440000"
|
|
11
|
+
*/
|
|
12
|
+
export declare function uuid(): string;
|
|
13
|
+
/**
|
|
14
|
+
* Generate a UUID (version 7).
|
|
15
|
+
*
|
|
16
|
+
* @return The generated UUID string.
|
|
17
|
+
*
|
|
18
|
+
* @requires {@link https://www.npmjs.com/package/uuid uuid package}
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
*
|
|
22
|
+
* uuid7(); -> "550e8400-e29b-41d4-a716-446655440000"
|
|
23
|
+
*/
|
|
24
|
+
export declare function uuid7(): string;
|
|
25
|
+
/**
|
|
26
|
+
* Set the callable that will be used to generate UUIDs.
|
|
27
|
+
*
|
|
28
|
+
* @param factory - The callable UUID factory.
|
|
29
|
+
* @returns void.
|
|
30
|
+
*
|
|
31
|
+
* @requires {@link https://www.npmjs.com/package/uuid uuid package}
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
*
|
|
35
|
+
* createUuidsUsing(() => "custom-uuid");
|
|
36
|
+
*/
|
|
37
|
+
export declare function createUuidsUsing(factory?: (() => string) | null): void;
|
|
38
|
+
/**
|
|
39
|
+
* Set the sequence that will be used to generate UUIDs.
|
|
40
|
+
*
|
|
41
|
+
* @param sequence - The sequence of UUID strings to return.
|
|
42
|
+
* @param whenMissing - Optional callable to generate UUIDs when the sequence is exhausted.
|
|
43
|
+
* @returns void.
|
|
44
|
+
*
|
|
45
|
+
* @requires {@link https://www.npmjs.com/package/uuid uuid package}
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
*
|
|
49
|
+
* createUuidsUsingSequence(["uuid1", "uuid2"], () => "custom-uuid");
|
|
50
|
+
*/
|
|
51
|
+
export declare function createUuidsUsingSequence(sequence: string[], whenMissing?: (() => string) | null): void;
|
|
52
|
+
/**
|
|
53
|
+
* Always return the same UUID when generating new UUIDs.
|
|
54
|
+
*
|
|
55
|
+
* @param callback - Optional callable to execute while UUIDs are frozen.
|
|
56
|
+
* @returns The frozen UUID string.
|
|
57
|
+
*
|
|
58
|
+
* @requires {@link https://www.npmjs.com/package/uuid uuid package}
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
*
|
|
62
|
+
* freezeUuids();
|
|
63
|
+
*/
|
|
64
|
+
export declare function freezeUuids(callback?: ((value: string) => string) | null): string;
|
|
65
|
+
/**
|
|
66
|
+
* Indicate that UUIDs should be created normally and not using a custom factory.
|
|
67
|
+
*
|
|
68
|
+
* @return void.
|
|
69
|
+
*
|
|
70
|
+
* @requires {@link https://www.npmjs.com/package/uuid uuid package}
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
*
|
|
74
|
+
* createUuidsNormally();
|
|
75
|
+
*/
|
|
76
|
+
export declare function createUuidsNormally(): void;
|
|
77
|
+
/**
|
|
78
|
+
* Determine if a given value is a valid UUID.
|
|
79
|
+
*
|
|
80
|
+
* @param value - The value to check.
|
|
81
|
+
* @param version - The UUID version to check against (1-8), "nil", "max", or null for any version.
|
|
82
|
+
* @returns True if the value is a valid UUID of the specified version, false otherwise.
|
|
83
|
+
*
|
|
84
|
+
* @requires {@link https://www.npmjs.com/package/uuid uuid package}
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
*
|
|
88
|
+
* isUuid("550e8400-e29b-41d4-a716-446655440000", 4); -> true
|
|
89
|
+
* isUuid("550e8400-e29b-41d4-a716-446655440000", 5); -> false
|
|
90
|
+
*/
|
|
91
|
+
export declare function isUuid(value: string | unknown, version?: number | "nil" | "max" | null): boolean;
|
|
92
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/uuid/index.ts"],"names":[],"mappings":"AAeA;;;;;;;;;;GAUG;AACH,wBAAgB,IAAI,IAAI,MAAM,CAE7B;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,KAAK,IAAI,MAAM,CAE9B;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,GAAE,CAAC,MAAM,MAAM,CAAC,GAAG,IAAW,GAAG,IAAI,CAE5E;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,wBAAwB,CACpC,QAAQ,EAAE,MAAM,EAAE,EAClB,WAAW,GAAE,CAAC,MAAM,MAAM,CAAC,GAAG,IAAW,GAC1C,IAAI,CAwBN;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,WAAW,CACvB,QAAQ,GAAE,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC,GAAG,IAAW,GACpD,MAAM,CAcR;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,IAAI,IAAI,CAE1C;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,MAAM,CAClB,KAAK,EAAE,MAAM,GAAG,OAAO,EACvB,OAAO,GAAE,MAAM,GAAG,KAAK,GAAG,KAAK,GAAG,IAAW,GAC9C,OAAO,CAkCT"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { isString as o } from "@zinaid/utils";
|
|
2
|
+
import { v4 as a, v7 as c, validate as d, NIL as s, MAX as U, version as m } from "uuid";
|
|
3
|
+
let u = null;
|
|
4
|
+
function f() {
|
|
5
|
+
return u ? u() : a();
|
|
6
|
+
}
|
|
7
|
+
function g() {
|
|
8
|
+
return u ? u() : c();
|
|
9
|
+
}
|
|
10
|
+
function e(n = null) {
|
|
11
|
+
u = n;
|
|
12
|
+
}
|
|
13
|
+
function p(n, t = null) {
|
|
14
|
+
let r = 0;
|
|
15
|
+
t ??= function() {
|
|
16
|
+
const i = u;
|
|
17
|
+
u = null;
|
|
18
|
+
const l = f();
|
|
19
|
+
return u = i, r++, l;
|
|
20
|
+
}, e(function() {
|
|
21
|
+
return r < n.length ? n[r++] : t();
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
function x(n = null) {
|
|
25
|
+
const t = f();
|
|
26
|
+
if (e(() => t), n !== null)
|
|
27
|
+
try {
|
|
28
|
+
n(t);
|
|
29
|
+
} finally {
|
|
30
|
+
A();
|
|
31
|
+
}
|
|
32
|
+
return t;
|
|
33
|
+
}
|
|
34
|
+
function A() {
|
|
35
|
+
u = null;
|
|
36
|
+
}
|
|
37
|
+
function C(n, t = null) {
|
|
38
|
+
return !o(n) || t !== null && !d(n) ? !1 : t === null ? /^[\da-fA-F]{8}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{12}$/.test(
|
|
39
|
+
n
|
|
40
|
+
) : t === 0 || t === "nil" ? n.toLowerCase() === s : t === "max" ? n.toLowerCase() === U : t < 1 || t > 8 ? !1 : m(n) === t;
|
|
41
|
+
}
|
|
42
|
+
export {
|
|
43
|
+
A as createUuidsNormally,
|
|
44
|
+
e as createUuidsUsing,
|
|
45
|
+
p as createUuidsUsingSequence,
|
|
46
|
+
x as freezeUuids,
|
|
47
|
+
C as isUuid,
|
|
48
|
+
f as uuid,
|
|
49
|
+
g as uuid7
|
|
50
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zinaid/str",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"description": "Utilities for working with strings similar to Laravel's Str & Stringable classes.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -9,14 +9,24 @@
|
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"sideEffects": false,
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@zinaid/
|
|
13
|
-
"@zinaid/
|
|
12
|
+
"@zinaid/num": "^0.0.8",
|
|
13
|
+
"@zinaid/utils": "^0.0.5"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"@types/markdown-it": "^14.1.2",
|
|
17
|
-
"@types/pluralize": "^0.0.33"
|
|
17
|
+
"@types/pluralize": "^0.0.33",
|
|
18
|
+
"any-ascii": "^0.3.3",
|
|
19
|
+
"markdown-it": "^14.1.0",
|
|
20
|
+
"markdown-it-anchor": "^9.2.0",
|
|
21
|
+
"markdown-it-task-lists": "^2.1.1",
|
|
22
|
+
"pluralize": "^8.0.0",
|
|
23
|
+
"transliteration": "^2.3.5",
|
|
24
|
+
"ulid": "^2.4.0",
|
|
25
|
+
"uuid": "^11.1.0"
|
|
18
26
|
},
|
|
19
|
-
"
|
|
27
|
+
"peerDependencies": {
|
|
28
|
+
"@types/markdown-it": "^14.1.2",
|
|
29
|
+
"@types/pluralize": "^0.0.33",
|
|
20
30
|
"any-ascii": "^0.3.3",
|
|
21
31
|
"markdown-it": "^14.1.0",
|
|
22
32
|
"markdown-it-anchor": "^9.2.0",
|
|
@@ -26,6 +36,32 @@
|
|
|
26
36
|
"ulid": "^2.4.0",
|
|
27
37
|
"uuid": "^11.1.0"
|
|
28
38
|
},
|
|
39
|
+
"peerDependenciesMeta": {
|
|
40
|
+
"markdown-it": {
|
|
41
|
+
"optional": true
|
|
42
|
+
},
|
|
43
|
+
"markdown-it-anchor": {
|
|
44
|
+
"optional": true
|
|
45
|
+
},
|
|
46
|
+
"markdown-it-task-lists": {
|
|
47
|
+
"optional": true
|
|
48
|
+
},
|
|
49
|
+
"pluralize": {
|
|
50
|
+
"optional": true
|
|
51
|
+
},
|
|
52
|
+
"any-ascii": {
|
|
53
|
+
"optional": true
|
|
54
|
+
},
|
|
55
|
+
"transliteration": {
|
|
56
|
+
"optional": true
|
|
57
|
+
},
|
|
58
|
+
"ulid": {
|
|
59
|
+
"optional": true
|
|
60
|
+
},
|
|
61
|
+
"uuid": {
|
|
62
|
+
"optional": true
|
|
63
|
+
}
|
|
64
|
+
},
|
|
29
65
|
"files": [
|
|
30
66
|
"dist"
|
|
31
67
|
],
|
|
@@ -39,41 +75,62 @@
|
|
|
39
75
|
"require": "./dist/index.js",
|
|
40
76
|
"types": "./dist/index.d.ts"
|
|
41
77
|
},
|
|
78
|
+
"./*": {
|
|
79
|
+
"import": "./dist/*",
|
|
80
|
+
"require": "./dist/*",
|
|
81
|
+
"types": "./dist/*"
|
|
82
|
+
},
|
|
83
|
+
"./ascii": {
|
|
84
|
+
"import": "./dist/ascii/index.js",
|
|
85
|
+
"types": "./dist/ascii/index.d.ts"
|
|
86
|
+
},
|
|
42
87
|
"./base64": {
|
|
43
|
-
"import": "./dist/base64.js",
|
|
44
|
-
"types": "./dist/base64.d.ts"
|
|
88
|
+
"import": "./dist/base64/index.js",
|
|
89
|
+
"types": "./dist/base64/index.d.ts"
|
|
45
90
|
},
|
|
46
91
|
"./convertcase": {
|
|
47
|
-
"import": "./dist/convertcase.js",
|
|
48
|
-
"types": "./dist/convertcase.d.ts"
|
|
92
|
+
"import": "./dist/convertcase/index.js",
|
|
93
|
+
"types": "./dist/convertcase/index.d.ts"
|
|
49
94
|
},
|
|
50
95
|
"./markdown": {
|
|
51
|
-
"import": "./dist/markdown.js",
|
|
52
|
-
"types": "./dist/markdown.d.ts"
|
|
96
|
+
"import": "./dist/markdown/index.js",
|
|
97
|
+
"types": "./dist/markdown/index.d.ts"
|
|
53
98
|
},
|
|
54
99
|
"./pluralizer": {
|
|
55
|
-
"import": "./dist/pluralizer.js",
|
|
56
|
-
"types": "./dist/pluralizer.d.ts"
|
|
100
|
+
"import": "./dist/pluralizer/index.js",
|
|
101
|
+
"types": "./dist/pluralizer/index.d.ts"
|
|
57
102
|
},
|
|
58
103
|
"./random": {
|
|
59
|
-
"import": "./dist/random.js",
|
|
60
|
-
"types": "./dist/random.d.ts"
|
|
104
|
+
"import": "./dist/random/index.js",
|
|
105
|
+
"types": "./dist/random/index.d.ts"
|
|
61
106
|
},
|
|
62
107
|
"./replacer": {
|
|
63
|
-
"import": "./dist/replacer.js",
|
|
64
|
-
"types": "./dist/replacer.d.ts"
|
|
108
|
+
"import": "./dist/replacer/index.js",
|
|
109
|
+
"types": "./dist/replacer/index.d.ts"
|
|
65
110
|
},
|
|
66
111
|
"./str": {
|
|
67
112
|
"import": "./dist/str.js",
|
|
68
113
|
"types": "./dist/str.d.ts"
|
|
69
114
|
},
|
|
70
115
|
"./stringable": {
|
|
71
|
-
"import": "./dist/stringable.js",
|
|
72
|
-
"types": "./dist/stringable.d.ts"
|
|
116
|
+
"import": "./dist/stringable/index.js",
|
|
117
|
+
"types": "./dist/stringable/index.d.ts"
|
|
118
|
+
},
|
|
119
|
+
"./transliterate": {
|
|
120
|
+
"import": "./dist/transliterate/index.js",
|
|
121
|
+
"types": "./dist/transliterate/index.d.ts"
|
|
73
122
|
},
|
|
74
123
|
"./trimmer": {
|
|
75
|
-
"import": "./dist/trimmer.js",
|
|
76
|
-
"types": "./dist/trimmer.d.ts"
|
|
124
|
+
"import": "./dist/trimmer/index.js",
|
|
125
|
+
"types": "./dist/trimmer/index.d.ts"
|
|
126
|
+
},
|
|
127
|
+
"./ulid": {
|
|
128
|
+
"import": "./dist/ulid/index.js",
|
|
129
|
+
"types": "./dist/ulid/index.d.ts"
|
|
130
|
+
},
|
|
131
|
+
"./uuid": {
|
|
132
|
+
"import": "./dist/uuid/index.js",
|
|
133
|
+
"types": "./dist/uuid/index.d.ts"
|
|
77
134
|
}
|
|
78
135
|
}
|
|
79
136
|
}
|
package/dist/base64.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export declare function toBase64(value: string): string;
|
|
2
|
-
/**
|
|
3
|
-
* Convert raw bytes to a Base64 string using the same fallbacks as toBase64.
|
|
4
|
-
*/
|
|
5
|
-
export declare function bytesToBase64(bytes: Uint8Array): string;
|
|
6
|
-
export declare function fromBase64(value: string, strict?: boolean): string | false;
|
|
7
|
-
//# sourceMappingURL=base64.d.ts.map
|
package/dist/base64.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"base64.d.ts","sourceRoot":"","sources":["../src/base64.ts"],"names":[],"mappings":"AAAA,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CA+B9C;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAsBvD;AAED,wBAAgB,UAAU,CACtB,KAAK,EAAE,MAAM,EACb,MAAM,GAAE,OAAe,GACxB,MAAM,GAAG,KAAK,CAqEhB"}
|
package/dist/base64.js
DELETED
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
function m(n) {
|
|
2
|
-
const o = l();
|
|
3
|
-
if (o.Buffer && typeof o.Buffer.from == "function")
|
|
4
|
-
return o.Buffer.from(n, "utf8").toString("base64");
|
|
5
|
-
if (typeof o.btoa == "function")
|
|
6
|
-
try {
|
|
7
|
-
const t = g(n);
|
|
8
|
-
return o.btoa(t);
|
|
9
|
-
} catch {
|
|
10
|
-
return o.btoa(n);
|
|
11
|
-
}
|
|
12
|
-
const e = g(n);
|
|
13
|
-
return d(e);
|
|
14
|
-
}
|
|
15
|
-
function B(n) {
|
|
16
|
-
const o = l();
|
|
17
|
-
if (o.Buffer && typeof o.Buffer.from == "function")
|
|
18
|
-
return o.Buffer.from(n).toString("base64");
|
|
19
|
-
let e = "";
|
|
20
|
-
for (let t = 0; t < n.length; t++)
|
|
21
|
-
e += String.fromCharCode(n[t]);
|
|
22
|
-
return typeof o.btoa == "function" ? o.btoa(e) : d(e);
|
|
23
|
-
}
|
|
24
|
-
function y(n, o = !1) {
|
|
25
|
-
const e = l();
|
|
26
|
-
let t = String(n);
|
|
27
|
-
if (o) {
|
|
28
|
-
const c = t.replace(/\s+/g, "");
|
|
29
|
-
if (!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(c))
|
|
30
|
-
return !1;
|
|
31
|
-
t = c;
|
|
32
|
-
} else
|
|
33
|
-
t = t.replace(/[^A-Za-z0-9+/=]/g, "");
|
|
34
|
-
if (e.Buffer && typeof e.Buffer.from == "function")
|
|
35
|
-
try {
|
|
36
|
-
return e.Buffer.from(t, "base64").toString("utf8");
|
|
37
|
-
} catch {
|
|
38
|
-
return !1;
|
|
39
|
-
}
|
|
40
|
-
if (typeof e.atob == "function")
|
|
41
|
-
try {
|
|
42
|
-
const c = e.atob(t);
|
|
43
|
-
if (typeof e.TextDecoder == "function") {
|
|
44
|
-
const f = new Uint8Array(c.length);
|
|
45
|
-
for (let a = 0; a < c.length; a++)
|
|
46
|
-
f[a] = c.charCodeAt(a);
|
|
47
|
-
return new e.TextDecoder("utf-8").decode(f);
|
|
48
|
-
}
|
|
49
|
-
let r = "";
|
|
50
|
-
for (let f = 0; f < c.length; f++)
|
|
51
|
-
r += "%" + c.charCodeAt(f).toString(16).padStart(2, "0");
|
|
52
|
-
return decodeURIComponent(r);
|
|
53
|
-
} catch {
|
|
54
|
-
return !1;
|
|
55
|
-
}
|
|
56
|
-
try {
|
|
57
|
-
const c = A(t);
|
|
58
|
-
return C(c);
|
|
59
|
-
} catch {
|
|
60
|
-
return !1;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
function l() {
|
|
64
|
-
return globalThis;
|
|
65
|
-
}
|
|
66
|
-
function g(n) {
|
|
67
|
-
return encodeURIComponent(n).replace(
|
|
68
|
-
/%([0-9A-F]{2})/g,
|
|
69
|
-
(o, e) => String.fromCharCode(parseInt(e, 16))
|
|
70
|
-
);
|
|
71
|
-
}
|
|
72
|
-
function d(n) {
|
|
73
|
-
const o = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
74
|
-
let e = "";
|
|
75
|
-
for (let t = 0; t < n.length; t += 3) {
|
|
76
|
-
const c = n.charCodeAt(t), r = n.charCodeAt(t + 1), f = n.charCodeAt(t + 2), a = (c ?? 0) << 16 | (r ?? 0) << 8 | (f ?? 0), i = a >> 18 & 63, s = a >> 12 & 63, u = a >> 6 & 63, h = a & 63;
|
|
77
|
-
isNaN(r) ? e += o.charAt(i) + o.charAt(s) + "==" : isNaN(f) ? e += o.charAt(i) + o.charAt(s) + o.charAt(u) + "=" : e += o.charAt(i) + o.charAt(s) + o.charAt(u) + o.charAt(h);
|
|
78
|
-
}
|
|
79
|
-
return e;
|
|
80
|
-
}
|
|
81
|
-
function A(n) {
|
|
82
|
-
const o = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", e = /* @__PURE__ */ new Map();
|
|
83
|
-
for (let r = 0; r < o.length; r++)
|
|
84
|
-
e.set(o[r], r);
|
|
85
|
-
const t = n.replace(/=+$/g, ""), c = [];
|
|
86
|
-
for (let r = 0; r < t.length; r += 4) {
|
|
87
|
-
const f = e.has(t[r]) ? e.get(t[r]) : 64, a = e.has(t[r + 1]) ? e.get(t[r + 1]) : 64, i = e.has(t[r + 2]) ? e.get(t[r + 2]) : 64, s = e.has(t[r + 3]) ? e.get(t[r + 3]) : 64, u = f << 18 | a << 12 | (i & 63) << 6 | s & 63, h = u >> 16 & 255, p = u >> 8 & 255, b = u & 255;
|
|
88
|
-
c.push(h), i !== 64 && c.push(p), s !== 64 && c.push(b);
|
|
89
|
-
}
|
|
90
|
-
return c;
|
|
91
|
-
}
|
|
92
|
-
function C(n) {
|
|
93
|
-
const o = l();
|
|
94
|
-
if (typeof o.TextDecoder == "function")
|
|
95
|
-
return new o.TextDecoder("utf-8").decode(new Uint8Array(n));
|
|
96
|
-
let e = "";
|
|
97
|
-
for (let t = 0; t < n.length; ) {
|
|
98
|
-
const c = n[t++];
|
|
99
|
-
if (c < 128)
|
|
100
|
-
e += String.fromCharCode(c);
|
|
101
|
-
else if (c < 224) {
|
|
102
|
-
const r = n[t++];
|
|
103
|
-
e += String.fromCharCode((c & 31) << 6 | r & 63);
|
|
104
|
-
} else if (c < 240) {
|
|
105
|
-
const r = n[t++], f = n[t++];
|
|
106
|
-
e += String.fromCharCode(
|
|
107
|
-
(c & 15) << 12 | (r & 63) << 6 | f & 63
|
|
108
|
-
);
|
|
109
|
-
} else {
|
|
110
|
-
const r = n[t++], f = n[t++], a = n[t++], s = ((c & 7) << 18 | (r & 63) << 12 | (f & 63) << 6 | a & 63) - 65536;
|
|
111
|
-
e += String.fromCharCode(
|
|
112
|
-
55296 + (s >> 10 & 1023),
|
|
113
|
-
56320 + (s & 1023)
|
|
114
|
-
);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
return e;
|
|
118
|
-
}
|
|
119
|
-
export {
|
|
120
|
-
B as bytesToBase64,
|
|
121
|
-
y as fromBase64,
|
|
122
|
-
m as toBase64
|
|
123
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"convertcase.d.ts","sourceRoot":"","sources":["../src/convertcase.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,SAAS;;;;;;;;;CASZ,CAAC;AAEX,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,SAAS,CAAC,CAAC,MAAM,OAAO,SAAS,CAAC,CAAC;AAEzE;;;;;;GAMG;AACH,wBAAgB,WAAW,CACvB,KAAK,EAAE,MAAM,EACb,IAAI,GAAE,eAAgC,GACvC,MAAM,CAER;AAED;;;;;;;GAOG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE3C;AAED;;;;;;;GAOG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE3C"}
|
package/dist/markdown.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { Options as MarkdownItOptions, PluginSimple, PluginWithOptions, default as __DTS_DEFAULT_0__ } from 'markdown-it';
|
|
2
|
-
export interface MarkDownOptions extends MarkdownItOptions {
|
|
3
|
-
gfm?: boolean;
|
|
4
|
-
anchors?: object | boolean;
|
|
5
|
-
typographer?: boolean;
|
|
6
|
-
}
|
|
7
|
-
export type MarkDownExtension = PluginSimple | PluginWithOptions<unknown> | [PluginWithOptions<unknown>, unknown];
|
|
8
|
-
export type MarkDownExtensions = MarkDownExtension[];
|
|
9
|
-
/**
|
|
10
|
-
* Converts GitHub flavored Markdown into HTML.
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
*
|
|
14
|
-
* markdown('# Hello World'); -> '<h1>Hello World</h1>\n'
|
|
15
|
-
*/
|
|
16
|
-
export declare function markdown(value: string, options?: MarkDownOptions, extensions?: MarkDownExtensions): string;
|
|
17
|
-
/**
|
|
18
|
-
* Converts inline Markdown into HTML.
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
*
|
|
22
|
-
* inlineMarkdown("Hello *World*"); -> "<p>Hello <em>World</em></p>"
|
|
23
|
-
*/
|
|
24
|
-
export declare function inlineMarkdown(value: string, options?: MarkDownOptions, extensions?: MarkDownExtensions): string;
|
|
25
|
-
export declare function markDownRenderer(options?: MarkDownOptions, extensions?: MarkDownExtensions): __DTS_DEFAULT_0__;
|
|
26
|
-
//# sourceMappingURL=markdown.d.ts.map
|
package/dist/markdown.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../src/markdown.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACR,OAAO,IAAI,iBAAiB,EAC5B,YAAY,EACZ,iBAAiB,EACpB,MAAM,aAAa,CAAC;AAErB,MAAM,WAAW,eAAgB,SAAQ,iBAAiB;IACtD,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAC3B,WAAW,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,MAAM,MAAM,iBAAiB,GACvB,YAAY,GACZ,iBAAiB,CAAC,OAAO,CAAC,GAC1B,CAAC,iBAAiB,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC;AAE5C,MAAM,MAAM,kBAAkB,GAAG,iBAAiB,EAAE,CAAC;AAyCrD;;;;;;GAMG;AACH,wBAAgB,QAAQ,CACpB,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,eAA+C,EACxD,UAAU,GAAE,kBAAuB,GACpC,MAAM,CAER;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC1B,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,eAA+B,EACxC,UAAU,GAAE,kBAAuB,GACpC,MAAM,CAER;AAED,wBAAgB,gBAAgB,CAC5B,OAAO,GAAE,eAA+C,EACxD,UAAU,GAAE,kBAAuB,iCAmCtC"}
|