@poppinss/utils 6.5.0-2 → 6.5.0-4
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/README.md +2 -0
- package/build/index.d.ts +284 -19
- package/build/index.js +372 -23
- package/build/src/json/main.d.ts +15 -3
- package/build/src/json/main.js +5 -6
- package/build/src/string/main.d.ts +121 -15
- package/build/src/string/main.js +6 -42
- package/build/src/string_builder.d.ts +60 -1
- package/build/src/string_builder.js +148 -86
- package/build/src/types.d.ts +18 -8
- package/build/src/types.js +0 -1
- package/package.json +56 -64
- package/build/src/base64.d.ts +0 -17
- package/build/src/base64.js +0 -35
- package/build/src/compose.d.ts +0 -14
- package/build/src/compose.js +0 -3
- package/build/src/define_static_property.d.ts +0 -7
- package/build/src/define_static_property.js +0 -21
- package/build/src/exception.d.ts +0 -21
- package/build/src/exception.js +0 -40
- package/build/src/exceptions/invalid_arguments_exception.d.ts +0 -5
- package/build/src/exceptions/invalid_arguments_exception.js +0 -6
- package/build/src/exceptions/runtime_exception.d.ts +0 -5
- package/build/src/exceptions/runtime_exception.js +0 -6
- package/build/src/flatten.d.ts +0 -1
- package/build/src/flatten.js +0 -4
- package/build/src/fs_import_all.d.ts +0 -3
- package/build/src/fs_import_all.js +0 -28
- package/build/src/fs_read_all.d.ts +0 -3
- package/build/src/fs_read_all.js +0 -55
- package/build/src/import_default.d.ts +0 -3
- package/build/src/import_default.js +0 -15
- package/build/src/is_script_file.d.ts +0 -1
- package/build/src/is_script_file.js +0 -12
- package/build/src/json/safe_parse.d.ts +0 -2
- package/build/src/json/safe_parse.js +0 -7
- package/build/src/json/safe_stringify.d.ts +0 -2
- package/build/src/json/safe_stringify.js +0 -18
- package/build/src/message_builder.d.ts +0 -5
- package/build/src/message_builder.js +0 -38
- package/build/src/natural_sort.d.ts +0 -1
- package/build/src/natural_sort.js +0 -3
- package/build/src/object_builder.d.ts +0 -18
- package/build/src/object_builder.js +0 -32
- package/build/src/safe_equal.d.ts +0 -7
- package/build/src/safe_equal.js +0 -14
- package/build/src/slash.d.ts +0 -1
- package/build/src/slash.js +0 -1
- package/build/src/string/bytes.d.ts +0 -6
- package/build/src/string/bytes.js +0 -12
- package/build/src/string/change_case.d.ts +0 -13
- package/build/src/string/change_case.js +0 -75
- package/build/src/string/excerpt.d.ts +0 -4
- package/build/src/string/excerpt.js +0 -10
- package/build/src/string/interpolate.d.ts +0 -1
- package/build/src/string/interpolate.js +0 -19
- package/build/src/string/milliseconds.d.ts +0 -5
- package/build/src/string/milliseconds.js +0 -16
- package/build/src/string/ordinal.d.ts +0 -1
- package/build/src/string/ordinal.js +0 -21
- package/build/src/string/pluralize.d.ts +0 -12
- package/build/src/string/pluralize.js +0 -12
- package/build/src/string/random.d.ts +0 -1
- package/build/src/string/random.js +0 -7
- package/build/src/string/seconds.d.ts +0 -5
- package/build/src/string/seconds.js +0 -16
- package/build/src/string/sentence.d.ts +0 -5
- package/build/src/string/sentence.js +0 -13
- package/build/src/string/slugify.d.ts +0 -2
- package/build/src/string/slugify.js +0 -2
- package/build/src/string/truncate.d.ts +0 -4
- package/build/src/string/truncate.js +0 -10
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { parse, format } from '@lukeed/ms';
|
|
2
|
-
export default {
|
|
3
|
-
format(seconds, long) {
|
|
4
|
-
return format(seconds * 1000, long);
|
|
5
|
-
},
|
|
6
|
-
parse(duration) {
|
|
7
|
-
if (typeof duration === 'number') {
|
|
8
|
-
return duration;
|
|
9
|
-
}
|
|
10
|
-
const milliseconds = parse(duration);
|
|
11
|
-
if (milliseconds === undefined) {
|
|
12
|
-
throw new Error(`Invalid duration expression "${duration}"`);
|
|
13
|
-
}
|
|
14
|
-
return Math.floor(milliseconds / 1000);
|
|
15
|
-
},
|
|
16
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export function sentence(values, options) {
|
|
2
|
-
if (values.length === 0) {
|
|
3
|
-
return '';
|
|
4
|
-
}
|
|
5
|
-
if (values.length === 1) {
|
|
6
|
-
return values[0];
|
|
7
|
-
}
|
|
8
|
-
if (values.length === 2) {
|
|
9
|
-
return `${values[0]}${options?.pairSeparator || ' and '}${values[1]}`;
|
|
10
|
-
}
|
|
11
|
-
const normalized = Object.assign({ separator: ', ', lastSeparator: ', and ' }, options);
|
|
12
|
-
return `${values.slice(0, -1).join(normalized.separator)}${normalized.lastSeparator}${values[values.length - 1]}`;
|
|
13
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import truncatise from 'truncatise';
|
|
2
|
-
export function truncate(sentence, charactersLimit, options) {
|
|
3
|
-
return truncatise(sentence, {
|
|
4
|
-
TruncateLength: charactersLimit,
|
|
5
|
-
Strict: options && options.completeWords === true ? false : true,
|
|
6
|
-
StripHTML: false,
|
|
7
|
-
TruncateBy: 'characters',
|
|
8
|
-
Suffix: options && options.suffix,
|
|
9
|
-
});
|
|
10
|
-
}
|