@h3ravel/support 0.2.0 → 0.4.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.cjs CHANGED
@@ -1,26 +1,26 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
1
+ 'use strict'
2
+ var __defProp = Object.defineProperty
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor
4
+ var __getOwnPropNames = Object.getOwnPropertyNames
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty
6
+ var __name = (target, value) => __defProp(target, 'name', { value, configurable: true })
7
7
  var __export = (target, all) => {
8
8
  for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
9
+ __defProp(target, name, { get: all[name], enumerable: true })
10
+ }
11
11
  var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
12
+ if (from && typeof from === 'object' || typeof from === 'function') {
13
13
  for (let key of __getOwnPropNames(from))
14
14
  if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable })
16
16
  }
17
- return to;
18
- };
19
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
17
+ return to
18
+ }
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, '__esModule', { value: true }), mod)
20
20
 
21
21
  // src/index.ts
22
- var index_exports = {};
23
- __export(index_exports, {
22
+ var src_exports = {}
23
+ __export(src_exports, {
24
24
  abbreviate: () => abbreviate,
25
25
  after: () => after,
26
26
  afterLast: () => afterLast,
@@ -45,351 +45,377 @@ __export(index_exports, {
45
45
  toBytes: () => toBytes,
46
46
  toHumanTime: () => toHumanTime,
47
47
  truncate: () => truncate
48
- });
49
- module.exports = __toCommonJS(index_exports);
48
+ })
49
+ module.exports = __toCommonJS(src_exports)
50
50
 
51
51
  // src/Helpers/Arr.ts
52
52
  var chunk = /* @__PURE__ */ __name((arr, size = 2) => {
53
- if (size <= 0) throw new Error("Chunk size must be greater than 0");
54
- const chunks = [];
53
+ if (size <= 0)
54
+ throw new Error('Chunk size must be greater than 0')
55
+ const chunks = []
55
56
  for (let i = 0; i < arr.length; i += size) {
56
- chunks.push(arr.slice(i, i + size));
57
+ chunks.push(arr.slice(i, i + size))
57
58
  }
58
- return chunks;
59
- }, "chunk");
59
+ return chunks
60
+ }, 'chunk')
60
61
  var range = /* @__PURE__ */ __name((size, startAt = 0) => {
61
- if (size <= 0 || !Number.isFinite(size)) return [];
62
+ if (size <= 0 || !Number.isFinite(size))
63
+ return []
62
64
  return Array.from({
63
65
  length: size
64
- }, (_, i) => startAt + i);
65
- }, "range");
66
+ }, (_, i) => startAt + i)
67
+ }, 'range')
66
68
 
67
69
  // src/Helpers/Number.ts
