@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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Abraham Arango
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
File without changes
@@ -0,0 +1,7 @@
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
@@ -0,0 +1 @@
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 ADDED
@@ -0,0 +1,123 @@
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
+ };
@@ -0,0 +1,38 @@
1
+ export declare const CaseTypes: {
2
+ readonly upper: "upper";
3
+ readonly lower: "lower";
4
+ readonly title: "title";
5
+ readonly fold: "fold";
6
+ readonly simple: "simple";
7
+ readonly lower_simple: "lower_simple";
8
+ readonly title_simple: "title_simple";
9
+ readonly fold_simple: "fold_simple";
10
+ };
11
+ export type ConvertCaseMode = (typeof CaseTypes)[keyof typeof CaseTypes];
12
+ /**
13
+ * Convert the case of a string.
14
+ *
15
+ * @example
16
+ *
17
+ * convertCase('hello', CaseTypes.upper); -> 'HELLO'
18
+ */
19
+ export declare function convertCase(value: string, mode?: ConvertCaseMode): string;
20
+ /**
21
+ * Convert the given string to upper-case.
22
+ *
23
+ * @example
24
+ *
25
+ * upper("foo bar baz"); -> "FOO BAR BAZ"
26
+ * upper("foO bAr BaZ"); -> "FOO BAR BAZ"
27
+ */
28
+ export declare function upper(value: string): string;
29
+ /**
30
+ * Convert the given string to proper case.
31
+ *
32
+ * @example
33
+ *
34
+ * title("foo bar baz"); -> "Foo Bar Baz"
35
+ * title("foO bAr BaZ"); -> "Foo Bar Baz"
36
+ */
37
+ export declare function title(value: string): string;
38
+ //# sourceMappingURL=convertcase.d.ts.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,49 @@
1
+ import { upperFirst as o, lowerFirst as l, toLower as s, toUpper as n } from "@zinaid/utils";
2
+ const r = {
3
+ upper: "upper",
4
+ lower: "lower",
5
+ title: "title",
6
+ fold: "fold",
7
+ simple: "simple",
8
+ lower_simple: "lower_simple",
9
+ title_simple: "title_simple",
10
+ fold_simple: "fold_simple"
11
+ };
12
+ function a(e, p = r.fold) {
13
+ return i(e, p);
14
+ }
15
+ function m(e) {
16
+ return i(e, r.upper);
17
+ }
18
+ function u(e) {
19
+ return i(e, r.title);
20
+ }
21
+ function i(e, p) {
22
+ switch (p) {
23
+ case r.upper:
24
+ return n(e);
25
+ case r.lower:
26
+ return s(e);
27
+ case r.title:
28
+ return e.replace(
29
+ new RegExp("\\p{L}[\\p{L}\\p{M}\\p{N}]*", "gu"),
30
+ (t) => t.charAt(0).toUpperCase() + t.slice(1).toLowerCase()
31
+ );
32
+ case r.fold:
33
+ return e.normalize("NFKD").toLowerCase();
34
+ case r.simple:
35
+ return e.replace(/[^a-z0-9]+/g, " ").trim();
36
+ case r.lower_simple:
37
+ return l(e).replace(/[^a-z0-9]+/g, " ").trim();
38
+ case r.title_simple:
39
+ return e.split(/[^a-z0-9]+/g).map((t) => o(t)).join(" ");
40
+ case r.fold_simple:
41
+ return e.normalize("NFKD").toLowerCase().replace(/[^a-z0-9]+/g, " ").trim();
42
+ }
43
+ }
44
+ export {
45
+ r as CaseTypes,
46
+ a as convertCase,
47
+ u as title,
48
+ m as upper
49
+ };
@@ -0,0 +1,10 @@
1
+ export * from './base64';
2
+ export * from './convertcase';
3
+ export * from './markdown';
4
+ export * from './pluralizer';
5
+ export * from './random';
6
+ export * from './replacer';
7
+ export * from './str';
8
+ export * from './stringable';
9
+ export * from './trimmer';
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,OAAO,CAAC;AACtB,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,133 @@
1
+ import { bytesToBase64 as a, fromBase64 as t, toBase64 as s } from "./base64.js";
2
+ import { CaseTypes as n, convertCase as o, title as l, upper as c } from "./convertcase.js";
3
+ import { inlineMarkdown as p, markDownRenderer as u, markdown as m } from "./markdown.js";
4
+ import { inflector as h, isPlural as g, isSingular as S, matchCase as U, plural as w, singular as b, uncountable as x } from "./pluralizer.js";
5
+ import { randomInt as k, randomString as y } from "./random.js";
6
+ import { substr as z, substrCount as A, substrReplace as W } from "./replacer.js";
7
+ import { after as B, afterLast as L, apa as v, ascii as E, before as M, beforeLast as N, between as P, betweenFirst as T, camel as F, camelCacheSize as D, charAt as I, chopEnd as J, chopStart as O, contains as j, containsAll as G, createRandomStringsNormally as H, createRandomStringsUsing as K, createRandomStringsUsingSequence as Q, createUlidsNormally as V, createUlidsUsing as X, createUlidsUsingSequence as Y, createUuidsNormally as Z, createUuidsUsing as _, createUuidsUsingSequence as $, deduplicate as ee, doesntContain as re, doesntEndWith as ae, doesntStartWith as te, endsWith as se, excerpt as ie, finish as ne, flushCache as oe, freezeUlids as le, freezeUuids as ce, headline as de, is as pe, isAscii as ue, isJson as me, isMatch as fe, isUlid as he, isUrl as ge, isUuid as Se, kebab as Ue, lcfirst as we, length as be, limit as xe, lower as Ce, makePad as ke, mask as ye, match as Re, matchAll as ze, numbers as Ae, padBoth as We, padLeft as qe, padRight as Be, pascal as Le, password as ve, pluralPascal as Ee, pluralStudly as Me, position as Ne, random as Pe, remove as Te, repeat as Fe, replace as De, replaceArray as Ie, replaceEnd as Je, replaceFirst as Oe, replaceLast as je, replaceMatches as Ge, replaceStart as He, reverse as Ke, slug as Qe, snake as Ve, snakeCacheSize as Xe, squish as Ye, start as Ze, startsWith as _e, stripTags as $e, studly as er, studlyCacheSize as rr, swap as ar, take as tr, toStringOr as sr, transliterate as ir, ucfirst as nr, ucsplit as or, ucwords as lr, ulid as cr, unwrap as dr, uuid as pr, uuid7 as ur, wordCount as mr, wordWrap as fr, words as hr, wrap as gr } from "./str.js";
8
+ import { Stringable as Ur, of as wr } from "./stringable.js";
9
+ import { ltrim as xr, rtrim as Cr, trim as kr } from "./trimmer.js";
10
+ export {
11
+ n as CaseTypes,
12
+ Ur as Stringable,
13
+ B as after,
14
+ L as afterLast,
15
+ v as apa,
16
+ E as ascii,
17
+ M as before,
18
+ N as beforeLast,
19
+ P as between,
20
+ T as betweenFirst,
21
+ a as bytesToBase64,
22
+ F as camel,
23
+ D as camelCacheSize,
24
+ I as charAt,
25
+ J as chopEnd,
26
+ O as chopStart,
27
+ j as contains,
28
+ G as containsAll,
29
+ o as convertCase,
30
+ H as createRandomStringsNormally,
31
+ K as createRandomStringsUsing,
32
+ Q as createRandomStringsUsingSequence,
33
+ V as createUlidsNormally,
34
+ X as createUlidsUsing,
35
+ Y as createUlidsUsingSequence,
36
+ Z as createUuidsNormally,
37
+ _ as createUuidsUsing,
38
+ $ as createUuidsUsingSequence,
39
+ ee as deduplicate,
40
+ re as doesntContain,
41
+ ae as doesntEndWith,
42
+ te as doesntStartWith,
43
+ se as endsWith,
44
+ ie as excerpt,
45
+ ne as finish,
46
+ oe as flushCache,
47
+ le as freezeUlids,
48
+ ce as freezeUuids,
49
+ t as fromBase64,
50
+ de as headline,
51
+ h as inflector,
52
+ p as inlineMarkdown,
53
+ pe as is,
54
+ ue as isAscii,
55
+ me as isJson,
56
+ fe as isMatch,
57
+ g as isPlural,
58
+ S as isSingular,
59
+ he as isUlid,
60
+ ge as isUrl,
61
+ Se as isUuid,
62
+ Ue as kebab,
63
+ we as lcfirst,
64
+ be as length,
65
+ xe as limit,
66
+ Ce as lower,
67
+ xr as ltrim,
68
+ ke as makePad,
69
+ u as markDownRenderer,
70
+ m as markdown,
71
+ ye as mask,
72
+ Re as match,
73
+ ze as matchAll,
74
+ U as matchCase,
75
+ Ae as numbers,
76
+ wr as of,
77
+ We as padBoth,
78
+ qe as padLeft,
79
+ Be as padRight,
80
+ Le as pascal,
81
+ ve as password,
82
+ w as plural,
83
+ Ee as pluralPascal,
84
+ Me as pluralStudly,
85
+ Ne as position,
86
+ Pe as random,
87
+ k as randomInt,
88
+ y as randomString,
89
+ Te as remove,
90
+ Fe as repeat,
91
+ De as replace,
92
+ Ie as replaceArray,
93
+ Je as replaceEnd,
94
+ Oe as replaceFirst,
95
+ je as replaceLast,
96
+ Ge as replaceMatches,
97
+ He as replaceStart,
98
+ Ke as reverse,
99
+ Cr as rtrim,
100
+ b as singular,
101
+ Qe as slug,
102
+ Ve as snake,
103
+ Xe as snakeCacheSize,
104
+ Ye as squish,
105
+ Ze as start,
106
+ _e as startsWith,
107
+ $e as stripTags,
108
+ er as studly,
109
+ rr as studlyCacheSize,
110
+ z as substr,
111
+ A as substrCount,
112
+ W as substrReplace,
113
+ ar as swap,
114
+ tr as take,
115
+ l as title,
116
+ s as toBase64,
117
+ sr as toStringOr,
118
+ ir as transliterate,
119
+ kr as trim,
120
+ nr as ucfirst,
121
+ or as ucsplit,
122
+ lr as ucwords,
123
+ cr as ulid,
124
+ x as uncountable,
125
+ dr as unwrap,
126
+ c as upper,
127
+ pr as uuid,
128
+ ur as uuid7,
129
+ mr as wordCount,
130
+ fr as wordWrap,
131
+ hr as words,
132
+ gr as wrap
133
+ };
@@ -0,0 +1,26 @@
1
+ import { default as MarkdownIt, Options as MarkdownItOptions, PluginSimple, PluginWithOptions } 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): MarkdownIt;
26
+ //# sourceMappingURL=markdown.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../src/markdown.ts"],"names":[],"mappings":"AACA,OAAO,UAAU,EAAE,EACf,KAAK,OAAO,IAAI,iBAAiB,EACjC,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACzB,MAAM,aAAa,CAAC;AAIrB,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;AAErD;;;;;;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,cAgCtC"}
@@ -0,0 +1,32 @@
1
+ import { isArray as d } from "@zinaid/utils";
2
+ import k from "markdown-it";
3
+ import p from "markdown-it-anchor";
4
+ import w from "markdown-it-task-lists";
5
+ function y(r, e = { gfm: !0, anchors: !1 }, t = []) {
6
+ return s(e, t).render(r);
7
+ }
8
+ function A(r, e = { gfm: !0 }, t = []) {
9
+ return s(e, t).renderInline(r);
10
+ }
11
+ function s(r = { gfm: !0, anchors: !1 }, e = []) {
12
+ const {
13
+ html: t = !1,
14
+ linkify: i = !0,
15
+ breaks: u = !0,
16
+ gfm: a = !0,
17
+ anchors: f = !1,
18
+ ...m
19
+ } = r, n = new k({ html: t, linkify: i, breaks: u, ...m });
20
+ a && n.use(w, { label: !0, labelAfter: !0 }), f && n.use(p, typeof f == "object" ? f : {});
21
+ for (const o of e)
22
+ if (d(o)) {
23
+ const [l, c] = o;
24
+ n.use(l, c);
25
+ } else o && n.use(o);
26
+ return n;
27
+ }
28
+ export {
29
+ A as inlineMarkdown,
30
+ s as markDownRenderer,
31
+ y as markdown
32
+ };
@@ -0,0 +1,39 @@
1
+ import { default as pluralize } from 'pluralize';
2
+ export interface PluralizerRules {
3
+ uncountable: string[];
4
+ }
5
+ /**
6
+ * Get the plural form of an English word.
7
+ *
8
+ * @example
9
+ *
10
+ * plural("child"); -> "children"
11
+ * plural("apple", 1); -> "apple"
12
+ * plural("apple", 2, true); -> "2 apples"
13
+ */
14
+ export declare function plural(value: string, count?: number, prependCount?: boolean): string;
15
+ /**
16
+ * Get the singular form of an English word.
17
+ */
18
+ export declare function singular(value: string): string;
19
+ /**
20
+ * Determine if the given value is uncountable.
21
+ */
22
+ export declare function uncountable(value: string): boolean;
23
+ /**
24
+ * Determine if the given value is plural.
25
+ */
26
+ export declare function isPlural(value?: string): boolean;
27
+ /**
28
+ * Determine if the given value is singular.
29
+ */
30
+ export declare function isSingular(value?: string): boolean;
31
+ /**
32
+ * Attempt to match the case on two strings
33
+ */
34
+ export declare function matchCase(value: string, comparison: string): string;
35
+ /**
36
+ * Get the pluralize instance
37
+ */
38
+ export declare function inflector(): typeof pluralize;
39
+ //# sourceMappingURL=pluralizer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pluralizer.d.ts","sourceRoot":"","sources":["../src/pluralizer.ts"],"names":[],"mappings":"AAEA,OAAO,SAAS,MAAM,WAAW,CAAC;AAElC,MAAM,WAAW,eAAe;IAC5B,WAAW,EAAE,MAAM,EAAE,CAAC;CACzB;AAoDD;;;;;;;;GAQG;AACH,wBAAgB,MAAM,CAClB,KAAK,EAAE,MAAM,EACb,KAAK,GAAE,MAAU,EACjB,YAAY,GAAE,OAAe,GAC9B,MAAM,CAKR;AAeD;;GAEG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAI9C;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAElD;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,KAAK,GAAE,MAAW,GAAG,OAAO,CAEpD;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,GAAE,MAAW,GAAG,OAAO,CAEtD;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAiBnE;AAED;;GAEG;AACH,wBAAgB,SAAS,IAAI,OAAO,SAAS,CAU5C"}
@@ -0,0 +1,90 @@
1
+ import { format as a } from "@zinaid/num";
2
+ import { isUndefined as s } from "@zinaid/utils";
3
+ import l from "pluralize";
4
+ let r;
5
+ const o = {
6
+ uncountable: [
7
+ "audio",
8
+ "bison",
9
+ "cattle",
10
+ "chassis",
11
+ "compensation",
12
+ "coreopsis",
13
+ "data",
14
+ "deer",
15
+ "education",
16
+ "emoji",
17
+ "equipment",
18
+ "evidence",
19
+ "feedback",
20
+ "firmware",
21
+ "fish",
22
+ "furniture",
23
+ "gold",
24
+ "hardware",
25
+ "information",
26
+ "jedi",
27
+ "kin",
28
+ "knowledge",
29
+ "love",
30
+ "metadata",
31
+ "money",
32
+ "moose",
33
+ "news",
34
+ "nutrition",
35
+ "offspring",
36
+ "plankton",
37
+ "pokemon",
38
+ "police",
39
+ "rain",
40
+ "recommended",
41
+ "related",
42
+ "rice",
43
+ "series",
44
+ "sheep",
45
+ "software",
46
+ "species",
47
+ "swine",
48
+ "traffic",
49
+ "wheat"
50
+ ]
51
+ };
52
+ function w(e, n = 2, i = !1) {
53
+ return (i ? a(n) + " " : "") + f(e, n);
54
+ }
55
+ function f(e, n) {
56
+ if (Math.abs(n) === 1 || c(e))
57
+ return e;
58
+ const i = t().plural(e);
59
+ return u(i, e);
60
+ }
61
+ function b(e) {
62
+ const n = t().singular(e);
63
+ return u(n, e);
64
+ }
65
+ function c(e) {
66
+ return o.uncountable.includes(e.toLowerCase());
67
+ }
68
+ function g(e = "") {
69
+ return t().isPlural(e);
70
+ }
71
+ function h(e = "") {
72
+ return t().isSingular(e);
73
+ }
74
+ function u(e, n) {
75
+ return n.toLowerCase() === n ? e.toLowerCase() : n.toUpperCase() === n ? e.toUpperCase() : n[0] && n[0].toUpperCase() + n.slice(1) === n ? (e[0] ?? "").toUpperCase() + e.slice(1) : e;
76
+ }
77
+ function t() {
78
+ return s(r) && (r = l, o.uncountable.forEach(
79
+ (e) => r.addUncountableRule(e)
80
+ )), r;
81
+ }
82
+ export {
83
+ t as inflector,
84
+ g as isPlural,
85
+ h as isSingular,
86
+ u as matchCase,
87
+ w as plural,
88
+ b as singular,
89
+ c as uncountable
90
+ };
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Random utilities mirroring Laravel's Str::random and PHP's random_int.
3
+ *
4
+ * Uses a cryptographically secure RNG when available (Web Crypto / Node crypto).
5
+ */
6
+ /**
7
+ * Generate a more truly "random" alpha-numeric string (Laravel compatible algorithm).
8
+ *
9
+ * @param length - The length of the random string to generate. Default is 16.
10
+ * @returns A random alpha-numeric string of the specified length.
11
+ *
12
+ * @example
13
+ * Random.string(); // 16 chars
14
+ * Random.string(40); // 40 chars
15
+ */
16
+ export declare function randomString(length?: number): string;
17
+ /**
18
+ * Cryptographically secure uniform random integer in [min, max] (inclusive).
19
+ * Mirrors PHP's random_int rejection sampling approach.
20
+ *
21
+ * @param min - The minimum value (inclusive).
22
+ * @param max - The maximum value (inclusive).
23
+ * @returns A cryptographically secure random integer between min and max (inclusive).
24
+ * @throws TypeError if bounds are not safe integers.
25
+ * @throws RangeError if min > max or bounds exceed MAX_SAFE_INTEGER.
26
+ */
27
+ export declare function randomInt(min: number, max: number): number;
28
+ //# sourceMappingURL=random.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"random.d.ts","sourceRoot":"","sources":["../src/random.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAC,MAAM,SAAK,GAAG,MAAM,CAehD;AAED;;;;;;;;;GASG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CA4C1D"}
package/dist/random.js ADDED
@@ -0,0 +1,44 @@
1
+ import { bytesToBase64 as c } from "@zinaid/str";
2
+ function f(e = 16) {
3
+ if (!Number.isFinite(e) || e <= 0)
4
+ return "";
5
+ let t = "";
6
+ for (; t.length < e; ) {
7
+ const o = e - t.length, r = Math.ceil(o / 3) * 3, i = u(r), a = c(i).replace(/[/+=]/g, "");
8
+ t += a.slice(0, o);
9
+ }
10
+ return t;
11
+ }
12
+ function l(e, t) {
13
+ if (!Number.isInteger(e) || !Number.isInteger(t))
14
+ throw new TypeError("randomInt bounds must be safe integers");
15
+ if (e > t)
16
+ throw new RangeError("randomInt min must be <= max");
17
+ if (e === t)
18
+ return e;
19
+ if (Math.abs(e) > Number.MAX_SAFE_INTEGER || Math.abs(t) > Number.MAX_SAFE_INTEGER)
20
+ throw new RangeError("Bounds exceed MAX_SAFE_INTEGER");
21
+ const o = t - e, r = Math.floor(Math.log2(o)) + 1, i = Math.ceil(r / 8);
22
+ for (; ; ) {
23
+ const a = u(i);
24
+ let n = 0;
25
+ for (let s = 0; s < i; s++)
26
+ n = n << 8 | a[s];
27
+ if (r % 8 !== 0) {
28
+ const s = 8 - r % 8;
29
+ n = n >> s & (1 << r) - 1;
30
+ }
31
+ if (n <= o)
32
+ return e + n;
33
+ }
34
+ }
35
+ function u(e) {
36
+ if (e <= 0) return new Uint8Array();
37
+ if (typeof globalThis.crypto?.getRandomValues == "function")
38
+ return globalThis.crypto.getRandomValues(new Uint8Array(e));
39
+ throw new Error("Secure randomness not available in this environment");
40
+ }
41
+ export {
42
+ l as randomInt,
43
+ f as randomString
44
+ };