@catstral/levy-utils 1.0.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.
Files changed (52) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +912 -0
  3. package/dist/array/index.d.ts +7 -0
  4. package/dist/array/utils/cluster/index.d.ts +17 -0
  5. package/dist/array/utils/counting/index.d.ts +15 -0
  6. package/dist/array/utils/fork/index.d.ts +14 -0
  7. package/dist/array/utils/list/index.d.ts +65 -0
  8. package/dist/array/utils/select/index.d.ts +14 -0
  9. package/dist/array/utils/sift/index.d.ts +11 -0
  10. package/dist/array/utils/toggle/index.d.ts +34 -0
  11. package/dist/callback/index.d.ts +3 -0
  12. package/dist/callback/utils/chain/index.d.ts +31 -0
  13. package/dist/callback/utils/defer/index.d.ts +9 -0
  14. package/dist/callback/utils/retry/index.d.ts +30 -0
  15. package/dist/error.d.ts +4 -0
  16. package/dist/index.d.ts +8 -0
  17. package/dist/levyUtils.cjs +5 -0
  18. package/dist/levyUtils.js +1198 -0
  19. package/dist/misc/index.d.ts +5 -0
  20. package/dist/misc/utils/compute/index.d.ts +24 -0
  21. package/dist/misc/utils/isEmpty/index.d.ts +19 -0
  22. package/dist/misc/utils/isPrimitive/index.d.ts +18 -0
  23. package/dist/misc/utils/range/index.d.ts +89 -0
  24. package/dist/misc/utils/sleep/index.d.ts +9 -0
  25. package/dist/number/index.d.ts +2 -0
  26. package/dist/number/utils/toFloat/index.d.ts +10 -0
  27. package/dist/number/utils/toInt/index.d.ts +12 -0
  28. package/dist/object/index.d.ts +5 -0
  29. package/dist/object/utils/entries/index.d.ts +7 -0
  30. package/dist/object/utils/isObject/index.d.ts +9 -0
  31. package/dist/object/utils/keys/index.d.ts +4 -0
  32. package/dist/object/utils/omit/index.d.ts +12 -0
  33. package/dist/object/utils/pick/index.d.ts +12 -0
  34. package/dist/string/casing/index.d.ts +11 -0
  35. package/dist/string/casing/internal/splitCasing/index.d.ts +59 -0
  36. package/dist/string/casing/utils/camel/index.d.ts +27 -0
  37. package/dist/string/casing/utils/capitalize/index.d.ts +13 -0
  38. package/dist/string/casing/utils/custom/index.d.ts +42 -0
  39. package/dist/string/casing/utils/http/index.d.ts +27 -0
  40. package/dist/string/casing/utils/kebab/index.d.ts +48 -0
  41. package/dist/string/casing/utils/lower/index.d.ts +13 -0
  42. package/dist/string/casing/utils/pascal/index.d.ts +31 -0
  43. package/dist/string/casing/utils/snake/index.d.ts +48 -0
  44. package/dist/string/casing/utils/title/index.d.ts +27 -0
  45. package/dist/string/casing/utils/uncapitalize/index.d.ts +13 -0
  46. package/dist/string/casing/utils/upper/index.d.ts +13 -0
  47. package/dist/string/index.d.ts +4 -0
  48. package/dist/string/utils/parseUrlParams/index.d.ts +4 -0
  49. package/dist/string/utils/slug/index.d.ts +1 -0
  50. package/dist/string/utils/textDifference/index.d.ts +133 -0
  51. package/dist/types.d.ts +3 -0
  52. package/package.json +63 -0