68
- var abbreviate = /* @__PURE__ */ __name((value, locale = "en-US") => {
69
- if (!value) return "0";
70
+ var abbreviate = /* @__PURE__ */ __name((value, locale = 'en-US') => {
71
+ if (!value)
72
+ return '0'
70
73
  if (value < 1e3) {
71
- return new Intl.NumberFormat(locale).format(value);
74
+ return new Intl.NumberFormat(locale).format(value)
72
75
  }
73
76
  const si = [
74
77
  {
75
78
  v: 1e18,
76
- s: "E"
79
+ s: 'E'
77
80
  },
78
81
  {
79
82
  v: 1e15,
80
- s: "P"
83
+ s: 'P'
81
84
  },
82
85
  {
83
86
  v: 1e12,
84
- s: "T"
87
+ s: 'T'
85
88
  },
86
89
  {
87
90
  v: 1e9,
88
- s: "B"
91
+ s: 'B'
89
92
  },
90
93
  {
91
94
  v: 1e6,
92
- s: "M"
95
+ s: 'M'
93
96
  },
94
97
  {
95
98
  v: 1e3,
96
- s: "K"
99
+ s: 'K'
97
100
  }
98
- ];
99
- const match = si.find((scale) => value >= scale.v);
100
- if (!match) return new Intl.NumberFormat(locale).format(value);
101
- const formatted = value / match.v;
101
+ ]
102
+ const match = si.find((scale) => value >= scale.v)
103
+ if (!match)
104
+ return new Intl.NumberFormat(locale).format(value)
105
+ const formatted = value / match.v
102
106
  return new Intl.NumberFormat(locale, {
103
107
  minimumFractionDigits: 0,
104
108
  maximumFractionDigits: 2
105
- }).format(formatted) + match.s;
106
- }, "abbreviate");
109
+ }).format(formatted) + match.s
110
+ }, 'abbreviate')
107
111
  var humanize = /* @__PURE__ */ __name((num, slugify2) => {
108
112
  if (!num) {
109
- return "";
113
+ return ''
110
114
  }
111
- if (slugify2 === "-" || slugify2 === "_") {
112
- const h = humanize(num);
113
- return typeof h === "string" ? h.replace(" ", slugify2).toLowerCase() : h;
115
+ if (slugify2 === '-' || slugify2 === '_') {
116
+ const h = humanize(num)
117
+ return typeof h === 'string' ? h.replace(' ', slugify2).toLowerCase() : h
114
118
  }
115
119
  const ones = [
116
- "",
117
- "one",
118
- "two",
119
- "three",
120
- "four",
121
- "five",
122
- "six",
123
- "seven",
124
- "eight",
125
- "nine",
126
- "ten",
127
- "eleven",
128
- "twelve",
129
- "thirteen",
130
- "fourteen",
131
- "fifteen",
132
- "sixteen",
133
- "seventeen",
134
- "eighteen",
135
- "nineteen"
136
- ];
120
+ '',
121
+ 'one',
122
+ 'two',
123
+ 'three',
124
+ 'four',
125
+ 'five',
126
+ 'six',
127
+ 'seven',
128
+ 'eight',
129
+ 'nine',
130
+ 'ten',
131
+ 'eleven',
132
+ 'twelve',
133
+ 'thirteen',
134
+ 'fourteen',
135
+ 'fifteen',
136
+ 'sixteen',
137
+ 'seventeen',
138
+ 'eighteen',
139
+ 'nineteen'
140
+ ]
137
141
  const tens = [
138
- "",
139
- "",
140
- "twenty",
141
- "thirty",
142
- "forty",
143
- "fifty",
144
- "sixty",
145
- "seventy",
146
- "eighty",
147
- "ninety"
148
- ];
149
- const numString = num.toString();
150
- if (num < 0) throw new Error("Negative numbers are not supported.");
151
- if (num === 0) return "zero";
142
+ '',
143
+ '',
144
+ 'twenty',
145
+ 'thirty',
146
+ 'forty',
147
+ 'fifty',
148
+ 'sixty',
149
+ 'seventy',
150
+ 'eighty',
151
+ 'ninety'
152
+ ]
153
+ const numString = num.toString()
154
+ if (num < 0)
155
+ throw new Error('Negative numbers are not supported.')
156
+ if (num === 0)
157
+ return 'zero'
152
158
  if (num < 20) {
153
- return ones[num] ?? "";
159
+ return ones[num] ?? ''
154
160
  }
155
161
  if (numString.length === 2) {
156
- return tens[numString[0]] + " " + ones[numString[1]];
162
+ return tens[numString[0]] + ' ' + ones[numString[1]]
157
163
  }
158
164
  if (numString.length == 3) {
159
- if (numString[1] === "0" && numString[2] === "0") return ones[numString[0]] + " hundred";
160
- else return ones[numString[0]] + " hundred and " + humanize(+((numString[1] || "") + numString[2]), slugify2);
165
+ if (numString[1] === '0' && numString[2] === '0')
166
+ return ones[numString[0]] + ' hundred'
167
+ else
168
+ return ones[numString[0]] + ' hundred and ' + humanize(+((numString[1] || '') + numString[2]), slugify2)
161
169
  }
162
170
  if (numString.length === 4) {
163
- const end = +((numString[1] || "") + numString[2] + numString[3]);
164
- if (end === 0) return ones[numString[0]] + " thousand";
165
- if (end < 100) return ones[numString[0]] + " thousand and " + humanize(end, slugify2);
166
- return ones[numString[0]] + " thousand " + humanize(end, slugify2);
171
+ const end = +((numString[1] || '') + numString[2] + numString[3])
172
+ if (end === 0)
173
+ return ones[numString[0]] + ' thousand'
174
+ if (end < 100)
175
+ return ones[numString[0]] + ' thousand and ' + humanize(end, slugify2)
176
+ return ones[numString[0]] + ' thousand ' + humanize(end, slugify2)
167
177
  }
168
- return num;
169
- }, "humanize");
178
+ return num
179
+ }, 'humanize')
170
180
  var toBytes = /* @__PURE__ */ __name((bytes, decimals = 2, bits = false) => {
171
181
  if (!bytes || isNaN(bytes)) {
172
- return bits ? "0 B" : "0 Bytes";
182
+ return bits ? '0 B' : '0 Bytes'
173
183
  }
174
- const base = bits ? 1e3 : 1024;
175
- const dm = decimals < 0 ? 0 : decimals;
184
+ const base = bits ? 1e3 : 1024
185
+ const dm = decimals < 0 ? 0 : decimals
176
186
  const sizes = bits ? [
177
- "B",
178
- "KB",
179
- "MB",
180
- "GB",
181
- "TB",
182
- "PB",
183
- "EB",
184
- "ZB",
185
- "YB"
187
+ 'B',
188
+ 'KB',
189
+ 'MB',
190
+ 'GB',
191
+ 'TB',
192
+ 'PB',
193
+ 'EB',
194
+ 'ZB',
195
+ 'YB'
186
196
  ] : [
187
- "Bytes",
188
- "KiB",
189
- "MiB",
190
- "GiB",
191
- "TiB",
192
- "PiB",
193
- "EiB",
194
- "ZiB",
195
- "YiB"
196
- ];
197
- const index = Math.floor(Math.log(bytes) / Math.log(base));
198
- const value = parseFloat((bytes / Math.pow(base, index)).toFixed(dm));
199
- return `${value} ${sizes[index]}`;
200
- }, "toBytes");
197
+ 'Bytes',
198
+ 'KiB',
199
+ 'MiB',
200
+ 'GiB',
201
+ 'TiB',
202
+ 'PiB',
203
+ 'EiB',
204
+ 'ZiB',
205
+ 'YiB'
206
+ ]
207
+ const index = Math.floor(Math.log(bytes) / Math.log(base))
208
+ const value = parseFloat((bytes / Math.pow(base, index)).toFixed(dm))
209
+ return `${value} ${sizes[index]}`
210
+ }, 'toBytes')
201
211
  var toHumanTime = /* @__PURE__ */ __name((seconds = 0, worded = false) => {
202
- if (isNaN(seconds) || seconds < 0) seconds = 0;
203
- const hours = Math.floor(seconds / 3600);
204
- const minutes = Math.floor(seconds % 3600 / 60);
205
- const secs = Math.floor(seconds % 60);
212
+ if (isNaN(seconds) || seconds < 0)
213
+ seconds = 0
214
+ const hours = Math.floor(seconds / 3600)
215
+ const minutes = Math.floor(seconds % 3600 / 60)
216
+ const secs = Math.floor(seconds % 60)
206
217
  if (worded) {
207
- const parts = [];
208
- if (hours) parts.push(`${hours}hr`);
209
- if (minutes) parts.push(`${minutes}min`);
210
- if (secs || !hours && !minutes) parts.push(`${secs}sec`);
211
- return parts.join(" ");
218
+ const parts = []
219
+ if (hours)
220
+ parts.push(`${hours}hr`)
221
+ if (minutes)
222
+ parts.push(`${minutes}min`)
223
+ if (secs || !hours && !minutes)
224
+ parts.push(`${secs}sec`)
225
+ return parts.join(' ')
212
226
  }
213
- const hh = hours > 0 ? `${hours}:` : "";
214
- const mm = (hours > 0 && minutes < 10 ? `0${minutes}` : minutes) + ":";
215
- const ss = secs < 10 ? `0${secs}` : secs;
216
- return `${hh}${mm}${ss}`;
217
- }, "toHumanTime");
227
+ const hh = hours > 0 ? `${hours}:` : ''
228
+ const mm = (hours > 0 && minutes < 10 ? `0${minutes}` : minutes) + ':'
229
+ const ss = secs < 10 ? `0${secs}` : secs
230
+ return `${hh}${mm}${ss}`
231
+ }, 'toHumanTime')
218
232
 
