@zinaid/str 0.0.1

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.
@@ -0,0 +1,4 @@
1
+ export declare function trim(value: string, charlist?: string | null): string;
2
+ export declare function ltrim(value: string, charlist?: string | null): string;
3
+ export declare function rtrim(value: string, charlist?: string | null): string;
4
+ //# sourceMappingURL=trimmer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trimmer.d.ts","sourceRoot":"","sources":["../src/trimmer.ts"],"names":[],"mappings":"AAiDA,wBAAgB,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAM,GAAG,IAAW,GAAG,MAAM,CA0B1E;AAED,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAM,GAAG,IAAW,GAAG,MAAM,CAqB3E;AAED,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAM,GAAG,IAAW,GAAG,MAAM,CAyB3E"}
@@ -0,0 +1,128 @@
1
+ const f = [
2
+ 9,
3
+ 32,
4
+ 160,
5
+ 173,
6
+ 847,
7
+ 1564,
8
+ 4447,
9
+ 4448,
10
+ 6068,
11
+ 6069,
12
+ 6158,
13
+ 8192,
14
+ 8193,
15
+ 8194,
16
+ 8195,
17
+ 8196,
18
+ 8197,
19
+ 8198,
20
+ 8199,
21
+ 8200,
22
+ 8201,
23
+ 8202,
24
+ 8203,
25
+ 8204,
26
+ 8205,
27
+ 8206,
28
+ 8207,
29
+ 8239,
30
+ 8287,
31
+ 8288,
32
+ 8289,
33
+ 8290,
34
+ 8291,
35
+ 8292,
36
+ 8293,
37
+ 8298,
38
+ 8299,
39
+ 8300,
40
+ 8301,
41
+ 8302,
42
+ 8303,
43
+ 12288,
44
+ 10240,
45
+ 12644,
46
+ 65279,
47
+ 65440,
48
+ 119129,
49
+ 119155,
50
+ 119156,
51
+ 119157,
52
+ 119158,
53
+ 119159,
54
+ 119160,
55
+ 119161,
56
+ 119162,
57
+ 917536
58
+ ].map((n) => `\\u{${n.toString(16)}}`).join("");
59
+ function a() {
60
+ return `\\s${f}\\u0000`;
61
+ }
62
+ function u(t) {
63
+ return t.replace(/[-\\^$*+?.()|[\]{}]/g, "\\$&");
64
+ }
65
+ function $(t) {
66
+ let n = 0;
67
+ const r = t.split(/\r?\n/);
68
+ for (const c of r) {
69
+ if (!/\S/.test(c))
70
+ continue;
71
+ n = c.match(/^[ \t]*/)[0].length;
72
+ break;
73
+ }
74
+ const e = r[r.length - 1].match(/^[ \t]*/)[0].length;
75
+ return { baseIndent: n, tailIndent: e };
76
+ }
77
+ function m(t, n = null) {
78
+ if (n == null || n === "") {
79
+ const { baseIndent: i, tailIndent: l } = $(t), e = a(), c = new RegExp(`^[${e}]+|[${e}]+$`, "gu");
80
+ let s = t.replace(c, "");
81
+ const p = Math.max(0, i - l);
82
+ if (p > 0 && s.includes(`
83
+ `)) {
84
+ const g = " ".repeat(p);
85
+ s = s.split(/\r?\n/).map((o, d) => d === 0 || /^\s*$/.test(o) ? o : g + o).join(`
86
+ `);
87
+ }
88
+ return s.length !== t.length ? s : t.trim();
89
+ }
90
+ const r = new RegExp(
91
+ `^[${u(n)}]+|[${u(n)}]+$`,
92
+ "gu"
93
+ );
94
+ return t.replace(r, "");
95
+ }
96
+ function x(t, n = null) {
97
+ if (n == null || n === "") {
98
+ const i = a(), l = new RegExp(`^[${i}]+`, "gu");
99
+ let e = t.replace(l, "");
100
+ const c = String.raw` (?:\n|\r|\t|\v|\x00)$`;
101
+ return e = e.replace(new RegExp(c, "u"), ""), t.endsWith(" ") && !t.endsWith(" ") && (e = e.replace(/ {2}$/u, "")), e.length !== t.length ? e : t.trimStart();
102
+ }
103
+ const r = new RegExp(`^[${u(n)}]+`, "gu");
104
+ return t.replace(r, "");
105
+ }
106
+ function h(t, n = null) {
107
+ if (n == null || n === "") {
108
+ const i = a(), l = new RegExp(`[${i}]+$`, "gu");
109
+ let e = t.replace(l, "");
110
+ if (e.includes(`
111
+ `)) {
112
+ const { baseIndent: c, tailIndent: s } = $(t), p = Math.max(0, s - c);
113
+ if (p > 0) {
114
+ const g = " ".repeat(p);
115
+ e = e.split(/\r?\n/).map((o) => /\S/.test(o) ? g + o : o).join(`
116
+ `);
117
+ }
118
+ }
119
+ return e.length !== t.length ? e : t.trimEnd();
120
+ }
121
+ const r = new RegExp(`[${u(n)}]+$`, "gu");
122
+ return t.replace(r, "");
123
+ }
124
+ export {
125
+ x as ltrim,
126
+ h as rtrim,
127
+ m as trim
128
+ };
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@zinaid/str",
3
+ "version": "0.0.1",
4
+ "description": "Utilities for working with strings similar to Laravel's Str & Stringable classes.",
5
+ "main": "dist/index.js",
6
+ "type": "module",
7
+ "keywords": [],
8
+ "author": "",
9
+ "license": "MIT",
10
+ "dependencies": {
11
+ "@types/markdown-it": "^14.1.2",
12
+ "@types/pluralize": "^0.0.33",
13
+ "any-ascii": "^0.3.3",
14
+ "markdown-it": "^14.1.0",
15
+ "markdown-it-anchor": "^9.2.0",
16
+ "markdown-it-task-lists": "^2.1.1",
17
+ "pluralize": "^8.0.0",
18
+ "transliteration": "^2.3.5",
19
+ "ulid": "^2.4.0",
20
+ "uuid": "^11.1.0",
21
+ "@zinaid/utils": "^0.0.1",
22
+ "@zinaid/num": "^0.0.1"
23
+ },
24
+ "files": [
25
+ "dist"
26
+ ],
27
+ "scripts": {
28
+ "build": "vite build"
29
+ },
30
+ "types": "dist/index.d.ts",
31
+ "exports": {
32
+ ".": {
33
+ "import": "./dist/index.js",
34
+ "require": "./dist/index.js",
35
+ "types": "./dist/index.d.ts"
36
+ },
37
+ "./*": {
38
+ "import": "./dist/*.js",
39
+ "require": "./dist/*.js",
40
+ "types": "./dist/*.d.ts"
41
+ }
42
+ }
43
+ }