@h3ravel/support 0.4.0 → 0.5.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,25 +1,25 @@
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 src_exports = {}
22
+ var src_exports = {};
23
23
  __export(src_exports, {
24
24
  abbreviate: () => abbreviate,
25
25
  after: () => after,
@@ -45,377 +45,377 @@ __export(src_exports, {
45
45
  toBytes: () => toBytes,
46
46
  toHumanTime: () => toHumanTime,
47
47
  truncate: () => truncate
48
- })
49
- module.exports = __toCommonJS(src_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
53
  if (size <= 0)
54
- throw new Error('Chunk size must be greater than 0')
55
- const chunks = []
54
+ throw new Error("Chunk size must be greater than 0");
55
+ const chunks = [];
56
56
  for (let i = 0; i < arr.length; i += size) {
57
- chunks.push(arr.slice(i, i + size))
57
+ chunks.push(arr.slice(i, i + size));
58
58
  }
59
- return chunks
60
- }, 'chunk')
59
+ return chunks;
60
+ }, "chunk");
61
61
  var range = /* @__PURE__ */ __name((size, startAt = 0) => {
62
62
  if (size <= 0 || !Number.isFinite(size))
63
- return []
63
+ return [];
64
64
  return Array.from({
65
65
  length: size
66
- }, (_, i) => startAt + i)
67
- }, 'range')
66
+ }, (_, i) => startAt + i);
67
+ }, "range");
68
68
 
69
69
  // src/Helpers/Number.ts