219
233
  // src/Helpers/Obj.ts
220
234
  var dot = /* @__PURE__ */ __name((obj) => {
221
- const result = {};
222
- const recurse = /* @__PURE__ */ __name((o, prefix = "") => {
235
+ const result = {}
236
+ const recurse = /* @__PURE__ */ __name((o, prefix = '') => {
223
237
  for (const [key, value] of Object.entries(o)) {
224
- const newKey = prefix ? `${prefix}.${key}` : key;
225
- if (value && typeof value === "object" && !Array.isArray(value)) {
226
- recurse(value, newKey);
238
+ const newKey = prefix ? `${prefix}.${key}` : key
239
+ if (value && typeof value === 'object' && !Array.isArray(value)) {
240
+ recurse(value, newKey)
227
241
  } else {
228
- result[newKey] = value;
242
+ result[newKey] = value
229
243
  }
230
244
  }
231
- }, "recurse");
232
- recurse(obj);
233
- return result;
234
- }, "dot");
245
+ }, 'recurse')
246
+ recurse(obj)
247
+ return result
248
+ }, 'dot')
235
249
  var extractProperties = /* @__PURE__ */ __name((obj, keys = []) => {
236
250
  return Object.fromEntries(keys.map((key) => [
237
251
  key,
238
252
  obj[key]
239
- ]));
240
- }, "extractProperties");
253
+ ]))
254
+ }, 'extractProperties')
241
255
  var getValue = /* @__PURE__ */ __name((key, item) => {
242
256
  if (Array.isArray(key)) {
243
- const [parent, child] = key;
257
+ const [parent, child] = key
244
258
  if (child !== void 0) {
245
- return String(item?.[parent]?.[child] ?? item?.[parent] ?? `${String(parent)}.${String(child)}`);
259
+ return String(item?.[parent]?.[child] ?? item?.[parent] ?? `${String(parent)}.${String(child)}`)
246
260
  }
247
- return String(item?.[parent] ?? parent);
261
+ return String(item?.[parent] ?? parent)
248
262
  }
249
- return String(item?.[key] ?? key);
250
- }, "getValue");
263
+ return String(item?.[key] ?? key)
264
+ }, 'getValue')
251
265
  var modObj = /* @__PURE__ */ __name((obj, callback) => {
252
266
  return Object.fromEntries(Object.entries(obj).map(([key, value]) => callback([
253
267
  key,
254
268
  value
255
- ])));
256
- }, "modObj");
269
+ ])))
270
+ }, 'modObj')
257
271
  function safeDot(data, key) {
258
- if (!key) return data;
259
- return key.split(".").reduce((acc, k) => acc?.[k], data);
272
+ if (!key)
273
+ return data
274
+ return key.split('.').reduce((acc, k) => acc?.[k], data)
260
275
  }