@@ -0,0 +1,5 @@
1
+ export * from './utils/compute';
2
+ export * from './utils/isEmpty';
3
+ export * from './utils/isPrimitive';
4
+ export * from './utils/range';
5
+ export * from './utils/sleep';
@@ -0,0 +1,24 @@
1
+ export type Computable<T, Args extends unknown[] = never[]> = T | ((...args: Args) => T);
2
+ /**
3
+ * Check if a given value can be executed/computed.
4
+ *
5
+ * The time complexity for this is `O(1)`.
6
+ *
7
+ * @template T
8
+ * @template {?[]} Args
9
+ * @param {Computable<T, Args>} value The values to check if it can be computed
10
+ * @returns {boolean} A boolean to signal if the value can be computed
11
+ */
12
+ export declare function isComputation<const T, const Args extends unknown[]>(value: Computable<T, Args>): value is (...args: Args) => T;
13
+ /**
14
+ * Computes a computable value.
15
+ *
16
+ * The time complexity for this is `O(1)`.
17
+ *
18
+ * @template T
19
+ * @template {unknown[]} [Args=never[]]
20
+ * @param {Computable<T, Args>} value The value to compute
21
+ * @param {Args} args The arguments needed to compute the value
22
+ * @returns {T} A computed value
23
+ */
24
+ export declare function compute<const T, const Args extends unknown[] = never[]>(value: Computable<T, Args>, ...args: Args): T;
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Checks if the given value is considered empty.
3
+ *
4
+ * Empty values include:
5
+ * - Empty arrays (`[]`)
6
+ * - Empty objects (`{}`) (Do note that this checks keys, if a key exists without a value it not considered empty)
7
+ * - Empty strings (`""`)
8
+ * - `null`
9
+ * - `undefined`
10
+ *
11
+ * The time complexity for this is `O(1)`.
12
+ *
13
+ * @param {?} value The value to check if it is empty
14
+ * @returns {boolean} A boolean to signal if the given value is empty
15
+ */
16
+ export declare function isEmpty(value: string | null | undefined): value is "" | null | undefined;
17
+ export declare function isEmpty(value: unknown[] | null | undefined): value is [] | null | undefined;
18
+ export declare function isEmpty(value: Record<string, unknown> | null | undefined): value is Record<string, never> | null | undefined;
19
+ export declare function isEmpty(value: unknown): value is "" | [] | Record<string, never> | null | undefined;
@@ -0,0 +1,18 @@
1
+ export type Primitive = string | number | boolean | symbol | null | undefined;
2
+ /**
3
+ * Checks if the given value is a primitve value.
4
+ *
5
+ * The following types are considered primitive:
6
+ * - string
7
+ * - number
8
+ * - boolean
9
+ * - null
10
+ * - undefined
11
+ * - symbol
12
+ *
13
+ * The time complexity for this is `O(1)`.
14
+ *
15
+ * @param {?} value The value to check if it is primitive
16
+ * @returns {boolean} A boolean that signals if the given value is a primitive
17
+ */
18
+ export declare function isPrimitive(value: unknown): value is Primitive;
@@ -0,0 +1,89 @@
1
+ import { UtilError } from '../../../error';
2
+ import { Computable } from '../compute';
3
+ export declare class RangeUtilError extends UtilError {
4
+ readonly util = "range";
5
+ }
6
+ /**
7
+ * @typedef {Object} RangeOptions
8
+ * @template T
9
+ * @prop {T | ((step: number) => T)} [valueMapper] A mapper to map the current step of the range to a given value that will be returned by the generator
10
+ * @prop {number} [step] A number to define the steps that should be used by the range generator
11
+ */
12
+ export interface RangeOptions<T> {
13
+ /**
14
+ * A mapper to map the current step of the range to a given value that will be returned by the generator.
15
+ *
16
+ * @default undefined
17
+ */
18
+ valueMapper?: Computable<T, [step: number]> | undefined;
19
+ /**
20
+ * A number to define the steps that should be used by the range generator.
21
+ *
22
+ * @default 1
23
+ */
24
+ step?: number;
25
+ }
26
+ /**
27
+ * Returns a generator that returns values from a specified range.
28
+ *
29
+ * If `start` is greater than `end`, the range will traverse negatively (counting down) instead of positively.
30
+ *
31
+ * The time complexity for this is `O(n)` where `n` is the amount of steps needed to generate the result.
32
+ *
33
+ * @example
34
+ * // This will log the following numbers: 0, 1, 2, 3
35
+ * for (const value of range(3)) {
36
+ * console.log(value);
37
+ * }
38
+ *
39
+ * @example
40
+ * // This will log the following: 0, 1, 2, 3
41
+ * for (const value of range(0, 3)) {
42
+ * console.log(value);
43
+ * }
44
+ *
45
+ * @example
46
+ * // This will log the following: 3, 2, 1, 0
47
+ * for (const value of range(3, 0)) {
48
+ * console.log(value);
49
+ * }
50
+ *
51
+ * @example
52
+ * // This will log the following: 0, 2, 4, 6
53
+ * for (const value of range(0, 6, { step: 2 })) {
54
+ * console.log(value);
55
+ * }
56
+ *
57
+ * @example
58
+ * // This will log the following: 6, 4, 2, 0
59
+ * for (const value of range(6, 0, { step: -2 })) {
60
+ * console.log(value);
61
+ * }
62
+ *
63
+ * @example
64
+ * // This will log the following: "foo", "foo", "foo", "foo"
65
+ * for (const value of range(0, 3, { valueMapper: "foo" })) {
66
+ * console.log(value);
67
+ * }
68
+ *
69
+ * @example
70
+ * // This will log the following: "foo-0", "foo-1", "foo-2", "foo-3"
71
+ * for (const value of range(0, 3, { valueMapper: (currentStep) => `foo-${currentStep}` })) {
72
+ * console.log(value);
73
+ * }
74
+ *
75
+ * @example
76
+ * // This will log the following: "foo-0", "foo-2", "foo-4", "foo-6"
77
+ * for (const value of range(0, 6, { step: 2, valueMapper: (currentStep) => `foo-${currentStep}` })) {
78
+ * console.log(value);
79
+ * }
80
+ *
81
+ * @template [T=number]
82
+ * @param {number} startOrLength The start of the range, or if this is the only parameter given, the length of the range (inclusive)
83
+ * @param {number | undefined} [end] The end of the range (inclusive), if this value is not given, the `startOrLength` will be used to determine the end
84
+ * @param {RangeOptions<T>} [options] The options used to generate the range (see {@link RangeOptions} for more details)
85
+ * @returns {Generator<T>} A generator of a specified range (optionally mapped to a specified value)
86
+ * @throws {RangeUtilError} If `options.step` is `0`
87
+ * @throws {RangeUtilError} If `options.step` is positive while the range traverses negatively (`start` > `end`), or negative while the range traverses positively
88
+ */
89
+ export declare function range<const T = number>(startOrLength: number, end?: number, options?: RangeOptions<T>): Generator<T>;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Returns a promise that will resolve after the specified delay has elapsed.
3
+ *
4
+ * The time complexity for this is `O(1)`.
5
+ *
6
+ * @param {number} delay The delay to wait to resolve the returned promise
7
+ * @returns {Promise<void>} A Promise that resolved after the specified delay has elapsed
8
+ */
9
+ export declare function sleep(delay: number): Promise<void>;
@@ -0,0 +1,2 @@
1
+ export * from './utils/toFloat';
2
+ export * from './utils/toInt';
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Turns a value into an float where invalid values, `NaN` or `Infinity` will return a fallback.
3
+ *
4
+ * The time complexity for this is `O(1)`.
5
+ *
6
+ * @param {?} value The value to convert
7
+ * @param {number} [fallback = 0] A float number to fallback on when the value is invalid
8
+ * @returns {number} A float number parsed from the value or a fallback
9
+ */
10
+ export declare function toFloat(value: unknown, fallback?: number): number;
@@ -0,0 +1,12 @@
1
+ export type Integer<T extends number> = `${T}` extends `${string}.${string}` ? never : T;
2
+ /**
3
+ * Turns a value into an integer where invalid values, `NaN` or `Infinity` will return a fallback.
4
+ *
5
+ * The time complexity for this is `O(1)`.
6
+ *
7
+ * @template {number} T
8
+ * @param {?} value The value to convert
9
+ * @param {Integer<T>} [fallback = 0] An integer to fallback on when the value is invalid
10
+ * @returns {number} An integer number parsed from the value or a fallback
11
+ */
12
+ export declare function toInt<const T extends number>(value: unknown, fallback?: Integer<T>): number;
@@ -0,0 +1,5 @@
1
+ export * from './utils/entries';
2
+ export * from './utils/isObject';
3
+ export * from './utils/keys';
4
+ export * from './utils/omit';
5
+ export * from './utils/pick';
@@ -0,0 +1,7 @@
1
+ export type Entries<T extends object> = {
2
+ [K in keyof T]: [K, T[K]];
3
+ }[keyof T][];
4
+ /**
5
+ * Converts an object into a types version of `Object.entries`.
6
+ */
7
+ export declare function entries<const T extends Record<string, unknown>>(value: T): Entries<T>;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Checks if the given item is an object (This does not include arrays).
3
+ *
4
+ * The time complexity for this is `O(1)`.
5
+ *
6
+ * @param {?} item - The item to check
7
+ * @returns {boolean} A boolean to signal if the given item is an object
8
+ */
9
+ export declare function isObject(item: unknown): item is object;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Converts an object into a types version of `Object.keys`.
3
+ */
4
+ export declare function keys<const T extends Record<string, unknown>>(value: T): (keyof T)[];
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Omits certain keys off of an object and returns a new object without those keys.
3
+ *
4
+ * The time complexity for this is `O(n)` where `n` is the amount of keys to omit.
5
+ *
6
+ * @template {Record<string, unknown>} T
7
+ * @template {keyof T} K
8
+ * @param {T} object The objects to omit the keys off of
9
+ * @param {K | K[]} keys The keys to omit off of the object
10
+ * @returns {Omit<T, K>} A new object without the omitted keys
11
+ */
12
+ export declare function omit<const T extends Record<string, unknown>, const K extends keyof T>(object: T, keys: K | K[]): Omit<T, K>;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Picks certain keys off of an object and returns a new object with only those keys (and values)
3
+ *
4
+ * The time complexity for this is `O(n)` where `n` is the amount of keys to pick.
5
+ *
6
+ * @template {Record<string, unknown>} T
7
+ * @template {keyof T} K
8
+ * @param {T} object The objects to pick the keys off of
9
+ * @param {K | K[]} keys The keys to pick off of the object
10
+ * @returns {Pick<T, K>} A new object with the picked keys
11
+ */
12
+ export declare function pick<const T extends Record<string, unknown>, const K extends keyof T>(object: T, keys: K | K[]): Pick<T, K>;
@@ -0,0 +1,11 @@
1
+ export * from './utils/camel';
2
+ export * from './utils/capitalize';
3
+ export * from './utils/custom';
4
+ export * from './utils/http';
5
+ export * from './utils/kebab';
6
+ export * from './utils/lower';
7
+ export * from './utils/pascal';
8
+ export * from './utils/snake';
9
+ export * from './utils/title';
10
+ export * from './utils/uncapitalize';
11
+ export * from './utils/upper';
@@ -0,0 +1,59 @@
1
+ export type splitCasingParser = (str: string) => string[];
2
+ /**
3
+ * @typedef {Object} SplitCasingOptions
4
+ * @prop {boolean} [splitOnNumbers] Whether a run of digits should be split off into its own word, or seen as normal characters of the same word
5
+ * @prop {boolean} [groupUppercaseLetters] Whether consecutive uppercase letters should be grouped into a single word instead of being split one letter at a time
6
+ * @prop {splitCasingParser} [parser] A custom parser to parse a given string into word that are then used for changing the casing of words
7
+ */
8
+ export interface SplitCasingOptions {
9
+ /**
10
+ * Whether a run of digits should be split off into its own word, or seen as normal characters of the same word.
11
+ *
12
+ * @default false
13
+ */
14
+ groupNumbers?: boolean;
15
+ /**
16
+ * Whether consecutive uppercase letters should be grouped into a single word instead of being split one letter at a time.
17
+ *
18
+ * @default true
19
+ */
20
+ groupUppercaseLetters?: boolean;
21
+ /**
22
+ * A custom parser to parse a given string into word that are then used for changing the casing of words.
23
+ *
24
+ * If this is defined, all other options are ignored.
25
+ */
26
+ parser?: splitCasingParser;
27
+ }
28
+ /**
29
+ * Splits a string into its constituent words, based on whitespace, hyphens, underscores, casing changes, and
30
+ * (optionally) runs of digits. The original casing of each word is preserved as-is.
31
+ *
32
+ * This is an internal building block used by the casing utilities in this directory (see {@link CustomCaseOptions})
33
+ * and is not intended to be used directly.
34
+ *
35
+ * The time complexity for this is `O(n)` where `n` is the length of the given string.
36
+ *
37
+ * @example
38
+ * const words = splitCasing("helloWorld", undefined); // -> ["hello", "World"]
39
+ *
40
+ * @example
41
+ * const words = splitCasing("HTTPServer", undefined); // -> ["HTTP", "Server"]
42
+ *
43
+ * @example
44
+ * const words = splitCasing("HTTPServer", { groupUppercaseLetters: false }); // -> ["H", "T", "T", "P", "Server"]
45
+ *
46
+ * @example
47
+ * const words = splitCasing("HTTP_server", undefined); // -> ["HTTP", "server"]
48
+ *
49
+ * @example
50
+ * const words = splitCasing("foo123bar", { groupNumbers: true }); // -> ["foo", "123", "bar"]
51
+ *
52
+ * @example
53
+ * const words = splitCasing("foo_bar-baz qux", undefined); // -> ["foo", "bar", "baz", "qux"]
54
+ *
55
+ * @param {string} str The string to split into words
56
+ * @param {SplitCasingOptions | undefined} options The options used to split the string (see {@link SplitCasingOptions} for more details)
57
+ * @returns {string[]} The words found in the given string, with their original casing preserved
58
+ */
59
+ export declare function splitCasing(str: string, options?: SplitCasingOptions): string[];
@@ -0,0 +1,27 @@
1
+ import { SplitCasingOptions } from '../../internal/splitCasing';
2
+ /**
3
+ * @typedef {Object} CamelCaseOptions
4
+ */
5
+ export interface CamelCaseOptions extends SplitCasingOptions {
6
+ }
7
+ /**
8
+ * Converts a string to camelCase.
9
+ *
10
+ * The first word is lowercased, every following word has its first letter uppercased with the rest lowercased, and
11
+ * words are joined together with no separator.
12
+ *
13
+ * The time complexity for this is `O(n + m)` where:
14
+ * - `n` is the length of the given string.
15
+ * - `m` is the amount of words in `n`.
16
+ *
17
+ * @example
18
+ * const str = camelCase("hello world"); // -> "helloWorld"
19
+ *
20
+ * @example
21
+ * const str = camelCase("Hello-World_foo"); // -> "helloWorldFoo"
22
+ *
23
+ * @param {string} str The string to convert
24
+ * @param {CamelCaseOptions} [options] The options used to convert the string (see {@link CamelCaseOptions} for more details)
25
+ * @returns {string} The camelCased string
26
+ */
27
+ export declare function camelCase(str: string, options?: CamelCaseOptions): string;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Converts the first character of string to uppercase.
3
+ *
4
+ * The time complexity for this is `O(n)` where `n` is the length of the given string.
5
+ *
6
+ * @example
7
+ * const str = capitalize("hello world"); // -> "Hello world"
8
+ *
9
+ * @template {string} T
10
+ * @param {T} str
11
+ * @returns {Capitalize<T>}
12
+ */
13
+ export declare function capitalize<const T extends string>(str: T): Capitalize<T>;
@@ -0,0 +1,42 @@
1
+ import { SplitCasingOptions } from '../../internal/splitCasing';
2
+ /**
3
+ * @typedef {Object} CustomCaseOptions
4
+ * @prop {string} seperator The separator to place between each transformed word
5
+ * @prop {(word: string, index: number) => string} transform A function used to transform each word found in the string
6
+ */
7
+ export interface CustomCaseOptions extends SplitCasingOptions {
8
+ /**
9
+ * The separator to place between each transformed word.
10
+ */
11
+ seperator: string;
12
+ /**
13
+ * A function used to transform each word found in the string. The word retains whatever casing it had in the
14
+ * original string.
15
+ *
16
+ * @param word The word to transform
17
+ * @param index The index of the word within the string
18
+ */
19
+ transform: (word: string, index: number) => string;
20
+ }
21
+ /**
22
+ * Splits a string into words (see {@link SplitCasingOptions}) and joins them back together using a custom separator,
23
+ * transforming each word along the way.
24
+ *
25
+ * This is the building block used by the other casing utilities (`camelCase`, `kebabCase`, `pascalCase`, `snakeCase`,
26
+ * `titleCase`, `httpHeaderCase`, etc.), That also means that those casing options should be used instead most of the time.
27
+ *
28
+ * The time complexity for this is `O(n + m)` where:
29
+ * - `n` is the length of the given string.
30
+ * - `m` is the amount of words in `n`.
31
+ *
32
+ * @example
33
+ * const str = customCase("hello world", { seperator: "-", transform: (word) => word.toUpperCase() }); // -> "HELLO-WORLD"
34
+ *
35
+ * @example
36
+ * const str = customCase("hello world", { seperator: "_", transform: (word, index) => (index === 0 ? word : word.toUpperCase()) }); // -> "hello_WORLD"
37
+ *
38
+ * @param {string} str The string to transform
39
+ * @param {CustomCaseOptions} options The options used to split and join the string (see {@link CustomCaseOptions} for more details)
40
+ * @returns {string} The transformed string
41
+ */
42
+ export declare function customCase(str: string, options: CustomCaseOptions): string;
@@ -0,0 +1,27 @@
1
+ import { SplitCasingOptions } from '../../internal/splitCasing';
2
+ /**
3
+ * @typedef {Object} HttpHeaderCaseOptions
4
+ */
5
+ export interface HttpHeaderCaseOptions extends SplitCasingOptions {
6
+ }
7
+ /**
8
+ * Converts a string to HTTP-Header-Case (also known as Train-Case).
9
+ *
10
+ * Every word has its first letter uppercased with the rest lowercased, and words are joined together using a `-`.
11
+ *
12
+ * The time complexity for this is `O(n + m)` where:
13
+ * - `n` is the length of the given string.
14
+ * - `m` is the amount of words in `n`.
15
+ *
16
+ * @example
17
+ * const str = httpHeaderCase("content type"); // -> "Content-Type"
18
+ *
19
+ * @example
20
+ * const str = httpHeaderCase("x_forwarded_for"); // -> "X-Forwarded-For"
21
+ *
22
+ * @param {string} str The string to convert
23
+ * @param {HttpHeaderCaseOptions} [options] The options used to convert the string (see {@link HttpHeaderCaseOptions} for more details)
24
+ * @returns {string} The HTTP-Header-Cased string
25
+ */
26
+ export declare function httpHeaderCase(str: string, options?: HttpHeaderCaseOptions): string;
27
+ export { type HttpHeaderCaseOptions as TrainCaseOptions, httpHeaderCase as trainCase };
@@ -0,0 +1,48 @@
1
+ import { SplitCasingOptions } from '../../internal/splitCasing';
2
+ /**
3
+ * @typedef {Object} KebabCaseOptions
4
+ * @prop {boolean} [screaming] Whether to uppercase every word instead of lowercasing them (SCREAMING-KEBAB-CASE)
5
+ */
6
+ export interface KebabCaseOptions extends SplitCasingOptions {
7
+ /**
8
+ * Whether to uppercase every word instead of lowercasing them (SCREAMING-KEBAB-CASE).
9
+ *
10
+ * @default false
11
+ */
12
+ screaming?: boolean;
13
+ }
14
+ /**
15
+ * Converts a string to kebab-case.
16
+ *
17
+ * Every word is lowercased (or uppercased if `options.screaming` is `true`) and joined together using a `-`.
18
+ *
19
+ * The time complexity for this is `O(n + m)` where:
20
+ * - `n` is the length of the given string.
21
+ * - `m` is the amount of words in `n`.
22
+ *
23
+ * @example
24
+ * const str = kebabCase("hello world"); // -> "hello-world"
25
+ *
26
+ * @example
27
+ * const str = kebabCase("helloWorld", { screaming: true }); // -> "HELLO-WORLD"
28
+ *
29
+ * @param {string} str The string to convert
30
+ * @param {KebabCaseOptions} [options] The options used to convert the string (see {@link KebabCaseOptions} for more details)
31
+ * @returns {string} The kebab-cased string
32
+ */
33
+ export declare function kebabCase(str: string, options?: KebabCaseOptions): string;
34
+ /**
35
+ * Converts a string to SCREAMING-KEBAB-CASE.
36
+ *
37
+ * Equivalent to calling {@link kebabCase} with `options.screaming` set to `true`.
38
+ *
39
+ * The time complexity for this is `O(n)` where `n` is the length of the given string.
40
+ *
41
+ * @example
42
+ * const str = screamingKebabCase("hello world"); // -> "HELLO-WORLD"
43
+ *
44
+ * @param {string} str The string to convert
45
+ * @param {Omit<KebabCaseOptions, "screaming">} [options] The options used to convert the string (see {@link KebabCaseOptions} for more details)
46
+ * @returns {string} The SCREAMING-KEBAB-CASEd string
47
+ */
48
+ export declare function screamingKebabCase(str: string, options?: Omit<KebabCaseOptions, "screaming">): string;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Converts a string to lowercase.
3
+ *
4
+ * The time complexity for this is `O(n)` where `n` is the length of the given string.
5
+ *
6
+ * @example
7
+ * const str = lowerCase("Hello World"); // -> "hello world"
8
+ *
9
+ * @template {string} T
10
+ * @param {T} str
11
+ * @returns {Lowercase<T>}
12
+ */
13
+ export declare function lowerCase<const T extends string>(str: T): Lowercase<T>;
@@ -0,0 +1,31 @@
1
+ import { SplitCasingOptions } from '../../internal/splitCasing';
2
+ /**
3
+ * @typedef {Object} PascalCaseOptions
4
+ */
5
+ export interface PascalCaseOptions extends SplitCasingOptions {
6
+ }
7
+ /**
8
+ * Converts a string to PascalCase.
9
+ *
10
+ * Every word has its first letter uppercased, with the rest of the word left untouched, and words are joined together
11
+ * with no separator.
12
+ *
13
+ * The time complexity for this is `O(n + m)` where:
14
+ * - `n` is the length of the given string.
15
+ * - `m` is the amount of words in `n`.
16
+ *
17
+ * @example
18
+ * const str = pascalCase("hello world"); // -> "HelloWorld"
19
+ *
20
+ * @example
21
+ * const str = pascalCase("hello-world_foo"); // -> "HelloWorldFoo"
22
+ *
23
+ * @example
24
+ * // Acronyms keep their original casing, only their first letter is (re-)uppercased
25
+ * const str = pascalCase("HTTP_server"); // -> "HTTPServer"
26
+ *
27
+ * @param {string} str The string to convert
28
+ * @param {PascalCaseOptions} [options] The options used to convert the string (see {@link PascalCaseOptions} for more details)
29
+ * @returns {string} The PascalCased string
30
+ */
31
+ export declare function pascalCase(str: string, options?: PascalCaseOptions): string;
@@ -0,0 +1,48 @@
1
+ import { SplitCasingOptions } from '../../internal/splitCasing';
2
+ /**
3
+ * @typedef {Object} SnakeCaseOptions
4
+ * @prop {boolean} [screaming] Whether to uppercase every word instead of lowercasing them (SCREAMING_SNAKE_CASE)
5
+ */
6
+ export interface SnakeCaseOptions extends SplitCasingOptions {
7
+ /**
8
+ * Whether to uppercase every word instead of lowercasing them (SCREAMING_SNAKE_CASE).
9
+ *
10
+ * @default false
11
+ */
12
+ screaming?: boolean;
13
+ }
14
+ /**
15
+ * Converts a string to snake_case.
16
+ *
17
+ * Every word is lowercased (or uppercased if `options.screaming` is `true`) and joined together using a `_`.
18
+ *
19
+ * The time complexity for this is `O(n + m)` where:
20
+ * - `n` is the length of the given string.
21
+ * - `m` is the amount of words in `n`.
22
+ *
23
+ * @example
24
+ * const str = snakeCase("hello world"); // -> "hello_world"
25
+ *
26
+ * @example
27
+ * const str = snakeCase("helloWorld", { screaming: true }); // -> "HELLO_WORLD"
28
+ *
29
+ * @param {string} str The string to convert
30
+ * @param {SnakeCaseOptions} [options] The options used to convert the string (see {@link SnakeCaseOptions} for more details)
31
+ * @returns {string} The snake_cased string
32
+ */
33
+ export declare function snakeCase(str: string, options?: SnakeCaseOptions): string;
34
+ /**
35
+ * Converts a string to SCREAMING_SNAKE_CASE.
36
+ *
37
+ * Equivalent to calling {@link snakeCase} with `options.screaming` set to `true`.
38
+ *
39
+ * The time complexity for this is `O(n)` where `n` is the length of the given string.
40
+ *
41
+ * @example
42
+ * const str = screamingSnakeCase("hello world"); // -> "HELLO_WORLD"
43
+ *
44
+ * @param {string} str The string to convert
45
+ * @param {Omit<SnakeCaseOptions, "screaming">} [options] The options used to convert the string (see {@link SnakeCaseOptions} for more details)
46
+ * @returns {string} The SCREAMING_SNAKE_CASEd string
47
+ */
48
+ export declare function screamingSnakeCase(str: string, options?: Omit<SnakeCaseOptions, "screaming">): string;
@@ -0,0 +1,27 @@
1
+ import { SplitCasingOptions } from '../../internal/splitCasing';
2
+ /**
3
+ * @typedef {Object} TitleCaseOptions
4
+ */
5
+ export interface TitleCaseOptions extends SplitCasingOptions {
6
+ }
7
+ /**
8
+ * Converts a string to Title Case.
9
+ *
10
+ * Every word has its first letter uppercased, with the rest of the word left untouched, and words are joined together
11
+ * using a single space.
12
+ *
13
+ * The time complexity for this is `O(n + m)` where:
14
+ * - `n` is the length of the given string.
15
+ * - `m` is the amount of words in `n`.
16
+ *
17
+ * @example
18
+ * const str = titleCase("hello world"); // -> "Hello World"
19
+ *
20
+ * @example
21
+ * const str = titleCase("hello-world_foo"); // -> "Hello World Foo"
22
+ *
23
+ * @param {string} str The string to convert
24
+ * @param {TitleCaseOptions} [options] The options used to convert the string (see {@link TitleCaseOptions} for more details)
25
+ * @returns {string} The Title Cased string
26
+ */
27
+ export declare function titleCase(str: string, options?: TitleCaseOptions): string;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Converts the first character of string to lowercase.
3
+ *
4
+ * The time complexity for this is `O(n)` where `n` is the length of the given string.
5
+ *
6
+ * @example
7
+ * const str = uncapitalize("Hello world"); // -> "hello world"
8
+ *
9
+ * @template {string} T
10
+ * @param {T} str
11
+ * @returns {Uncapitalize<T>}
12
+ */
13
+ export declare function uncapitalize<const T extends string>(str: T): Uncapitalize<T>;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Converts a string to UPPERCASE.
3
+ *
4
+ * The time complexity for this is `O(n)` where `n` is the length of the given string.
5
+ *
6
+ * @example
7
+ * const str = upperCase("Hello World"); // -> "HELLO WORLD"
8
+ *
9
+ * @template {string} T
10
+ * @param {T} str
11
+ * @returns {Uppercase<T>}
12
+ */
13
+ export declare function upperCase<const T extends string>(str: T): Uppercase<T>;
@@ -0,0 +1,4 @@
1
+ export * from './casing';
2
+ export * from './utils/parseUrlParams';
3
+ export * from './utils/slug';
4
+ export * from './utils/textDifference';