70
- var abbreviate = /* @__PURE__ */ __name((value, locale = 'en-US') => {
70
+ var abbreviate = /* @__PURE__ */ __name((value, locale = "en-US") => {
71
71
  if (!value)
72
- return '0'
72
+ return "0";
73
73
  if (value < 1e3) {
74
- return new Intl.NumberFormat(locale).format(value)
74
+ return new Intl.NumberFormat(locale).format(value);
75
75
  }
76
76
  const si = [
77
77
  {
78
78
  v: 1e18,
79
- s: 'E'
79
+ s: "E"
80
80
  },
81
81
  {
82
82
  v: 1e15,
83
- s: 'P'
83
+ s: "P"
84
84
  },
85
85
  {
86
86
  v: 1e12,
87
- s: 'T'
87
+ s: "T"
88
88
  },
89
89
  {
90
90
  v: 1e9,
91
- s: 'B'
91
+ s: "B"
92
92
  },
93
93
  {
94
94
  v: 1e6,
95
- s: 'M'
95
+ s: "M"
96
96
  },
97
97
  {
98
98
  v: 1e3,
99
- s: 'K'
99
+ s: "K"
100
100
  }
101
- ]
102
- const match = si.find((scale) => value >= scale.v)
101
+ ];
102
+ const match = si.find((scale) => value >= scale.v);
103
103
  if (!match)
104
- return new Intl.NumberFormat(locale).format(value)
105
- const formatted = value / match.v
104
+ return new Intl.NumberFormat(locale).format(value);
105
+ const formatted = value / match.v;
106
106
  return new Intl.NumberFormat(locale, {
107
107
  minimumFractionDigits: 0,
108
108
  maximumFractionDigits: 2
109
- }).format(formatted) + match.s
110
- }, 'abbreviate')
109
+ }).format(formatted) + match.s;
110
+ }, "abbreviate");
111
111
  var humanize = /* @__PURE__ */ __name((num, slugify2) => {
112
112
  if (!num) {
113
- return ''
113
+ return "";
114
114
  }
115
- if (slugify2 === '-' || slugify2 === '_') {
116
- const h = humanize(num)
117
- 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;
118
118
  }
119
119
  const ones = [
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
- ]
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
+ ];
141
141
  const tens = [
142
- '',
143
- '',
144
- 'twenty',
145
- 'thirty',
146
- 'forty',
147
- 'fifty',
148
- 'sixty',
149
- 'seventy',
150
- 'eighty',
151
- 'ninety'
152
- ]
153
- const numString = num.toString()
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
154
  if (num < 0)
155
- throw new Error('Negative numbers are not supported.')
155
+ throw new Error("Negative numbers are not supported.");
156
156
  if (num === 0)
157
- return 'zero'
157
+ return "zero";
158
158
  if (num < 20) {
159
- return ones[num] ?? ''
159
+ return ones[num] ?? "";
160
160
  }
161
161
  if (numString.length === 2) {
162
- return tens[numString[0]] + ' ' + ones[numString[1]]
162
+ return tens[numString[0]] + " " + ones[numString[1]];
163
163
  }
164
164
  if (numString.length == 3) {
165
- if (numString[1] === '0' && numString[2] === '0')
166
- return ones[numString[0]] + ' hundred'
165
+ if (numString[1] === "0" && numString[2] === "0")
166
+ return ones[numString[0]] + " hundred";
167
167
  else
168
- return ones[numString[0]] + ' hundred and ' + humanize(+((numString[1] || '') + numString[2]), slugify2)
168
+ return ones[numString[0]] + " hundred and " + humanize(+((numString[1] || "") + numString[2]), slugify2);
169
169
  }
170
170
  if (numString.length === 4) {
171
- const end = +((numString[1] || '') + numString[2] + numString[3])
171
+ const end = +((numString[1] || "") + numString[2] + numString[3]);
172
172
  if (end === 0)
173
- return ones[numString[0]] + ' thousand'
173
+ return ones[numString[0]] + " thousand";
174
174
  if (end < 100)
175
- return ones[numString[0]] + ' thousand and ' + humanize(end, slugify2)
176
- return ones[numString[0]] + ' thousand ' + humanize(end, slugify2)
175
+ return ones[numString[0]] + " thousand and " + humanize(end, slugify2);
176
+ return ones[numString[0]] + " thousand " + humanize(end, slugify2);
177
177
  }
178
- return num
179
- }, 'humanize')
178
+ return num;
179
+ }, "humanize");
180
180
  var toBytes = /* @__PURE__ */ __name((bytes, decimals = 2, bits = false) => {
181
181
  if (!bytes || isNaN(bytes)) {
182
- return bits ? '0 B' : '0 Bytes'
182
+ return bits ? "0 B" : "0 Bytes";
183
183
  }
184
- const base = bits ? 1e3 : 1024
185
- const dm = decimals < 0 ? 0 : decimals
184
+ const base = bits ? 1e3 : 1024;
185
+ const dm = decimals < 0 ? 0 : decimals;
186
186
  const sizes = bits ? [
187
- 'B',
188
- 'KB',
189
- 'MB',
190
- 'GB',
191
- 'TB',
192
- 'PB',
193
- 'EB',
194
- 'ZB',
195
- 'YB'
187
+ "B",
188
+ "KB",
189
+ "MB",
190
+ "GB",
191
+ "TB",
192
+ "PB",
193
+ "EB",
194
+ "ZB",
195
+ "YB"
196
196
  ] : [
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')
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");
211
211
  var toHumanTime = /* @__PURE__ */ __name((seconds = 0, worded = false) => {
212
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)
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);
217
217
  if (worded) {
218
- const parts = []
218
+ const parts = [];
219
219
  if (hours)
220
- parts.push(`${hours}hr`)
220
+ parts.push(`${hours}hr`);
221
221
  if (minutes)
222
- parts.push(`${minutes}min`)
222
+ parts.push(`${minutes}min`);
223
223
  if (secs || !hours && !minutes)
224
- parts.push(`${secs}sec`)
225
- return parts.join(' ')
224
+ parts.push(`${secs}sec`);
225
+ return parts.join(" ");
226
226
  }
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')
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");
232
232
 
233
233
  // src/Helpers/Obj.ts
234
234
  var dot = /* @__PURE__ */ __name((obj) => {
235
- const result = {}
236
- const recurse = /* @__PURE__ */ __name((o, prefix = '') => {
235
+ const result = {};
236
+ const recurse = /* @__PURE__ */ __name((o, prefix = "") => {
237
237
  for (const [key, value] of Object.entries(o)) {
238
- const newKey = prefix ? `${prefix}.${key}` : key
239
- if (value && typeof value === 'object' && !Array.isArray(value)) {
240
- recurse(value, newKey)
238
+ const newKey = prefix ? `${prefix}.${key}` : key;
239
+ if (value && typeof value === "object" && !Array.isArray(value)) {
240
+ recurse(value, newKey);
241
241
  } else {
242
- result[newKey] = value
242
+ result[newKey] = value;
243
243
  }
244
244
  }
245
- }, 'recurse')
246
- recurse(obj)
247
- return result
248
- }, 'dot')
245
+ }, "recurse");
246
+ recurse(obj);
247
+ return result;
248
+ }, "dot");
249
249
  var extractProperties = /* @__PURE__ */ __name((obj, keys = []) => {
250
250
  return Object.fromEntries(keys.map((key) => [
251
251
  key,
252
252
  obj[key]
253
- ]))
254
- }, 'extractProperties')
253
+ ]));
254
+ }, "extractProperties");
255
255
  var getValue = /* @__PURE__ */ __name((key, item) => {
256
256
  if (Array.isArray(key)) {
257
- const [parent, child] = key
257
+ const [parent, child] = key;
258
258
  if (child !== void 0) {
259
- return String(item?.[parent]?.[child] ?? item?.[parent] ?? `${String(parent)}.${String(child)}`)
259
+ return String(item?.[parent]?.[child] ?? item?.[parent] ?? `${String(parent)}.${String(child)}`);
260
260
  }
261
- return String(item?.[parent] ?? parent)
261
+ return String(item?.[parent] ?? parent);
262
262
  }
263
- return String(item?.[key] ?? key)
264
- }, 'getValue')
263
+ return String(item?.[key] ?? key);
264
+ }, "getValue");
265
265
  var modObj = /* @__PURE__ */ __name((obj, callback) => {
266
266
  return Object.fromEntries(Object.entries(obj).map(([key, value]) => callback([
267
267
  key,
268
268
  value
269
- ])))
270
- }, 'modObj')
269
+ ])));
270
+ }, "modObj");
271
271
  function safeDot(data, key) {
272
272
  if (!key)
273
- return data
274
- return key.split('.').reduce((acc, k) => acc?.[k], data)
273
+ return data;
274
+ return key.split(".").reduce((acc, k) => acc?.[k], data);
275
275
  }