261
- __name(safeDot, "safeDot");
276
+ __name(safeDot, 'safeDot')
262
277
  var setNested = /* @__PURE__ */ __name((obj, key, value) => {
263
- if (!key.includes(".")) {
264
- obj[key] = value;
265
- return;
278
+ if (!key.includes('.')) {
279
+ obj[key] = value
280
+ return
266
281
  }
267
- const parts = key.split(".");
268
- let current = obj;
282
+ const parts = key.split('.')
283
+ let current = obj
269
284
  for (let i = 0; i < parts.length; i++) {
270
- const part = parts[i];
285
+ const part = parts[i]
271
286
  if (i === parts.length - 1) {
272
- current[part] = value;
287
+ current[part] = value
273
288
  } else {
274
- if (typeof current[part] !== "object" || current[part] === null) {
275
- current[part] = {};
289
+ if (typeof current[part] !== 'object' || current[part] === null) {
290
+ current[part] = {}
276
291
  }
277
- current = current[part];
292
+ current = current[part]
278
293
  }
279
294
  }
280
- }, "setNested");
281
- var slugifyKeys = /* @__PURE__ */ __name((obj, only = [], separator = "_") => {
282
- const slugify2 = /* @__PURE__ */ __name((key) => key.replace(/([a-z])([A-Z])/g, `$1${separator}$2`).replace(/[\s\W]+/g, separator).replace(new RegExp(`${separator}{2,}`, "g"), separator).replace(new RegExp(`^${separator}|${separator}$`, "g"), "").toLowerCase(), "slugify");
283
- let entries = Object.entries(obj);
295
+ }, 'setNested')
296
+ var slugifyKeys = /* @__PURE__ */ __name((obj, only = [], separator = '_') => {
297
+ const slugify2 = /* @__PURE__ */ __name((key) => key.replace(/([a-z])([A-Z])/g, `$1${separator}$2`).replace(/[\s\W]+/g, separator).replace(new RegExp(`${separator}{2,}`, 'g'), separator).replace(new RegExp(`^${separator}|${separator}$`, 'g'), '').toLowerCase(), 'slugify')
298
+ let entries = Object.entries(obj)
284
299
  if (only.length) {
285
- entries = entries.filter(([key]) => only.includes(key));
300
+ entries = entries.filter(([key]) => only.includes(key))
286
301
  }
287
302
  return Object.fromEntries(entries.map(([key, value]) => [
288
303
  slugify2(key),
289
304
  value
290
- ]));
291
- }, "slugifyKeys");
305
+ ]))
306
+ }, 'slugifyKeys')
292
307
 
