@poppinss/utils 6.5.0 → 6.5.1
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/build/{chunk-XHQBV7AF.js → chunk-IOBSMUFC.js} +1 -0
- package/build/chunk-IOBSMUFC.js.map +1 -0
- package/build/{chunk-OKRMWJO4.js → chunk-K76IL3UP.js} +2 -1
- package/build/chunk-K76IL3UP.js.map +1 -0
- package/build/{chunk-PWRXO3NF.js → chunk-NKGAOHNN.js} +1 -0
- package/build/chunk-NKGAOHNN.js.map +1 -0
- package/build/index.d.ts +19 -278
- package/build/index.js +3 -2
- package/build/index.js.map +1 -0
- package/build/src/assert.d.ts +3 -5
- package/build/src/assert.js +1 -0
- package/build/src/assert.js.map +1 -0
- package/build/src/base64.d.ts +33 -0
- package/build/src/compose.d.ts +19 -0
- package/build/src/define_static_property.d.ts +10 -0
- package/build/src/exception.d.ts +52 -0
- package/build/src/exceptions/invalid_arguments_exception.d.ts +5 -0
- package/build/src/exceptions/runtime_exception.d.ts +5 -0
- package/build/src/flatten.d.ts +4 -0
- package/build/src/fs_import_all.d.ts +20 -0
- package/build/src/fs_read_all.d.ts +20 -0
- package/build/src/import_default.d.ts +6 -0
- package/build/src/is_script_file.d.ts +5 -0
- package/build/src/json/main.d.ts +3 -15
- package/build/src/json/main.js +2 -1
- package/build/src/json/main.js.map +1 -0
- package/build/src/json/safe_parse.d.ts +5 -0
- package/build/src/json/safe_stringify.d.ts +6 -0
- package/build/src/message_builder.d.ts +17 -0
- package/build/src/natural_sort.d.ts +4 -0
- package/build/src/object_builder.d.ts +58 -0
- package/build/src/safe_equal.d.ts +11 -0
- package/build/src/slash.d.ts +1 -0
- package/build/src/string/bytes.d.ts +11 -0
- package/build/src/string/change_case.d.ts +42 -0
- package/build/src/string/excerpt.d.ts +11 -0
- package/build/src/string/interpolate.d.ts +8 -0
- package/build/src/string/main.d.ts +15 -118
- package/build/src/string/main.js +3 -2
- package/build/src/string/main.js.map +1 -0
- package/build/src/string/milliseconds.d.ts +9 -0
- package/build/src/string/ordinal.d.ts +4 -0
- package/build/src/string/pluralize.d.ts +16 -0
- package/build/src/string/random.d.ts +4 -0
- package/build/src/string/seconds.d.ts +9 -0
- package/build/src/string/sentence.d.ts +8 -0
- package/build/src/string/slugify.d.ts +6 -0
- package/build/src/string/truncate.d.ts +10 -0
- package/build/src/string_builder.d.ts +1 -3
- package/build/src/string_builder.js +3 -2
- package/build/src/string_builder.js.map +1 -0
- package/build/src/types.d.ts +9 -10
- package/build/src/types.js +1 -0
- package/build/src/types.js.map +1 -0
- package/package.json +17 -12
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
import { ImportAllFilesOptions } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Returns an array of file paths from the given location. You can
|
|
5
|
+
* optionally filter and sort files by passing relevant options
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* await fsReadAll(new URL('./', import.meta.url))
|
|
9
|
+
*
|
|
10
|
+
* await fsReadAll(new URL('./', import.meta.url), {
|
|
11
|
+
* filter: (filePath) => filePath.endsWith('.js')
|
|
12
|
+
* })
|
|
13
|
+
|
|
14
|
+
* await fsReadAll(new URL('./', import.meta.url), {
|
|
15
|
+
* absolute: true,
|
|
16
|
+
* unixPaths: true
|
|
17
|
+
* })
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare function fsImportAll(location: string | URL, options?: ImportAllFilesOptions): Promise<any>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
import { ReadAllFilesOptions } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Returns an array of file paths from the given location. You can
|
|
5
|
+
* optionally filter and sort files by passing relevant options
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* await fsReadAll(new URL('./', import.meta.url))
|
|
9
|
+
*
|
|
10
|
+
* await fsReadAll(new URL('./', import.meta.url), {
|
|
11
|
+
* filter: (filePath) => filePath.endsWith('.js')
|
|
12
|
+
* })
|
|
13
|
+
|
|
14
|
+
* await fsReadAll(new URL('./', import.meta.url), {
|
|
15
|
+
* absolute: true,
|
|
16
|
+
* unixPaths: true
|
|
17
|
+
* })
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare function fsReadAll(location: string | URL, options?: ReadAllFilesOptions): Promise<string[]>;
|
package/build/src/json/main.d.ts
CHANGED
|
@@ -1,19 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* A drop-in replacement for JSON.parse with prototype poisoning protection.
|
|
5
|
-
*/
|
|
6
|
-
declare function safeParse(jsonString: string, reviver?: JSONReviver): any;
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* String Javascript values to a JSON string. Handles circular
|
|
10
|
-
* references and bigints
|
|
11
|
-
*/
|
|
12
|
-
declare function safeStringify(value: any, replacer?: JSONReplacer, space?: string | number): string | undefined;
|
|
13
|
-
|
|
1
|
+
import { safeParse } from './safe_parse.js';
|
|
2
|
+
import { safeStringify } from './safe_stringify.js';
|
|
14
3
|
declare const json: {
|
|
15
4
|
safeParse: typeof safeParse;
|
|
16
5
|
safeStringify: typeof safeStringify;
|
|
17
6
|
};
|
|
18
|
-
|
|
19
|
-
export { json as default };
|
|
7
|
+
export default json;
|
package/build/src/json/main.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Message builder exposes an API to "JSON.stringify" values by
|
|
3
|
+
* encoding purpose and expiry date inside them.
|
|
4
|
+
*
|
|
5
|
+
* The return value must be further encrypted to prevent tempering.
|
|
6
|
+
*/
|
|
7
|
+
export declare class MessageBuilder {
|
|
8
|
+
#private;
|
|
9
|
+
/**
|
|
10
|
+
* Builds a message by encoding expiry date and purpose inside it.
|
|
11
|
+
*/
|
|
12
|
+
build(message: any, expiresIn?: string | number, purpose?: string): string;
|
|
13
|
+
/**
|
|
14
|
+
* Verifies the message for expiry and purpose.
|
|
15
|
+
*/
|
|
16
|
+
verify<T extends any>(message: any, purpose?: string): null | T;
|
|
17
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { OmitProperties } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* A simple class to build an object incrementally. It is helpful when you
|
|
4
|
+
* want to add properties to the object conditionally.
|
|
5
|
+
*
|
|
6
|
+
* Instead of writing
|
|
7
|
+
* ```
|
|
8
|
+
* const obj = {
|
|
9
|
+
* ...(user.id ? { id: user.id } : {}),
|
|
10
|
+
* ...(user.firstName && user.lastName ? { name: `${user.firstName} ${user.lastName}` } : {}),
|
|
11
|
+
* }
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* You can write
|
|
15
|
+
*
|
|
16
|
+
* const obj = new ObjectBuilder()
|
|
17
|
+
* .add('id', user.id)
|
|
18
|
+
* .add(
|
|
19
|
+
* 'fullName',
|
|
20
|
+
* user.firstName && user.lastName ? `${user.firstName} ${user.lastName}` : undefined
|
|
21
|
+
* )
|
|
22
|
+
* .toObject()
|
|
23
|
+
*/
|
|
24
|
+
export declare class ObjectBuilder<ReturnType extends Record<string, any>, IgnoreNull extends boolean = false> {
|
|
25
|
+
#private;
|
|
26
|
+
values: ReturnType;
|
|
27
|
+
constructor(initialValue: ReturnType, ignoreNull?: IgnoreNull);
|
|
28
|
+
/**
|
|
29
|
+
* Add a key-value pair to the object
|
|
30
|
+
*
|
|
31
|
+
* - Undefined values are ignored
|
|
32
|
+
* - Null values are ignored, when `ignoreNull` is set to true
|
|
33
|
+
*/
|
|
34
|
+
add<Prop extends string>(key: Prop, value: undefined): this;
|
|
35
|
+
add<Prop extends string, Value>(key: Prop, value: Value): ObjectBuilder<ReturnType & {
|
|
36
|
+
[P in Prop]: Value;
|
|
37
|
+
}, IgnoreNull>;
|
|
38
|
+
/**
|
|
39
|
+
* Remove key from the object
|
|
40
|
+
*/
|
|
41
|
+
remove<K extends keyof ReturnType>(key: K): this;
|
|
42
|
+
/**
|
|
43
|
+
* Find if a value exists
|
|
44
|
+
*/
|
|
45
|
+
has<K extends keyof ReturnType>(key: K): boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Get the existing value for a given key
|
|
48
|
+
*/
|
|
49
|
+
get<K extends keyof ReturnType>(key: K): ReturnType[K];
|
|
50
|
+
/**
|
|
51
|
+
* Get the underlying constructed object
|
|
52
|
+
*/
|
|
53
|
+
toObject(): IgnoreNull extends true ? {
|
|
54
|
+
[K in keyof OmitProperties<ReturnType, null>]: ReturnType[K];
|
|
55
|
+
} : {
|
|
56
|
+
[K in keyof ReturnType]: ReturnType[K];
|
|
57
|
+
};
|
|
58
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
type BufferSafeValue = ArrayBuffer | SharedArrayBuffer | number[] | string | {
|
|
2
|
+
valueOf(): string | object;
|
|
3
|
+
} | {
|
|
4
|
+
[Symbol.toPrimitive](hint: 'string'): string;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Compare two values to see if they are equal. The comparison is done in
|
|
8
|
+
* a way to avoid timing-attacks.
|
|
9
|
+
*/
|
|
10
|
+
export declare function safeEqual<T extends BufferSafeValue, U extends BufferSafeValue>(trustedValue: T, userInput: U): boolean;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as slash } from 'slash';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { BytesOptions } from 'bytes';
|
|
2
|
+
declare const _default: {
|
|
3
|
+
format(valueInBytes: number, options?: BytesOptions): string;
|
|
4
|
+
/**
|
|
5
|
+
* Parse the unit expression to bytes. If the unit value
|
|
6
|
+
* is a number, then it will be returned as it is considering
|
|
7
|
+
* it is already in bytes.
|
|
8
|
+
*/
|
|
9
|
+
parse(unit: string | number): number;
|
|
10
|
+
};
|
|
11
|
+
export default _default;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The method is a copy/paste from the "title-case" package. They have
|
|
3
|
+
* a dependency on "tslib", which I don't want.
|
|
4
|
+
*/
|
|
5
|
+
export declare function titleCase(input: string): string;
|
|
6
|
+
/**
|
|
7
|
+
* Convert string to camelcase
|
|
8
|
+
*/
|
|
9
|
+
export declare function camelCase(value: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* Convert string to snakecase
|
|
12
|
+
*/
|
|
13
|
+
export declare function snakeCase(value: string): string;
|
|
14
|
+
/**
|
|
15
|
+
* Convert string to dashcase
|
|
16
|
+
*/
|
|
17
|
+
export declare function dashCase(value: string, options?: {
|
|
18
|
+
capitalize?: boolean;
|
|
19
|
+
}): string;
|
|
20
|
+
/**
|
|
21
|
+
* Convert string to pascal case
|
|
22
|
+
*/
|
|
23
|
+
export declare function pascalCase(value: string): string;
|
|
24
|
+
/**
|
|
25
|
+
* Convert string to capital case
|
|
26
|
+
*/
|
|
27
|
+
export declare function capitalCase(value: string): string;
|
|
28
|
+
/**
|
|
29
|
+
* Convert string to sentence case
|
|
30
|
+
*/
|
|
31
|
+
export declare function sentenceCase(value: string): string;
|
|
32
|
+
/**
|
|
33
|
+
* Convert string to dot case
|
|
34
|
+
*/
|
|
35
|
+
export declare function dotCase(value: string, options?: {
|
|
36
|
+
lowerCase?: boolean;
|
|
37
|
+
}): string;
|
|
38
|
+
/**
|
|
39
|
+
* Remove all sort of casing from the string. Copy-pasted from
|
|
40
|
+
* "no-case" package with slight modifications.
|
|
41
|
+
*/
|
|
42
|
+
export declare function noCase(value: string, transform?: (part: string, index: number, parts: string[]) => string): string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Truncate a sentence to be under a certain characters limit and strip
|
|
3
|
+
* out HTML tags from it.
|
|
4
|
+
*
|
|
5
|
+
* Optionally, you can force the truncate logic to complete words, which
|
|
6
|
+
* may exceed the defined characters limit.
|
|
7
|
+
*/
|
|
8
|
+
export declare function excerpt(sentence: string, charactersLimit: number, options?: {
|
|
9
|
+
completeWords?: boolean;
|
|
10
|
+
suffix?: string;
|
|
11
|
+
}): string;
|
|
@@ -1,113 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Truncate a sentence to be under a certain characters limit and strip
|
|
12
|
-
* out HTML tags from it.
|
|
13
|
-
*
|
|
14
|
-
* Optionally, you can force the truncate logic to complete words, which
|
|
15
|
-
* may exceed the defined characters limit.
|
|
16
|
-
*/
|
|
17
|
-
declare function excerpt(sentence: string, charactersLimit: number, options?: {
|
|
18
|
-
completeWords?: boolean;
|
|
19
|
-
suffix?: string;
|
|
20
|
-
}): string;
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Ordinalize a give number or string
|
|
24
|
-
*/
|
|
25
|
-
declare function ordinal(value: string | number): string;
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Truncate a sentence to be under a certain characters limit.
|
|
29
|
-
*
|
|
30
|
-
* Optionally, you can force the truncate logic to complete words, which
|
|
31
|
-
* may exceed the defined characters limit.
|
|
32
|
-
*/
|
|
33
|
-
declare function truncate(sentence: string, charactersLimit: number, options?: {
|
|
34
|
-
completeWords?: boolean;
|
|
35
|
-
suffix?: string;
|
|
36
|
-
}): string;
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Convert an array of values to a sentence.
|
|
40
|
-
*/
|
|
41
|
-
declare function sentence(values: any[], options?: {
|
|
42
|
-
separator?: string;
|
|
43
|
-
pairSeparator?: string;
|
|
44
|
-
lastSeparator?: string;
|
|
45
|
-
}): string;
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* A simple function interpolate values inside curly braces.
|
|
49
|
-
*
|
|
50
|
-
* ```
|
|
51
|
-
* interpolate('hello {{ username }}', { username: 'virk' })
|
|
52
|
-
* ```
|
|
53
|
-
*/
|
|
54
|
-
declare function interpolate(input: string, data: any): string;
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Pluralize a word based upon the count. The method returns the
|
|
58
|
-
* singular form when count is 1.
|
|
59
|
-
*/
|
|
60
|
-
declare function pluralize(word: string, count?: number, inclusive?: boolean): string;
|
|
61
|
-
declare namespace pluralize {
|
|
62
|
-
var addPluralRule: typeof pluralizePkg.addPluralRule;
|
|
63
|
-
var addSingularRule: typeof pluralizePkg.addSingularRule;
|
|
64
|
-
var addIrregularRule: typeof pluralizePkg.addIrregularRule;
|
|
65
|
-
var addUncountableRule: typeof pluralizePkg.addUncountableRule;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* The method is a copy/paste from the "title-case" package. They have
|
|
70
|
-
* a dependency on "tslib", which I don't want.
|
|
71
|
-
*/
|
|
72
|
-
declare function titleCase(input: string): string;
|
|
73
|
-
/**
|
|
74
|
-
* Convert string to camelcase
|
|
75
|
-
*/
|
|
76
|
-
declare function camelCase(value: string): string;
|
|
77
|
-
/**
|
|
78
|
-
* Convert string to snakecase
|
|
79
|
-
*/
|
|
80
|
-
declare function snakeCase(value: string): string;
|
|
81
|
-
/**
|
|
82
|
-
* Convert string to dashcase
|
|
83
|
-
*/
|
|
84
|
-
declare function dashCase(value: string, options?: {
|
|
85
|
-
capitalize?: boolean;
|
|
86
|
-
}): string;
|
|
87
|
-
/**
|
|
88
|
-
* Convert string to pascal case
|
|
89
|
-
*/
|
|
90
|
-
declare function pascalCase(value: string): string;
|
|
91
|
-
/**
|
|
92
|
-
* Convert string to capital case
|
|
93
|
-
*/
|
|
94
|
-
declare function capitalCase(value: string): string;
|
|
95
|
-
/**
|
|
96
|
-
* Convert string to sentence case
|
|
97
|
-
*/
|
|
98
|
-
declare function sentenceCase(value: string): string;
|
|
99
|
-
/**
|
|
100
|
-
* Convert string to dot case
|
|
101
|
-
*/
|
|
102
|
-
declare function dotCase(value: string, options?: {
|
|
103
|
-
lowerCase?: boolean;
|
|
104
|
-
}): string;
|
|
105
|
-
/**
|
|
106
|
-
* Remove all sort of casing from the string. Copy-pasted from
|
|
107
|
-
* "no-case" package with slight modifications.
|
|
108
|
-
*/
|
|
109
|
-
declare function noCase(value: string, transform?: (part: string, index: number, parts: string[]) => string): string;
|
|
110
|
-
|
|
1
|
+
import { random } from './random.js';
|
|
2
|
+
import { excerpt } from './excerpt.js';
|
|
3
|
+
import { ordinal } from './ordinal.js';
|
|
4
|
+
import { truncate } from './truncate.js';
|
|
5
|
+
import { sentence } from './sentence.js';
|
|
6
|
+
import { interpolate } from './interpolate.js';
|
|
7
|
+
import { pluralize } from './pluralize.js';
|
|
8
|
+
import { noCase, dotCase, dashCase, camelCase, snakeCase, titleCase, pascalCase, capitalCase, sentenceCase } from './change_case.js';
|
|
111
9
|
/**
|
|
112
10
|
* Condense multiple whitespaces from a string
|
|
113
11
|
*/
|
|
@@ -115,13 +13,13 @@ declare function condenseWhitespace(value: string): string;
|
|
|
115
13
|
declare const string: {
|
|
116
14
|
excerpt: typeof excerpt;
|
|
117
15
|
truncate: typeof truncate;
|
|
118
|
-
slug: typeof slugify.default;
|
|
16
|
+
slug: typeof import("slugify").default;
|
|
119
17
|
interpolate: typeof interpolate;
|
|
120
|
-
plural: typeof pluralize.plural;
|
|
18
|
+
plural: typeof import("pluralize").plural;
|
|
121
19
|
pluralize: typeof pluralize;
|
|
122
|
-
singular: typeof pluralize.singular;
|
|
123
|
-
isPlural: typeof pluralize.isPlural;
|
|
124
|
-
isSingular: typeof pluralize.isSingular;
|
|
20
|
+
singular: typeof import("pluralize").singular;
|
|
21
|
+
isPlural: typeof import("pluralize").isPlural;
|
|
22
|
+
isSingular: typeof import("pluralize").isSingular;
|
|
125
23
|
camelCase: typeof camelCase;
|
|
126
24
|
capitalCase: typeof capitalCase;
|
|
127
25
|
dashCase: typeof dashCase;
|
|
@@ -143,10 +41,9 @@ declare const string: {
|
|
|
143
41
|
parse(duration: string | number): number;
|
|
144
42
|
};
|
|
145
43
|
bytes: {
|
|
146
|
-
format(valueInBytes: number, options?: bytes.BytesOptions | undefined): string;
|
|
44
|
+
format(valueInBytes: number, options?: import("bytes").BytesOptions | undefined): string;
|
|
147
45
|
parse(unit: string | number): number;
|
|
148
46
|
};
|
|
149
47
|
ordinal: typeof ordinal;
|
|
150
48
|
};
|
|
151
|
-
|
|
152
|
-
export { string as default };
|
|
49
|
+
export default string;
|
package/build/src/string/main.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
format(milliseconds: number, long?: boolean): string;
|
|
3
|
+
/**
|
|
4
|
+
* Parse time expression string to milliseconds. The number value
|
|
5
|
+
* is returned as it is, considering it is already in milliseconds
|
|
6
|
+
*/
|
|
7
|
+
parse(duration: string | number): number;
|
|
8
|
+
};
|
|
9
|
+
export default _default;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { default as pluralizePkg } from 'pluralize';
|
|
2
|
+
/**
|
|
3
|
+
* Pluralize a word based upon the count. The method returns the
|
|
4
|
+
* singular form when count is 1.
|
|
5
|
+
*/
|
|
6
|
+
export declare function pluralize(word: string, count?: number, inclusive?: boolean): string;
|
|
7
|
+
export declare namespace pluralize {
|
|
8
|
+
var addPluralRule: typeof pluralizePkg.addPluralRule;
|
|
9
|
+
var addSingularRule: typeof pluralizePkg.addSingularRule;
|
|
10
|
+
var addIrregularRule: typeof pluralizePkg.addIrregularRule;
|
|
11
|
+
var addUncountableRule: typeof pluralizePkg.addUncountableRule;
|
|
12
|
+
}
|
|
13
|
+
export declare const plural: typeof pluralizePkg.plural;
|
|
14
|
+
export declare const singular: typeof pluralizePkg.singular;
|
|
15
|
+
export declare const isPlural: typeof pluralizePkg.isPlural;
|
|
16
|
+
export declare const isSingular: typeof pluralizePkg.isSingular;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
format(seconds: number, long?: boolean): string;
|
|
3
|
+
/**
|
|
4
|
+
* Parse time expression string to seconds. The number value
|
|
5
|
+
* is returned as it is, considering it is already in seconds
|
|
6
|
+
*/
|
|
7
|
+
parse(duration: string | number): number;
|
|
8
|
+
};
|
|
9
|
+
export default _default;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Truncate a sentence to be under a certain characters limit.
|
|
3
|
+
*
|
|
4
|
+
* Optionally, you can force the truncate logic to complete words, which
|
|
5
|
+
* may exceed the defined characters limit.
|
|
6
|
+
*/
|
|
7
|
+
export declare function truncate(sentence: string, charactersLimit: number, options?: {
|
|
8
|
+
completeWords?: boolean;
|
|
9
|
+
suffix?: string;
|
|
10
|
+
}): string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* String builder to transform the string using the fluent API
|
|
3
3
|
*/
|
|
4
|
-
|
|
4
|
+
export default class StringBuilder {
|
|
5
5
|
#private;
|
|
6
6
|
constructor(value: string | StringBuilder);
|
|
7
7
|
/**
|
|
@@ -78,5 +78,3 @@ declare class StringBuilder {
|
|
|
78
78
|
ext(extension: string): this;
|
|
79
79
|
toString(): string;
|
|
80
80
|
}
|
|
81
|
-
|
|
82
|
-
export { StringBuilder as default };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
main_default
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
3
|
+
} from "../chunk-K76IL3UP.js";
|
|
4
|
+
import "../chunk-NKGAOHNN.js";
|
|
5
5
|
|
|
6
6
|
// src/string_builder.ts
|
|
7
7
|
import { extname } from "node:path";
|
|
@@ -146,3 +146,4 @@ var StringBuilder = class {
|
|
|
146
146
|
export {
|
|
147
147
|
StringBuilder as default
|
|
148
148
|
};
|
|
149
|
+
//# sourceMappingURL=string_builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/string_builder.ts"],"sourcesContent":["/*\n * @poppinss/utils\n *\n * (c) Poppinss\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport { extname } from 'node:path'\nimport string from './string/main.js'\n\n/**\n * String builder to transform the string using the fluent API\n */\nexport default class StringBuilder {\n #value: string\n\n constructor(value: string | StringBuilder) {\n this.#value = typeof value === 'string' ? value : value.toString()\n }\n\n /**\n * Applies dash case transformation\n */\n dashCase(): this {\n this.#value = string.dashCase(this.#value)\n return this\n }\n\n /**\n * Applies dot case transformation\n */\n dotCase(): this {\n this.#value = string.dotCase(this.#value)\n return this\n }\n\n /**\n * Applies snake case transformation\n */\n snakeCase(): this {\n this.#value = string.snakeCase(this.#value)\n return this\n }\n\n /**\n * Applies pascal case transformation\n */\n pascalCase(): this {\n this.#value = string.pascalCase(this.#value)\n return this\n }\n\n /**\n * Applies camelcase case transformation\n */\n camelCase(): this {\n this.#value = string.camelCase(this.#value)\n return this\n }\n\n /**\n * Applies capital case transformation\n */\n capitalCase(): this {\n this.#value = string.capitalCase(this.#value)\n return this\n }\n\n /**\n * Applies title case transformation\n */\n titleCase(): this {\n this.#value = string.titleCase(this.#value)\n return this\n }\n\n /**\n * Applies sentence case transformation\n */\n sentenceCase(): this {\n this.#value = string.sentenceCase(this.#value)\n return this\n }\n\n /**\n * Removes all sorts of casing from the string\n */\n noCase(): this {\n this.#value = string.noCase(this.#value)\n return this\n }\n\n /**\n * Converts value to its plural form\n */\n plural(): this {\n this.#value = string.pluralize(this.#value)\n return this\n }\n\n /**\n * Converts value to its singular form\n */\n singular(): this {\n this.#value = string.singular(this.#value)\n return this\n }\n\n /**\n * Converts value to a URL friendly slug\n */\n slugify(): this {\n this.#value = string.slug(this.#value)\n return this\n }\n\n /**\n * Removes a given suffix from the string\n */\n removeSuffix(suffix: string): this {\n this.#value = this.#value.replace(new RegExp(`[-_]?${suffix}$`, 'i'), '')\n return this\n }\n\n /**\n * Adds suffix to the string\n */\n suffix(suffix: string): this {\n this.removeSuffix(suffix)\n this.#value = `${this.#value}${suffix}`\n return this\n }\n\n /**\n * Removes a given prefix from the string\n */\n removePrefix(prefix: string): this {\n this.#value = this.#value.replace(new RegExp(`^${prefix}[-_]?`, 'i'), '')\n return this\n }\n\n /**\n * Adds prefix to the string\n */\n prefix(prefix: string): this {\n this.removePrefix(prefix)\n this.#value = `${prefix}${this.#value}`\n return this\n }\n\n /**\n * Removes extension from the value\n */\n removeExtension(): this {\n this.#value = this.#value.replace(new RegExp(`${extname(this.#value)}$`), '')\n return this\n }\n\n /**\n * Adds extension to the value\n */\n ext(extension: string): this {\n this.removeExtension()\n this.#value = `${this.#value}.${extension.replace(/^\\./, '')}`\n return this\n }\n\n toString() {\n return this.#value\n }\n}\n"],"mappings":";;;;;;AASA,SAAS,eAAe;AAMxB,IAAqB,gBAArB,MAAmC;AAAA,EACjC;AAAA,EAEA,YAAY,OAA+B;AACzC,SAAK,SAAS,OAAO,UAAU,WAAW,QAAQ,MAAM,SAAS;AAAA,EACnE;AAAA;AAAA;AAAA;AAAA,EAKA,WAAiB;AACf,SAAK,SAAS,aAAO,SAAS,KAAK,MAAM;AACzC,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA,EAKA,UAAgB;AACd,SAAK,SAAS,aAAO,QAAQ,KAAK,MAAM;AACxC,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA,EAKA,YAAkB;AAChB,SAAK,SAAS,aAAO,UAAU,KAAK,MAAM;AAC1C,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA,EAKA,aAAmB;AACjB,SAAK,SAAS,aAAO,WAAW,KAAK,MAAM;AAC3C,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA,EAKA,YAAkB;AAChB,SAAK,SAAS,aAAO,UAAU,KAAK,MAAM;AAC1C,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA,EAKA,cAAoB;AAClB,SAAK,SAAS,aAAO,YAAY,KAAK,MAAM;AAC5C,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA,EAKA,YAAkB;AAChB,SAAK,SAAS,aAAO,UAAU,KAAK,MAAM;AAC1C,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA,EAKA,eAAqB;AACnB,SAAK,SAAS,aAAO,aAAa,KAAK,MAAM;AAC7C,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA,EAKA,SAAe;AACb,SAAK,SAAS,aAAO,OAAO,KAAK,MAAM;AACvC,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA,EAKA,SAAe;AACb,SAAK,SAAS,aAAO,UAAU,KAAK,MAAM;AAC1C,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA,EAKA,WAAiB;AACf,SAAK,SAAS,aAAO,SAAS,KAAK,MAAM;AACzC,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA,EAKA,UAAgB;AACd,SAAK,SAAS,aAAO,KAAK,KAAK,MAAM;AACrC,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA,EAKA,aAAa,QAAsB;AACjC,SAAK,SAAS,KAAK,OAAO,QAAQ,IAAI,OAAO,QAAQ,MAAM,KAAK,GAAG,GAAG,EAAE;AACxE,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,QAAsB;AAC3B,SAAK,aAAa,MAAM;AACxB,SAAK,SAAS,GAAG,KAAK,MAAM,GAAG,MAAM;AACrC,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA,EAKA,aAAa,QAAsB;AACjC,SAAK,SAAS,KAAK,OAAO,QAAQ,IAAI,OAAO,IAAI,MAAM,SAAS,GAAG,GAAG,EAAE;AACxE,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,QAAsB;AAC3B,SAAK,aAAa,MAAM;AACxB,SAAK,SAAS,GAAG,MAAM,GAAG,KAAK,MAAM;AACrC,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA,EAKA,kBAAwB;AACtB,SAAK,SAAS,KAAK,OAAO,QAAQ,IAAI,OAAO,GAAG,QAAQ,KAAK,MAAM,CAAC,GAAG,GAAG,EAAE;AAC5E,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA,EAKA,IAAI,WAAyB;AAC3B,SAAK,gBAAgB;AACrB,SAAK,SAAS,GAAG,KAAK,MAAM,IAAI,UAAU,QAAQ,OAAO,EAAE,CAAC;AAC5D,WAAO;AAAA,EACT;AAAA,EAEA,WAAW;AACT,WAAO,KAAK;AAAA,EACd;AACF;","names":[]}
|
package/build/src/types.d.ts
CHANGED
|
@@ -1,35 +1,34 @@
|
|
|
1
1
|
type PickKeysByValue<T, V> = {
|
|
2
2
|
[K in keyof T]: T[K] extends V ? K : never;
|
|
3
3
|
}[keyof T];
|
|
4
|
-
type OmitProperties<T, P> = Omit<T, PickKeysByValue<T, P>>;
|
|
4
|
+
export type OmitProperties<T, P> = Omit<T, PickKeysByValue<T, P>>;
|
|
5
5
|
type ScanFsBaseOptions = {
|
|
6
6
|
ignoreMissingRoot?: boolean;
|
|
7
7
|
filter?: (filePath: string, index: number) => boolean;
|
|
8
8
|
sort?: (current: string, next: string) => number;
|
|
9
9
|
};
|
|
10
|
-
type ImportAllFilesOptions = ScanFsBaseOptions & {
|
|
10
|
+
export type ImportAllFilesOptions = ScanFsBaseOptions & {
|
|
11
11
|
/**
|
|
12
12
|
* A custom method to transform collection keys
|
|
13
13
|
*/
|
|
14
14
|
transformKeys?: (keys: string[]) => string[];
|
|
15
15
|
};
|
|
16
|
-
type ReadAllFilesOptions = ScanFsBaseOptions & {
|
|
16
|
+
export type ReadAllFilesOptions = ScanFsBaseOptions & {
|
|
17
17
|
pathType?: 'relative' | 'unixRelative' | 'absolute' | 'unixAbsolute' | 'url';
|
|
18
18
|
};
|
|
19
|
-
type JSONReplacer = (this: any, key: string, value: any) => any;
|
|
20
|
-
type JSONReviver = (this: any, key: string, value: any) => any;
|
|
21
|
-
type Constructor = new (...args: any[]) => any;
|
|
19
|
+
export type JSONReplacer = (this: any, key: string, value: any) => any;
|
|
20
|
+
export type JSONReviver = (this: any, key: string, value: any) => any;
|
|
21
|
+
export type Constructor = new (...args: any[]) => any;
|
|
22
22
|
/**
|
|
23
23
|
* Normalizes constructor to work with mixins. There is an open bug for mixins
|
|
24
24
|
* to allow constructors other than `...args: any[]`
|
|
25
25
|
*
|
|
26
26
|
* https://github.com/microsoft/TypeScript/issues/37142
|
|
27
27
|
*/
|
|
28
|
-
type NormalizeConstructor<T extends Constructor> = {
|
|
28
|
+
export type NormalizeConstructor<T extends Constructor> = {
|
|
29
29
|
new (...args: any[]): InstanceType<T>;
|
|
30
30
|
} & Omit<T, 'constructor'>;
|
|
31
|
-
type Opaque<T, K> = T & {
|
|
31
|
+
export type Opaque<T, K> = T & {
|
|
32
32
|
[' __opaque__']: K;
|
|
33
33
|
};
|
|
34
|
-
|
|
35
|
-
export { Constructor, ImportAllFilesOptions, JSONReplacer, JSONReviver, NormalizeConstructor, OmitProperties, Opaque, ReadAllFilesOptions };
|
|
34
|
+
export {};
|
package/build/src/types.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|