@stacksjs/strings 0.56.3 → 0.56.24
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/package.json +5 -4
- package/dist/index.cjs +0 -201
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/strings",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.56.
|
|
4
|
+
"version": "0.56.24",
|
|
5
5
|
"packageManager": "pnpm@8.6.5",
|
|
6
6
|
"description": "The Stacks string utilities.",
|
|
7
7
|
"author": "Chris Breuer",
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
"import": "./dist/index.mjs"
|
|
41
41
|
}
|
|
42
42
|
},
|
|
43
|
+
"main": "dist/index.mjs",
|
|
43
44
|
"module": "dist/index.mjs",
|
|
44
45
|
"types": "dist/index.d.ts",
|
|
45
46
|
"contributors": [
|
|
@@ -60,14 +61,14 @@
|
|
|
60
61
|
"slugify": "^1.6.6",
|
|
61
62
|
"title-case": "^3.0.3",
|
|
62
63
|
"validator": "^13.9.0",
|
|
63
|
-
"@stacksjs/
|
|
64
|
-
"@stacksjs/
|
|
64
|
+
"@stacksjs/alias": "0.56.24",
|
|
65
|
+
"@stacksjs/types": "0.56.24"
|
|
65
66
|
},
|
|
66
67
|
"dependencies": {
|
|
67
68
|
"macroable": "^7.0.2"
|
|
68
69
|
},
|
|
69
70
|
"devDependencies": {
|
|
70
|
-
"@stacksjs/development": "0.56.
|
|
71
|
+
"@stacksjs/development": "0.56.24"
|
|
71
72
|
},
|
|
72
73
|
"scripts": {
|
|
73
74
|
"build": "unbuild",
|
package/dist/index.cjs
DELETED
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const slugify = require('slugify');
|
|
4
|
-
const detectIndent = require('detect-indent');
|
|
5
|
-
const detectNewline = require('detect-newline');
|
|
6
|
-
const changeCase = require('change-case');
|
|
7
|
-
const titleCase = require('title-case');
|
|
8
|
-
const pluralize = require('pluralize');
|
|
9
|
-
const macroable = require('macroable');
|
|
10
|
-
|
|
11
|
-
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
12
|
-
|
|
13
|
-
const slugify__default = /*#__PURE__*/_interopDefaultCompat(slugify);
|
|
14
|
-
const detectIndent__default = /*#__PURE__*/_interopDefaultCompat(detectIndent);
|
|
15
|
-
const pluralize__default = /*#__PURE__*/_interopDefaultCompat(pluralize);
|
|
16
|
-
|
|
17
|
-
const urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
|
|
18
|
-
function slash(str) {
|
|
19
|
-
return str.replace(/\\/g, "/");
|
|
20
|
-
}
|
|
21
|
-
function ensurePrefix(prefix, str) {
|
|
22
|
-
if (!str.startsWith(prefix))
|
|
23
|
-
return prefix + str;
|
|
24
|
-
return str;
|
|
25
|
-
}
|
|
26
|
-
function ensureSuffix(suffix, str) {
|
|
27
|
-
if (!str.endsWith(suffix))
|
|
28
|
-
return str + suffix;
|
|
29
|
-
return str;
|
|
30
|
-
}
|
|
31
|
-
function template(str, ...args) {
|
|
32
|
-
return str.replace(/{(\d+)}/g, (match, key) => {
|
|
33
|
-
const index = Number(key);
|
|
34
|
-
if (Number.isNaN(index))
|
|
35
|
-
return match;
|
|
36
|
-
return args[index];
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
function truncate(str, length, end = "...") {
|
|
40
|
-
if (str.length <= length)
|
|
41
|
-
return str;
|
|
42
|
-
return str.slice(0, length - end.length) + end;
|
|
43
|
-
}
|
|
44
|
-
function randomStr(size = 16, dict = urlAlphabet) {
|
|
45
|
-
let id = "";
|
|
46
|
-
let i = size;
|
|
47
|
-
const len = dict.length;
|
|
48
|
-
while (i--)
|
|
49
|
-
id += dict[Math.random() * len | 0];
|
|
50
|
-
return id;
|
|
51
|
-
}
|
|
52
|
-
function slug(str, options) {
|
|
53
|
-
if (options)
|
|
54
|
-
return slugify__default(str, options);
|
|
55
|
-
return slugify__default(str, {
|
|
56
|
-
lower: true,
|
|
57
|
-
strict: true
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
function capitalize(str) {
|
|
62
|
-
return str[0].toUpperCase() + str.slice(1).toLowerCase();
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const { plural, singular, isPlural, isSingular, addPluralRule, addSingularRule, addIrregularRule, addUncountableRule } = pluralize__default;
|
|
66
|
-
|
|
67
|
-
class Str extends macroable.Macroable {
|
|
68
|
-
slash(str2) {
|
|
69
|
-
return slash(str2);
|
|
70
|
-
}
|
|
71
|
-
ensurePrefix(prefix, str2) {
|
|
72
|
-
return ensurePrefix(prefix, str2);
|
|
73
|
-
}
|
|
74
|
-
ensureSuffix(suffix, str2) {
|
|
75
|
-
return ensureSuffix(suffix, str2);
|
|
76
|
-
}
|
|
77
|
-
template(str2, ...args) {
|
|
78
|
-
return template(str2, ...args);
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Truncate a string
|
|
82
|
-
*/
|
|
83
|
-
truncate(str2, length, end = "...") {
|
|
84
|
-
return truncate(str2, length, end);
|
|
85
|
-
}
|
|
86
|
-
random(length = 16) {
|
|
87
|
-
return randomStr(length);
|
|
88
|
-
}
|
|
89
|
-
capitalize(str2) {
|
|
90
|
-
return capitalize(str2);
|
|
91
|
-
}
|
|
92
|
-
slug(str2) {
|
|
93
|
-
return slug(str2);
|
|
94
|
-
}
|
|
95
|
-
detectIndent(str2) {
|
|
96
|
-
return detectIndent__default(str2);
|
|
97
|
-
}
|
|
98
|
-
detectNewline(str2) {
|
|
99
|
-
return detectNewline.detectNewline(str2);
|
|
100
|
-
}
|
|
101
|
-
camelCase(str2) {
|
|
102
|
-
return changeCase.camelCase(str2);
|
|
103
|
-
}
|
|
104
|
-
capitalCase(str2) {
|
|
105
|
-
return changeCase.capitalCase(str2);
|
|
106
|
-
}
|
|
107
|
-
constantCase(str2) {
|
|
108
|
-
return changeCase.constantCase(str2);
|
|
109
|
-
}
|
|
110
|
-
dotCase(str2) {
|
|
111
|
-
return changeCase.dotCase(str2);
|
|
112
|
-
}
|
|
113
|
-
headerCase(str2) {
|
|
114
|
-
return changeCase.headerCase(str2);
|
|
115
|
-
}
|
|
116
|
-
noCase(str2) {
|
|
117
|
-
return changeCase.noCase(str2);
|
|
118
|
-
}
|
|
119
|
-
paramCase(str2) {
|
|
120
|
-
return changeCase.paramCase(str2);
|
|
121
|
-
}
|
|
122
|
-
pascalCase(str2) {
|
|
123
|
-
return changeCase.pascalCase(str2);
|
|
124
|
-
}
|
|
125
|
-
pathCase(str2) {
|
|
126
|
-
return changeCase.pathCase(str2);
|
|
127
|
-
}
|
|
128
|
-
sentenceCase(str2) {
|
|
129
|
-
return changeCase.sentenceCase(str2);
|
|
130
|
-
}
|
|
131
|
-
snakeCase(str2) {
|
|
132
|
-
return changeCase.snakeCase(str2);
|
|
133
|
-
}
|
|
134
|
-
titleCase(str2) {
|
|
135
|
-
return titleCase.titleCase(str2);
|
|
136
|
-
}
|
|
137
|
-
kebabCase(str2) {
|
|
138
|
-
return changeCase.paramCase(str2);
|
|
139
|
-
}
|
|
140
|
-
plural(str2) {
|
|
141
|
-
return plural(str2);
|
|
142
|
-
}
|
|
143
|
-
singular(str2) {
|
|
144
|
-
return singular(str2);
|
|
145
|
-
}
|
|
146
|
-
isPlural(str2) {
|
|
147
|
-
return isPlural(str2);
|
|
148
|
-
}
|
|
149
|
-
isSingular(str2) {
|
|
150
|
-
return isSingular(str2);
|
|
151
|
-
}
|
|
152
|
-
addPluralRule(rule, repl) {
|
|
153
|
-
return addPluralRule(rule, repl);
|
|
154
|
-
}
|
|
155
|
-
addSingularRule(rule, repl) {
|
|
156
|
-
return addSingularRule(rule, repl);
|
|
157
|
-
}
|
|
158
|
-
addIrregularRule(single, plural) {
|
|
159
|
-
return addIrregularRule(single, plural);
|
|
160
|
-
}
|
|
161
|
-
addUncountableRule(word) {
|
|
162
|
-
return addUncountableRule(word);
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
Str.macros = {};
|
|
166
|
-
Str.getters = {};
|
|
167
|
-
const str = new Str();
|
|
168
|
-
|
|
169
|
-
exports.detectIndent = detectIndent__default;
|
|
170
|
-
exports.detectNewline = detectNewline.detectNewline;
|
|
171
|
-
exports.camelCase = changeCase.camelCase;
|
|
172
|
-
exports.capitalCase = changeCase.capitalCase;
|
|
173
|
-
exports.constantCase = changeCase.constantCase;
|
|
174
|
-
exports.dotCase = changeCase.dotCase;
|
|
175
|
-
exports.headerCase = changeCase.headerCase;
|
|
176
|
-
exports.kebabCase = changeCase.paramCase;
|
|
177
|
-
exports.noCase = changeCase.noCase;
|
|
178
|
-
exports.paramCase = changeCase.paramCase;
|
|
179
|
-
exports.pascalCase = changeCase.pascalCase;
|
|
180
|
-
exports.pathCase = changeCase.pathCase;
|
|
181
|
-
exports.sentenceCase = changeCase.sentenceCase;
|
|
182
|
-
exports.snakeCase = changeCase.snakeCase;
|
|
183
|
-
exports.titleCase = titleCase.titleCase;
|
|
184
|
-
exports.Str = Str;
|
|
185
|
-
exports.addIrregularRule = addIrregularRule;
|
|
186
|
-
exports.addPluralRule = addPluralRule;
|
|
187
|
-
exports.addSingularRule = addSingularRule;
|
|
188
|
-
exports.addUncountableRule = addUncountableRule;
|
|
189
|
-
exports.capitalize = capitalize;
|
|
190
|
-
exports.ensurePrefix = ensurePrefix;
|
|
191
|
-
exports.ensureSuffix = ensureSuffix;
|
|
192
|
-
exports.isPlural = isPlural;
|
|
193
|
-
exports.isSingular = isSingular;
|
|
194
|
-
exports.plural = plural;
|
|
195
|
-
exports.randomStr = randomStr;
|
|
196
|
-
exports.singular = singular;
|
|
197
|
-
exports.slash = slash;
|
|
198
|
-
exports.slug = slug;
|
|
199
|
-
exports.str = str;
|
|
200
|
-
exports.template = template;
|
|
201
|
-
exports.truncate = truncate;
|