@stacksjs/strings 0.61.24 → 0.63.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -12,181 +12,41 @@ var __export = (target, all) => {
12
12
  // src/string.ts
13
13
  var exports_string = {};
14
14
  __export(exports_string, {
15
- truncate: () => {
16
- {
17
- return truncate;
18
- }
19
- },
20
- toString: () => {
21
- {
22
- return toString;
23
- }
24
- },
25
- titleCase: () => {
26
- {
27
- return titleCase;
28
- }
29
- },
30
- template: () => {
31
- {
32
- return template;
33
- }
34
- },
35
- str: () => {
36
- {
37
- return str;
38
- }
39
- },
40
- split: () => {
41
- {
42
- return split;
43
- }
44
- },
45
- snakeCase: () => {
46
- {
47
- return snakeCase;
48
- }
49
- },
50
- slug: () => {
51
- {
52
- return slug;
53
- }
54
- },
55
- slash: () => {
56
- {
57
- return slash;
58
- }
59
- },
60
- singular: () => {
61
- {
62
- return singular2;
63
- }
64
- },
65
- sentenceCase: () => {
66
- {
67
- return sentenceCase;
68
- }
69
- },
70
- random: () => {
71
- {
72
- return random;
73
- }
74
- },
75
- plural: () => {
76
- {
77
- return plural2;
78
- }
79
- },
80
- pathCase: () => {
81
- {
82
- return pathCase;
83
- }
84
- },
85
- pascalCase: () => {
86
- {
87
- return pascalCase;
88
- }
89
- },
90
- paramCase: () => {
91
- {
92
- return kebabCase2;
93
- }
94
- },
95
- noCase: () => {
96
- {
97
- return noCase;
98
- }
99
- },
100
- lowercase: () => {
101
- {
102
- return lowercase;
103
- }
104
- },
105
- kebabCase: () => {
106
- {
107
- return kebabCase;
108
- }
109
- },
110
- isSingular: () => {
111
- {
112
- return isSingular2;
113
- }
114
- },
115
- isPlural: () => {
116
- {
117
- return isPlural2;
118
- }
119
- },
120
- ensureSuffix: () => {
121
- {
122
- return ensureSuffix;
123
- }
124
- },
125
- ensurePrefix: () => {
126
- {
127
- return ensurePrefix;
128
- }
129
- },
130
- dotCase: () => {
131
- {
132
- return dotCase;
133
- }
134
- },
135
- detectNewline: () => {
136
- {
137
- return detectNewline;
138
- }
139
- },
140
- detectIndent: () => {
141
- {
142
- return default2;
143
- }
144
- },
145
- constantCase: () => {
146
- {
147
- return constantCase;
148
- }
149
- },
150
- capitalize: () => {
151
- {
152
- return capitalize;
153
- }
154
- },
155
- capitalCase: () => {
156
- {
157
- return capitalCase;
158
- }
159
- },
160
- camelCase: () => {
161
- {
162
- return camelCase;
163
- }
164
- },
165
- addUncountableRule: () => {
166
- {
167
- return addUncountableRule2;
168
- }
169
- },
170
- addSingularRule: () => {
171
- {
172
- return addSingularRule2;
173
- }
174
- },
175
- addPluralRule: () => {
176
- {
177
- return addPluralRule2;
178
- }
179
- },
180
- addIrregularRule: () => {
181
- {
182
- return addIrregularRule2;
183
- }
184
- },
185
- Str: () => {
186
- {
187
- return Str;
188
- }
189
- }
15
+ truncate: () => truncate,
16
+ toString: () => toString,
17
+ titleCase: () => titleCase,
18
+ template: () => template,
19
+ str: () => str,
20
+ split: () => split,
21
+ snakeCase: () => snakeCase,
22
+ slug: () => slug,
23
+ slash: () => slash,
24
+ singular: () => singular2,
25
+ sentenceCase: () => sentenceCase,
26
+ random: () => random,
27
+ plural: () => plural2,
28
+ pathCase: () => pathCase,
29
+ pascalCase: () => pascalCase,
30
+ paramCase: () => kebabCase2,
31
+ noCase: () => noCase,
32
+ lowercase: () => lowercase,
33
+ kebabCase: () => kebabCase,
34
+ isSingular: () => isSingular2,
35
+ isPlural: () => isPlural2,
36
+ ensureSuffix: () => ensureSuffix,
37
+ ensurePrefix: () => ensurePrefix,
38
+ dotCase: () => dotCase,
39
+ detectNewline: () => detectNewline,
40
+ detectIndent: () => default2,
41
+ constantCase: () => constantCase,
42
+ capitalize: () => capitalize,
43
+ capitalCase: () => capitalCase,
44
+ camelCase: () => camelCase,
45
+ addUncountableRule: () => addUncountableRule2,
46
+ addSingularRule: () => addSingularRule2,
47
+ addPluralRule: () => addPluralRule2,
48
+ addIrregularRule: () => addIrregularRule2,
49
+ Str: () => Str
190
50
  });
191
51
 
192
52
  // src/utils.ts
@@ -404,3 +264,6 @@ export {
404
264
  addIrregularRule2 as addIrregularRule,
405
265
  Str
406
266
  };
267
+
268
+ //# debugId=272B1643AB5F268164756E2164756E21
269
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,14 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/utils.ts", "../src/case.ts", "../src/pluralize.ts", "../src/macro.ts", "../src/helpers.ts"],
4
+ "sourcesContent": [
5
+ "import slugify from 'slugify'\n\ninterface SlugOptions {\n replacement?: string\n remove?: RegExp\n lower?: boolean\n strict?: boolean\n locale?: string\n trim?: boolean\n}\n\n// port from nanoid\n// https://github.com/ai/nanoid\nconst urlAlphabet = 'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict'\n\n/**\n * Replace backslash to slash\n *\n * @category String\n * @example\n * ```\n * slash('C:\\\\Users\\\\Chris') => 'C:/Users/Chris'\n * ```\n */\nexport function slash(str: string) {\n return str.replace(/\\\\/g, '/')\n}\n\n/**\n * Ensure prefix of a string\n *\n * @category String\n * @example\n * ```\n * ensurePrefix('https://', 'google.com') => 'https://google.com'\n * ensurePrefix('https://', 'http://google.com') => 'https://google.com'\n */\nexport function ensurePrefix(prefix: string, str: string) {\n if (!str.startsWith(prefix)) return prefix + str\n return str\n}\n\n/**\n * Ensure suffix of a string\n *\n * @category String\n * @example\n * ```\n * ensureSuffix('.js', 'index') => 'index.js'\n * ensureSuffix('.js', 'index.js') => 'index.js'\n * ```\n */\nexport function ensureSuffix(suffix: string, str: string) {\n return str.endsWith(suffix) ? str : str + suffix\n}\n\n/**\n * Dead simple template engine, just like Python's `.format()`\n *\n * @category String\n * @example\n * ```\n * const result = template('Hello {0}! My name is {1}.',\n * 'Buddy',\n * 'Chris'\n * ) // Hello Buddy! My name is Chris.\n * ```\n */\nexport function template(str: string, ...args: any[]): string {\n return str.replace(/{(\\d+)}/g, (match, key) => {\n const index = Number(key)\n\n return Number.isNaN(index) ? match : args[index]\n })\n}\n\nexport function truncate(str: string, length: number, end = '...') {\n if (str.length <= length) return str\n\n return str.slice(0, length - end.length) + end\n}\n\n/**\n * Generate a random string\n * @category String\n */\nexport function random(size = 16, dict = urlAlphabet) {\n let id = ''\n let i = size\n const len = dict.length\n while (i--) id += dict[(Math.random() * len) | 0]\n return id\n}\n\n/**\n * Slugify a string\n * @category string\n * @example\n * ```\n * slug('Hello World') => 'hello-world'\n * ```\n */\nexport function slug(str: string, options?: SlugOptions): string {\n if (options) return slugify(str, options)\n\n return slugify(str, {\n lower: true,\n strict: true,\n })\n}\n\nexport { default as detectIndent } from 'detect-indent'\nexport { detectNewline } from 'detect-newline'\n",
6
+ "/**\n * First letter uppercase, other lowercase\n * @category string\n * @example\n * ```\n * capitalize('hello world') => 'Hello world'\n * ```\n */\nexport function capitalize(str: string): string {\n return str[0] ? str[0].toUpperCase() + str.slice(1).toLowerCase() : ''\n}\n\nexport function lowercase(str: string): string {\n return str.toLowerCase()\n}\n\nexport {\n camelCase,\n capitalCase,\n constantCase,\n dotCase,\n noCase,\n kebabCase,\n kebabCase as paramCase,\n pascalCase,\n pathCase,\n sentenceCase,\n snakeCase,\n split,\n} from 'change-case'\nexport { titleCase } from 'title-case'\n",
7
+ "import * as pluralize from 'pluralize'\n\ntype Rule = string | RegExp\ntype Replacement = string\ntype Word = string\nexport type PluralizeTest = (word: Word) => boolean\n\nexport interface Pluralize {\n plural: (word: Word, count?: number, inclusive?: boolean) => Word\n singular: (word: Word) => Word\n isPlural: (word: Word) => boolean\n isSingular: (word: Word) => boolean\n addPluralRule: (rule: Rule, replacement: Replacement) => void\n addSingularRule: (rule: Rule, replacement: Replacement) => void\n addIrregularRule: (single: Word, plural: Word) => void\n addUncountableRule: (word: Word | RegExp) => void\n}\n\nexport const plural: Pluralize['plural'] = (word, count, inclusive) => {\n if (count !== undefined && inclusive) return `${count} ${pluralize.plural(word)}`\n\n return pluralize.plural(word)\n}\n\nexport const singular: Pluralize['singular'] = (word) => pluralize.singular(word)\nexport const isPlural: Pluralize['isPlural'] = (word) => pluralize.isPlural(word)\nexport const isSingular: Pluralize['isSingular'] = (word) => pluralize.isSingular(word)\nexport const addPluralRule: Pluralize['addPluralRule'] = (rule, replacement) =>\n pluralize.addPluralRule(rule, replacement)\nexport const addSingularRule: Pluralize['addSingularRule'] = (rule, replacement) =>\n pluralize.addSingularRule(rule, replacement)\nexport const addIrregularRule: Pluralize['addIrregularRule'] = (single, plural) =>\n pluralize.addIrregularRule(single, plural)\nexport const addUncountableRule: Pluralize['addUncountableRule'] = (word) => pluralize.addUncountableRule(word)\n",
8
+ "import * as c from './case'\nimport * as p from './pluralize'\nimport * as u from './utils'\n\nexport const Str = {\n slash(str: string) {\n return u.slash(str)\n },\n\n ensurePrefix(prefix: string, str: string) {\n return u.ensurePrefix(prefix, str)\n },\n\n ensureSuffix(suffix: string, str: string) {\n return u.ensureSuffix(suffix, str)\n },\n\n template(str: string, ...args: any[]): string {\n return u.template(str, ...args)\n },\n\n /**\n * Truncate a string\n */\n truncate(str: string, length: number, end = '...') {\n return u.truncate(str, length, end)\n },\n\n random(length = 16) {\n return u.random(length)\n },\n\n capitalize(str: string) {\n return c.capitalize(str)\n },\n\n slug(str: string) {\n return u.slug(str)\n },\n\n detectIndent(str: string) {\n return u.detectIndent(str)\n },\n\n detectNewline(str: string) {\n return u.detectNewline(str)\n },\n\n camelCase(str: string) {\n return c.camelCase(str)\n },\n\n capitalCase(str: string) {\n return c.capitalCase(str)\n },\n\n constantCase(str: string) {\n return c.constantCase(str)\n },\n\n dotCase(str: string) {\n return c.dotCase(str)\n },\n\n noCase(str: string) {\n return c.noCase(str)\n },\n\n paramCase(str: string) {\n return c.paramCase(str)\n },\n\n pascalCase(str: string) {\n return c.pascalCase(str)\n },\n\n pathCase(str: string) {\n return c.pathCase(str)\n },\n\n sentenceCase(str: string) {\n return c.sentenceCase(str)\n },\n\n snakeCase(str: string) {\n return c.snakeCase(str)\n },\n\n titleCase(str: string) {\n return c.titleCase(str)\n },\n\n kebabCase(str: string) {\n return c.kebabCase(str)\n },\n\n plural(str: string) {\n // plural, singular, isPlural, isSingular, addPluralRule, addSingularRule, addIrregularRule, addUncountableRule\n return p.plural(str)\n },\n\n singular(str: string) {\n return p.singular(str)\n },\n\n isPlural(str: string) {\n return p.isPlural(str)\n },\n\n isSingular(str: string) {\n return p.isSingular(str)\n },\n\n addPluralRule(rule: string | RegExp, repl: string) {\n return p.addPluralRule(rule, repl)\n },\n\n addSingularRule(rule: string | RegExp, repl: string) {\n return p.addSingularRule(rule, repl)\n },\n\n addIrregularRule(single: string, plural: string) {\n return p.addIrregularRule(single, plural)\n },\n\n addUncountableRule(word: string | RegExp) {\n return p.addUncountableRule(word)\n },\n}\n\nexport const str = Str\n",
9
+ "export function toString(v: any) {\n return Object.prototype.toString.call(v)\n}\n"
10
+ ],
11
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAwBO,SAAS,KAAK,CAAC,KAAa;AACjC,SAAO,IAAI,QAAQ,OAAO,GAAG;AAAA;AAYxB,SAAS,YAAY,CAAC,QAAgB,KAAa;AACxD,OAAK,IAAI,WAAW,MAAM;AAAG,WAAO,SAAS;AAC7C,SAAO;AAAA;AAaF,SAAS,YAAY,CAAC,QAAgB,KAAa;AACxD,SAAO,IAAI,SAAS,MAAM,IAAI,MAAM,MAAM;AAAA;AAerC,SAAS,QAAQ,CAAC,QAAgB,MAAqB;AAC5D,SAAO,IAAI,QAAQ,YAAY,CAAC,OAAO,QAAQ;AAC7C,UAAM,QAAQ,OAAO,GAAG;AAExB,WAAO,OAAO,MAAM,KAAK,IAAI,QAAQ,KAAK;AAAA,GAC3C;AAAA;AAGI,SAAS,QAAQ,CAAC,KAAa,QAAgB,MAAM,OAAO;AACjE,MAAI,IAAI,UAAU;AAAQ,WAAO;AAEjC,SAAO,IAAI,MAAM,GAAG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,KAAa;AACxB,WAAS,aAAa,GAAG;AAAA;AAAA,EAG3B,SAAS,CAAC,KAAa;AACrB,WAAS,UAAU,GAAG;AAAA;AAAA,EAGxB,SAAS,CAAC,KAAa;AACrB,WAAS,UAAU,GAAG;AAAA;AAAA,EAGxB,SAAS,CAAC,KAAa;AACrB,WAAS,UAAU,GAAG;AAAA;AAAA,EAGxB,MAAM,CAAC,KAAa;AAElB,WAAS,QAAO,GAAG;AAAA;AAAA,EAGrB,QAAQ,CAAC,KAAa;AACpB,WAAS,UAAS,GAAG;AAAA;AAAA,EAGvB,QAAQ,CAAC,KAAa;AACpB,WAAS,UAAS,GAAG;AAAA;AAAA,EAGvB,UAAU,CAAC,KAAa;AACtB,WAAS,YAAW,GAAG;AAAA;AAAA,EAGzB,aAAa,CAAC,MAAuB,MAAc;AACjD,WAAS,eAAc,MAAM,IAAI;AAAA;AAAA,EAGnC,eAAe,CAAC,MAAuB,MAAc;AACnD,WAAS,iBAAgB,MAAM,IAAI;AAAA;AAAA,EAGrC,gBAAgB,CAAC,QAAgB,SAAgB;AAC/C,WAAS,kBAAiB,QAAQ,OAAM;AAAA;AAAA,EAG1C,kBAAkB,CAAC,MAAuB;AACxC,WAAS,oBAAmB,IAAI;AAAA;AAEpC;AAEO,IAAM,MAAM;;AClIZ,SAAS,QAAQ,CAAC,GAAQ;AAC/B,SAAO,OAAO,UAAU,SAAS,KAAK,CAAC;AAAA;",
12
+ "debugId": "272B1643AB5F268164756E2164756E21",
13
+ "names": []
14
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/strings",
3
3
  "type": "module",
4
- "version": "0.61.24",
4
+ "version": "0.63.0",
5
5
  "description": "The Stacks string utilities.",
6
6
  "author": "Chris Breuer",
7
7
  "license": "MIT",
@@ -71,13 +71,13 @@
71
71
  "macroable": "^7.0.2",
72
72
  "pluralize": "^8.0.0",
73
73
  "slugify": "^1.6.6",
74
- "string-ts": "^2.1.1",
74
+ "string-ts": "^2.2.0",
75
75
  "title-case": "^4.3.1",
76
76
  "validator": "^13.12.0"
77
77
  },
78
78
  "devDependencies": {
79
79
  "@stacksjs/development": "latest",
80
80
  "@types/pluralize": "^0.0.33",
81
- "@types/validator": "^13.11.10"
81
+ "@types/validator": "^13.12.0"
82
82
  }
83
83
  }