276
- __name(safeDot, 'safeDot')
276
+ __name(safeDot, "safeDot");
277
277
  var setNested = /* @__PURE__ */ __name((obj, key, value) => {
278
- if (!key.includes('.')) {
279
- obj[key] = value
280
- return
278
+ if (!key.includes(".")) {
279
+ obj[key] = value;
280
+ return;
281
281
  }
282
- const parts = key.split('.')
283
- let current = obj
282
+ const parts = key.split(".");
283
+ let current = obj;
284
284
  for (let i = 0; i < parts.length; i++) {
285
- const part = parts[i]
285
+ const part = parts[i];
286
286
  if (i === parts.length - 1) {
287
- current[part] = value
287
+ current[part] = value;
288
288
  } else {
289
- if (typeof current[part] !== 'object' || current[part] === null) {
290
- current[part] = {}
289
+ if (typeof current[part] !== "object" || current[part] === null) {
290
+ current[part] = {};
291
291
  }
292
- current = current[part]
292
+ current = current[part];
293
293
  }
294
294
  }
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)
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);
299
299
  if (only.length) {
300
- entries = entries.filter(([key]) => only.includes(key))
300
+ entries = entries.filter(([key]) => only.includes(key));
301
301
  }
302
302
  return Object.fromEntries(entries.map(([key, value]) => [
303
303
  slugify2(key),
304
304
  value
305
- ]))
306
- }, 'slugifyKeys')
305
+ ]));
306
+ }, "slugifyKeys");
307
307
 
308
308
  // src/Helpers/Str.ts
309
309
  var after = /* @__PURE__ */ __name((value, search) => {
310
310
  if (!search)
311
- return value
312
- const index = value.indexOf(search)
313
- return index !== -1 ? value.slice(index + search.length) : value
314
- }, 'after')
311
+ return value;
312
+ const index = value.indexOf(search);
313
+ return index !== -1 ? value.slice(index + search.length) : value;
314
+ }, "after");
315
315
  var afterLast = /* @__PURE__ */ __name((value, search) => {
316
316
  if (!search)
317
- return value
318
- const lastIndex = value.lastIndexOf(search)
319
- return lastIndex !== -1 ? value.slice(lastIndex + search.length) : value
320
- }, 'afterLast')
317
+ return value;
318
+ const lastIndex = value.lastIndexOf(search);
319
+ return lastIndex !== -1 ? value.slice(lastIndex + search.length) : value;
320
+ }, "afterLast");
321
321
  var before = /* @__PURE__ */ __name((value, search) => {
322
322
  if (!search)
323
- return value
324
- const index = value.indexOf(search)
325
- return index !== -1 ? value.slice(0, index) : value
326
- }, 'before')
323
+ return value;
324
+ const index = value.indexOf(search);
325
+ return index !== -1 ? value.slice(0, index) : value;
326
+ }, "before");
327
327
  var beforeLast = /* @__PURE__ */ __name((value, search) => {
328
328
  if (!search)
329
- return value
330
- const lastIndex = value.lastIndexOf(search)
331
- return lastIndex !== -1 ? value.slice(0, lastIndex) : value
332
- }, 'beforeLast')
329
+ return value;
330
+ const lastIndex = value.lastIndexOf(search);
331
+ return lastIndex !== -1 ? value.slice(0, lastIndex) : value;
332
+ }, "beforeLast");
333
333
  function capitalize(str) {
334
334
  if (!str)
335
- return ''
336
- return str[0].toUpperCase() + str.slice(1)
335
+ return "";
336
+ return str[0].toUpperCase() + str.slice(1);
337
337
  }