293
308
  // src/Helpers/Str.ts
294
309
  var after = /* @__PURE__ */ __name((value, search) => {
295
- if (!search) return value;
296
- const index = value.indexOf(search);
297
- return index !== -1 ? value.slice(index + search.length) : value;
298
- }, "after");
310
+ if (!search)
311
+ return value
312
+ const index = value.indexOf(search)
313
+ return index !== -1 ? value.slice(index + search.length) : value
314
+ }, 'after')
299
315
  var afterLast = /* @__PURE__ */ __name((value, search) => {
300
- if (!search) return value;
301
- const lastIndex = value.lastIndexOf(search);
302
- return lastIndex !== -1 ? value.slice(lastIndex + search.length) : value;
303
- }, "afterLast");
316
+ if (!search)
317
+ return value
318
+ const lastIndex = value.lastIndexOf(search)
319
+ return lastIndex !== -1 ? value.slice(lastIndex + search.length) : value
320
+ }, 'afterLast')
304
321
  var before = /* @__PURE__ */ __name((value, search) => {
305
- if (!search) return value;
306
- const index = value.indexOf(search);
307
- return index !== -1 ? value.slice(0, index) : value;
308
- }, "before");
322
+ if (!search)
323
+ return value
324
+ const index = value.indexOf(search)
325
+ return index !== -1 ? value.slice(0, index) : value
326
+ }, 'before')
309
327
  var beforeLast = /* @__PURE__ */ __name((value, search) => {
310
- if (!search) return value;
311
- const lastIndex = value.lastIndexOf(search);
312
- return lastIndex !== -1 ? value.slice(0, lastIndex) : value;
313
- }, "beforeLast");
328
+ if (!search)
329
+ return value
330
+ const lastIndex = value.lastIndexOf(search)
331
+ return lastIndex !== -1 ? value.slice(0, lastIndex) : value
332
+ }, 'beforeLast')
314
333
  function capitalize(str) {
315
- if (!str) return "";
316
- return str[0].toUpperCase() + str.slice(1);
334
+ if (!str)
335
+ return ''
336
+ return str[0].toUpperCase() + str.slice(1)
317
337
  }