338
- __name(capitalize, 'capitalize')
338
+ __name(capitalize, "capitalize");
339
339
  var pluralize = /* @__PURE__ */ __name((word, count) => {
340
340
  if (count === 1)
341
- return word
341
+ return word;
342
342
  const irregularPlurals = {
343
- foot: 'feet',
344
- child: 'children',
345
- mouse: 'mice',
346
- goose: 'geese',
347
- person: 'people',
348
- man: 'men',
349
- woman: 'women'
350
- }
343
+ foot: "feet",
344
+ child: "children",
345
+ mouse: "mice",
346
+ goose: "geese",
347
+ person: "people",
348
+ man: "men",
349
+ woman: "women"
350
+ };
351
351
  if (word in irregularPlurals) {
352
- return irregularPlurals[word]
352
+ return irregularPlurals[word];
353
353
  }
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'
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";
362
362
  }
363
363
  if (/(s|ss|sh|ch|x|z)$/i.test(word)) {
364
- return word + 'es'
364
+ return word + "es";
365
365
  }
366
- return word + 's'
367
- }, 'pluralize')
366
+ return word + "s";
367
+ }, "pluralize");
368
368
  var singularize = /* @__PURE__ */ __name((word) => {
369
369
  const irregulars = {
370
- feet: 'foot',
371
- children: 'child',
372
- mice: 'mouse',
373
- geese: 'goose',
374
- people: 'person',
375
- men: 'man',
376
- women: 'woman'
377
- }
370
+ feet: "foot",
371
+ children: "child",
372
+ mice: "mouse",
373
+ geese: "goose",
374
+ people: "person",
375
+ men: "man",
376
+ women: "woman"
377
+ };
378
378
  if (word in irregulars)
379
- return irregulars[word]
379
+ return irregulars[word];
380
380
  if (/ies$/i.test(word) && word.length > 3) {
381
- return word.replace(/ies$/i, 'y')
381
+ return word.replace(/ies$/i, "y");
382
382
  }
383
383
  if (/(ches|shes|sses|xes|zes)$/i.test(word)) {
384
- return word.replace(/es$/i, '')
384
+ return word.replace(/es$/i, "");
385
385
  }
386
386
  if (/s$/i.test(word) && word.length > 1) {
387
- return word.replace(/s$/i, '')
387
+ return word.replace(/s$/i, "");
388
388
  }
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 = '...') => {
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
395
  if (!str)
396
- return ''
396
+ return "";
397
397
  if (len <= ellipsis.length)
398
- return ellipsis
399
- return str.length > len ? str.substring(0, len - ellipsis.length).trimEnd() + ellipsis : str
400
- }, 'subString')
398
+ return ellipsis;
399
+ return str.length > len ? str.substring(0, len - ellipsis.length).trimEnd() + ellipsis : str;
400
+ }, "subString");
401
401
  var substitute = /* @__PURE__ */ __name((str, data = {}, def) => {
402
402
  if (!str || !data)
403
- return void 0
404
- const regex = /{\s*([a-zA-Z0-9_.]+)\s*}/g
405
- const flattened = dot(data)
403
+ return void 0;
404
+ const regex = /{\s*([a-zA-Z0-9_.]+)\s*}/g;
405
+ const flattened = dot(data);
406
406
  const out = str.replace(regex, (_, key) => {
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 = '...') => {
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
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')
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");
419
419
  // Annotate the CommonJS export names for ESM import in node:
420
420
  0 && (module.exports = {
421
421
  abbreviate,
@@ -442,5 +442,5 @@ var truncate = /* @__PURE__ */ __name((str, len = 20, suffix = '...') => {
442
442
  toBytes,
443
443
  toHumanTime,
444
444
  truncate
445
- })
445
+ });
446
446
  //# sourceMappingURL=index.cjs.map