318
- __name(capitalize, "capitalize");
338
+ __name(capitalize, 'capitalize')
319
339
  var pluralize = /* @__PURE__ */ __name((word, count) => {
320
- if (count === 1) return word;
340
+ if (count === 1)
341
+ return word
321
342
  const irregularPlurals = {
322
- foot: "feet",
323
- child: "children",
324
- mouse: "mice",
325
- goose: "geese",
326
- person: "people",
327
- man: "men",
328
- woman: "women"
329
- };
343
+ foot: 'feet',
344
+ child: 'children',
345
+ mouse: 'mice',
346
+ goose: 'geese',
347
+ person: 'people',
348
+ man: 'men',
349
+ woman: 'women'
350
+ }
330
351
  if (word in irregularPlurals) {
331
- return irregularPlurals[word];
352
+ return irregularPlurals[word]
332
353
  }
333
- if (word.endsWith("y") && ![
334
- "a",
335
- "e",
336
- "i",
337
- "o",
338
- "u"
339
- ].includes(word[word.length - 2]?.toLowerCase() ?? "")) {
340
- return word.slice(0, -1) + "ies";
354
+ if (word.endsWith('y') && ![
355
+ 'a',
356
+ 'e',
357
+ 'i',
358
+ 'o',
359
+ 'u'
360
+ ].includes(word[word.length - 2]?.toLowerCase() ?? '')) {
361
+ return word.slice(0, -1) + 'ies'
341
362
  }
342
363
  if (/(s|ss|sh|ch|x|z)$/i.test(word)) {
343
- return word + "es";
364
+ return word + 'es'
344
365
  }
345
- return word + "s";
346
- }, "pluralize");
366
+ return word + 's'
367
+ }, 'pluralize')
347
368
  var singularize = /* @__PURE__ */ __name((word) => {
348
369
  const irregulars = {
349
- feet: "foot",
350
- children: "child",
351
- mice: "mouse",
352
- geese: "goose",
353
- people: "person",
354
- men: "man",
355
- women: "woman"
356
- };
357
- if (word in irregulars) return irregulars[word];
370
+ feet: 'foot',
371
+ children: 'child',
372
+ mice: 'mouse',
373
+ geese: 'goose',
374
+ people: 'person',
375
+ men: 'man',
376
+ women: 'woman'
377
+ }
378
+ if (word in irregulars)
379
+ return irregulars[word]
358
380
  if (/ies$/i.test(word) && word.length > 3) {
359
- return word.replace(/ies$/i, "y");
381
+ return word.replace(/ies$/i, 'y')
360
382
  }
361
383
  if (/(ches|shes|sses|xes|zes)$/i.test(word)) {
362
- return word.replace(/es$/i, "");
384
+ return word.replace(/es$/i, '')
363
385
  }
364
386
  if (/s$/i.test(word) && word.length > 1) {
365
- return word.replace(/s$/i, "");
387
+ return word.replace(/s$/i, '')
366
388
  }
367
- return word;
368
- }, "singularize");
369
- var slugify = /* @__PURE__ */ __name((str, joiner = "_") => {
370
- return str.replace(/([a-z])([A-Z])/g, `$1${joiner}$2`).replace(/[\s\W]+/g, joiner).replace(new RegExp(`${joiner}{2,}`, "g"), joiner).replace(new RegExp(`^${joiner}|${joiner}$`, "g"), "").toLowerCase();
371
- }, "slugify");
372
- var subString = /* @__PURE__ */ __name((str, len, ellipsis = "...") => {
373
- if (!str) return "";
374
- if (len <= ellipsis.length) return ellipsis;
375
- return str.length > len ? str.substring(0, len - ellipsis.length).trimEnd() + ellipsis : str;
376
- }, "subString");
389
+ return word
390
+ }, 'singularize')
391
+ var slugify = /* @__PURE__ */ __name((str, joiner = '_') => {
392
+ return str.replace(/([a-z])([A-Z])/g, `$1${joiner}$2`).replace(/[\s\W]+/g, joiner).replace(new RegExp(`${joiner}{2,}`, 'g'), joiner).replace(new RegExp(`^${joiner}|${joiner}$`, 'g'), '').toLowerCase()
393
+ }, 'slugify')
394
+ var subString = /* @__PURE__ */ __name((str, len, ellipsis = '...') => {
395
+ if (!str)
396
+ return ''
397
+ if (len <= ellipsis.length)
398
+ return ellipsis
399
+ return str.length > len ? str.substring(0, len - ellipsis.length).trimEnd() + ellipsis : str
400
+ }, 'subString')
377
401
  var substitute = /* @__PURE__ */ __name((str, data = {}, def) => {
378
- if (!str || !data) return void 0;
379
- const regex = /{\s*([a-zA-Z0-9_.]+)\s*}/g;
380
- const flattened = dot(data);
402
+ if (!str || !data)
403
+ return void 0
404
+ const regex = /{\s*([a-zA-Z0-9_.]+)\s*}/g
405
+ const flattened = dot(data)
381
406
  const out = str.replace(regex, (_, key) => {
382
- const value = flattened[key];
383
- return value !== void 0 ? String(value) : def ?? "";
384
- });
385
- return out;
386
- }, "substitute");
387
- var truncate = /* @__PURE__ */ __name((str, len = 20, suffix = "...") => {
388
- if (!str) return "";
389
- const clean = str.replace(/<[^>]+>/g, "");
390
- const truncated = clean.length > len ? clean.substring(0, len - suffix.length) + suffix : clean;
391
- return truncated.replace(/\n/g, " ").replace(new RegExp(`\\s+${suffix.replace(/\./g, "\\.")}$`), suffix);
392
- }, "truncate");
407
+ const value = flattened[key]
408
+ return value !== void 0 ? String(value) : def ?? ''
409
+ })
410
+ return out
411
+ }, 'substitute')
412
+ var truncate = /* @__PURE__ */ __name((str, len = 20, suffix = '...') => {
413
+ if (!str)
414
+ return ''
415
+ const clean = str.replace(/<[^>]+>/g, '')
416
+ const truncated = clean.length > len ? clean.substring(0, len - suffix.length) + suffix : clean
417
+ return truncated.replace(/\n/g, ' ').replace(new RegExp(`\\s+${suffix.replace(/\./g, '\\.')}$`), suffix)
418
+ }, 'truncate')
393
419
  // Annotate the CommonJS export names for ESM import in node:
394
420
  0 && (module.exports = {
395
421
  abbreviate,
@@ -416,5 +442,5 @@ var truncate = /* @__PURE__ */ __name((str, len = 20, suffix = "...") => {
416
442
  toBytes,
417
443
  toHumanTime,
418
444
  truncate
419
- });
445
+ })
420
446
  //# sourceMappingURL=index.cjs.map