utilitish 0.0.6 → 0.0.8

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.
@@ -1,27 +1,105 @@
1
- export {};
2
1
  declare global {
3
2
  interface Set<T> {
4
3
  /**
5
4
  * Converts the Set into an array, preserving insertion order.
6
- * @returns An array of all values in the Set.
5
+ *
6
+ * @template T The type of elements in the Set
7
+ * @this {Set<T>} The Set to convert
8
+ * @returns {T[]} An array containing all values in the Set in insertion order
9
+ *
10
+ * @example
11
+ * const set = new Set([1, 2, 3]);
12
+ * const arr = set.toList(); // [1, 2, 3]
13
+ *
14
+ * @remarks
15
+ * - Returns a new array instance each time; modifying it does not affect the Set
16
+ * - Empty sets return an empty array
7
17
  */
8
18
  toList<T>(): T[];
9
19
  /**
10
- * Returns true if at least one of the given items is present in the set.
20
+ * Returns true if at least one of the given items is present in the Set.
21
+ *
22
+ * @template T The type of elements in the Set
23
+ * @this {Set<T>} The Set to check
24
+ * @param {...T[]} items - Variable number of items to check
25
+ * @returns {boolean} True if any item is in the Set, false if no items or Set is empty
26
+ * @throws {TypeError} If arguments are not in array-like form
27
+ *
28
+ * @example
29
+ * const set = new Set(['a', 'b', 'c']);
30
+ * set.hasAny('d', 'a'); // true
31
+ * set.hasAny('d', 'e'); // false
32
+ *
33
+ * @remarks
34
+ * - Returns false if no items are provided (empty arguments)
35
+ * - Uses strict equality (===) to check for item presence
11
36
  */
12
37
  hasAny(...items: T[]): boolean;
13
38
  /**
14
- * Returns true if all of the given items are present in the set.
39
+ * Returns true if all of the given items are present in the Set.
40
+ * Can accept items as separate arguments or as a single Set parameter.
41
+ *
42
+ * @template T The type of elements in the Set
43
+ * @this {Set<T>} The Set to check
44
+ * @param {...(T[] | Set<T>)} args - Items to check (varargs or single Set)
45
+ * @returns {boolean} True if all items are in the Set, false otherwise
46
+ * @throws {TypeError} If arguments are not in a valid format or not all Sets
47
+ *
48
+ * @example
49
+ * const set = new Set(['a', 'b', 'c']);
50
+ * set.includes('a', 'b'); // true
51
+ * set.includes('a', 'd'); // false
52
+ * set.includes(new Set(['a', 'b'])); // true
53
+ *
54
+ * @remarks
55
+ * - Returns true if no arguments are provided (like Array's every())
56
+ * - Can check against another Set by passing it as the single argument
57
+ * - Uses strict equality (===) for item comparison
15
58
  */
16
59
  includes(...items: T[]): boolean;
17
60
  includes(items: Set<T>): boolean;
18
61
  /**
19
- * Returns a new Set that is the union of this set and all given sets.
62
+ * Returns a new Set that is the union (combination) of this Set and all given Sets.
63
+ *
64
+ * @template T The type of elements in the Sets
65
+ * @this {Set<T>} The Set to start with
66
+ * @param {...Set<T>[]} others - Sets to union with
67
+ * @returns {Set<T>} A new Set containing all unique elements from this Set and all given Sets
68
+ * @throws {TypeError} If any argument is not a Set instance
69
+ *
70
+ * @example
71
+ * const set1 = new Set([1, 2, 3]);
72
+ * const set2 = new Set([3, 4, 5]);
73
+ * const result = set1.union(set2); // Set(5) { 1, 2, 3, 4, 5 }
74
+ *
75
+ * @remarks
76
+ * - Does not modify the original Set
77
+ * - Duplicate values across sets are automatically deduplicated (Set behavior)
78
+ * - Returns a new Set instance each time
20
79
  */
21
80
  union(...others: Set<T>[]): Set<T>;
22
81
  /**
23
- * Returns a new Set that is the intersection of this set and all given sets.
82
+ * Returns a new Set that is the intersection of this Set and all given Sets.
83
+ * Contains only elements that are present in all Sets (this + all given Sets).
84
+ *
85
+ * @template T The type of elements in the Sets
86
+ * @this {Set<T>} The Set to start with
87
+ * @param {...Set<T>[]} others - Sets to intersect with
88
+ * @returns {Set<T>} A new Set containing only elements that exist in all Sets
89
+ * @throws {TypeError} If any argument is not a Set instance
90
+ *
91
+ * @example
92
+ * const set1 = new Set([1, 2, 3, 4]);
93
+ * const set2 = new Set([2, 3, 5]);
94
+ * const set3 = new Set([3, 6]);
95
+ * const result = set1.intersection(set2, set3); // Set(1) { 3 }
96
+ *
97
+ * @remarks
98
+ * - Does not modify the original Set
99
+ * - Returns an empty Set if no elements are common to all Sets
100
+ * - Returns a new Set instance each time
24
101
  */
25
102
  intersection(...others: Set<T>[]): Set<T>;
26
103
  }
27
104
  }
105
+ export {};
@@ -1,18 +1,27 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const utils_1 = require("../utils");
4
- (0, utils_1.defineIfNotExists)(Set.prototype, 'toList', function () {
3
+ const core_utils_1 = require("../utils/core.utils");
4
+ /**
5
+ * @see Set.prototype.toList
6
+ */
7
+ (0, core_utils_1.defineIfNotExists)(Set.prototype, 'toList', function () {
5
8
  // Always returns a new array, even for empty sets
6
9
  return Array.from(this);
7
10
  });
8
- (0, utils_1.defineIfNotExists)(Set.prototype, 'hasAny', function (...items) {
11
+ /**
12
+ * @see Set.prototype.hasAny
13
+ */
14
+ (0, core_utils_1.defineIfNotExists)(Set.prototype, 'hasAny', function (...items) {
9
15
  if (!Array.isArray(items))
10
16
  throw new TypeError('Arguments must be an array');
11
17
  if (items.length === 0)
12
18
  return false;
13
19
  return items.some((item) => this.has(item));
14
20
  });
15
- (0, utils_1.defineIfNotExists)(Set.prototype, 'includes', function (...args) {
21
+ /**
22
+ * @see Set.prototype.includes
23
+ */
24
+ (0, core_utils_1.defineIfNotExists)(Set.prototype, 'includes', function (...args) {
16
25
  let values;
17
26
  if (args.length === 0)
18
27
  return true; // empty means "all included" (like [].every)
@@ -26,7 +35,10 @@ const utils_1 = require("../utils");
26
35
  throw new TypeError('Arguments must be an array or a Set');
27
36
  return values.every((item) => this.has(item));
28
37
  });
29
- (0, utils_1.defineIfNotExists)(Set.prototype, 'union', function (...others) {
38
+ /**
39
+ * @see Set.prototype.union
40
+ */
41
+ (0, core_utils_1.defineIfNotExists)(Set.prototype, 'union', function (...others) {
30
42
  const result = new Set(this);
31
43
  for (const other of others) {
32
44
  if (!(other instanceof Set))
@@ -37,7 +49,10 @@ const utils_1 = require("../utils");
37
49
  }
38
50
  return result;
39
51
  });
40
- (0, utils_1.defineIfNotExists)(Set.prototype, 'intersection', function (...others) {
52
+ /**
53
+ * @see Set.prototype.intersection
54
+ */
55
+ (0, core_utils_1.defineIfNotExists)(Set.prototype, 'intersection', function (...others) {
41
56
  if (others.some((s) => !(s instanceof Set)))
42
57
  throw new TypeError('Arguments must be Sets');
43
58
  const result = new Set();
@@ -0,0 +1 @@
1
+ import '../set/set-prototype';
@@ -0,0 +1,122 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ require("../set/set-prototype");
4
+ describe('Set.prototype', () => {
5
+ describe('toList()', () => {
6
+ it('should return array with all values in insertion order', () => {
7
+ const set = new Set([3, 1, 2]);
8
+ expect(set.toList()).toEqual([3, 1, 2]);
9
+ });
10
+ it('should return empty array when set is empty', () => {
11
+ const set = new Set();
12
+ expect(set.toList()).toEqual([]);
13
+ });
14
+ it('should return a new array instance (not same reference)', () => {
15
+ const set = new Set([1, 2, 3]);
16
+ const arr = set.toList();
17
+ expect(Array.isArray(arr)).toBe(true);
18
+ expect(arr).not.toBe(set);
19
+ });
20
+ });
21
+ describe('hasAny()', () => {
22
+ describe('with multiple items', () => {
23
+ it('should return true when at least one item is present', () => {
24
+ const set = new Set([1, 2, 3]);
25
+ expect(set.hasAny(0, 2)).toBe(true);
26
+ });
27
+ it('should return false when no items are present', () => {
28
+ const set = new Set([1, 2, 3]);
29
+ expect(set.hasAny(4, 5)).toBe(false);
30
+ });
31
+ });
32
+ describe('with edge cases', () => {
33
+ it('should return false when called with no arguments', () => {
34
+ const set = new Set([1, 2, 3]);
35
+ expect(set.hasAny()).toBe(false);
36
+ });
37
+ });
38
+ });
39
+ describe('includes()', () => {
40
+ describe('with multiple items as arguments', () => {
41
+ it('should return true when all items are present', () => {
42
+ const set = new Set([1, 2, 3]);
43
+ expect(set.includes(1, 2)).toBe(true);
44
+ });
45
+ it('should return false when at least one item is missing', () => {
46
+ const set = new Set([1, 2, 3]);
47
+ expect(set.includes(1, 4)).toBe(false);
48
+ });
49
+ });
50
+ describe('with Set as argument', () => {
51
+ it('should return true when all items from Set are present', () => {
52
+ const set = new Set([1, 2, 3]);
53
+ expect(set.includes(new Set([1, 2]))).toBe(true);
54
+ });
55
+ it('should return false when some items from Set are missing', () => {
56
+ const set = new Set([1, 2, 3]);
57
+ expect(set.includes(new Set([1, 4]))).toBe(false);
58
+ });
59
+ });
60
+ describe('with edge cases', () => {
61
+ it('should return true when called with no arguments', () => {
62
+ const set = new Set([1, 2, 3]);
63
+ expect(set.includes()).toBe(true);
64
+ });
65
+ });
66
+ });
67
+ describe('union()', () => {
68
+ describe('with multiple Sets', () => {
69
+ it('should return a new Set with all unique values', () => {
70
+ const a = new Set([1, 2]);
71
+ const b = new Set([2, 3]);
72
+ expect(a.union(b)).toEqual(new Set([1, 2, 3]));
73
+ });
74
+ });
75
+ describe('with no arguments', () => {
76
+ it('should return a copy of the Set when no arguments provided', () => {
77
+ const a = new Set([1, 2]);
78
+ expect(a.union()).toEqual(new Set([1, 2]));
79
+ });
80
+ });
81
+ describe('error handling', () => {
82
+ it('should throw TypeError when argument is not a Set', () => {
83
+ const a = new Set([1, 2]);
84
+ // @ts-expect-error
85
+ expect(() => a.union([3, 4])).toThrow(TypeError);
86
+ });
87
+ });
88
+ });
89
+ describe('intersection()', () => {
90
+ describe('with multiple Sets', () => {
91
+ it('should return a new Set with only common values', () => {
92
+ const a = new Set([1, 2, 3]);
93
+ const b = new Set([2, 3, 4]);
94
+ expect(a.intersection(b)).toEqual(new Set([2, 3]));
95
+ });
96
+ it('should return empty Set when no common values exist', () => {
97
+ const a = new Set([1, 2]);
98
+ const b = new Set([3, 4]);
99
+ expect(a.intersection(b)).toEqual(new Set());
100
+ });
101
+ it('should work with multiple Sets at once', () => {
102
+ const a = new Set([1, 2, 3, 4]);
103
+ const b = new Set([2, 3, 5]);
104
+ const c = new Set([3, 6]);
105
+ expect(a.intersection(b, c)).toEqual(new Set([3]));
106
+ });
107
+ });
108
+ describe('with no arguments', () => {
109
+ it('should return a copy of the Set when no arguments provided', () => {
110
+ const a = new Set([1, 2]);
111
+ expect(a.intersection()).toEqual(new Set([1, 2]));
112
+ });
113
+ });
114
+ describe('error handling', () => {
115
+ it('should throw TypeError when argument is not a Set', () => {
116
+ const a = new Set([1, 2]);
117
+ // @ts-expect-error
118
+ expect(() => a.intersection([2])).toThrow(TypeError);
119
+ });
120
+ });
121
+ });
122
+ });
@@ -1,62 +1,181 @@
1
- export {};
2
1
  declare global {
3
2
  interface String {
4
3
  /**
5
- * Capitalizes the first character of the string.
6
- * @returns A new string with the first character in uppercase.
4
+ * Capitalizes the first character of the string (uppercase) and keeps the rest unchanged.
5
+ *
6
+ * @this {string} The string to capitalize
7
+ * @returns {string} A new string with the first character in uppercase
8
+ *
9
+ * @example
10
+ * 'hello world'.capitalize(); // 'Hello world'
11
+ * 'HELLO'.capitalize(); // 'HELLO'
12
+ *
13
+ * @remarks
14
+ * - Only affects the first character
15
+ * - Returns an empty string for empty input
16
+ * - Does not normalize the rest of the string
7
17
  */
8
18
  capitalize(): string;
9
19
  /**
10
- * Splits the string into an array of words, detecting camelCase, kebab-case, snake_case, and spaces.
11
- * @returns An array of words extracted from the string.
20
+ * Splits the string into an array of words by detecting camelCase, kebab-case, snake_case, and spaces.
21
+ * Useful as a foundation for case conversion methods.
22
+ *
23
+ * @this {string} The string to split
24
+ * @returns {string[]} An array of individual words extracted from the string
25
+ *
26
+ * @example
27
+ * 'helloWorld'.splitWords(); // ['hello', 'World']
28
+ * 'hello-world'.splitWords(); // ['hello', 'world']
29
+ * 'hello_world'.splitWords(); // ['hello', 'world']
30
+ * 'HelloWorld'.splitWords(); // ['Hello', 'World']
31
+ *
32
+ * @remarks
33
+ * - Handles transitions from lowercase to uppercase (camelCase)
34
+ * - Handles consecutive uppercase letters (HTMLParser → HTML Parser)
35
+ * - Treats spaces, hyphens, and underscores as word separators
36
+ * - Filters out empty strings
12
37
  */
13
38
  splitWords(): string[];
14
39
  /**
15
- * Converts the string to camelCase.
16
- * @returns A camelCased version of the string.
40
+ * Converts the string to camelCase format.
41
+ *
42
+ * @this {string} The string to convert
43
+ * @returns {string} The camelCased version of the string
44
+ *
45
+ * @example
46
+ * 'hello-world'.camelCase(); // 'helloWorld'
47
+ * 'hello_world'.camelCase(); // 'helloWorld'
48
+ * 'HelloWorld'.camelCase(); // 'helloWorld'
49
+ *
50
+ * @remarks
51
+ * - First word is lowercase, subsequent words have uppercase first letter
52
+ * - Uses `splitWords()` internally to handle various naming conventions
17
53
  */
18
54
  camelCase(): string;
19
55
  /**
20
- * Converts the string to kebab-case.
21
- * @returns A kebab-cased version of the string.
56
+ * Converts the string to kebab-case format.
57
+ *
58
+ * @this {string} The string to convert
59
+ * @returns {string} The kebab-cased version of the string
60
+ *
61
+ * @example
62
+ * 'helloWorld'.kebabCase(); // 'hello-world'
63
+ * 'hello_world'.kebabCase(); // 'hello-world'
64
+ * 'HelloWorld'.kebabCase(); // 'hello-world'
65
+ *
66
+ * @remarks
67
+ * - All letters are lowercase
68
+ * - Words are separated by hyphens
69
+ * - Uses `splitWords()` internally
22
70
  */
23
71
  kebabCase(): string;
24
72
  /**
25
- * Converts the string to snake_case.
26
- * @returns A snake_cased version of the string.
73
+ * Converts the string to snake_case format.
74
+ *
75
+ * @this {string} The string to convert
76
+ * @returns {string} The snake_cased version of the string
77
+ *
78
+ * @example
79
+ * 'helloWorld'.snakeCase(); // 'hello_world'
80
+ * 'hello-world'.snakeCase(); // 'hello_world'
81
+ * 'HelloWorld'.snakeCase(); // 'hello_world'
82
+ *
83
+ * @remarks
84
+ * - All letters are lowercase
85
+ * - Words are separated by underscores
86
+ * - Uses `splitWords()` internally
27
87
  */
28
88
  snakeCase(): string;
29
89
  /**
30
90
  * Truncates the string to a maximum number of characters, appending '...' if truncated.
31
- * @param n - Maximum length of the string.
32
- * @returns A truncated string.
91
+ *
92
+ * @this {string} The string to truncate
93
+ * @param {number} n - Maximum length of the result (not including the '...')
94
+ * @returns {string} The truncated string with '...' appended if truncated, otherwise the original string
95
+ * @throws {TypeError} If n is not a non-negative integer
96
+ *
97
+ * @example
98
+ * 'hello world'.truncate(5); // 'hello...'
99
+ * 'hello'.truncate(10); // 'hello'
100
+ *
101
+ * @remarks
102
+ * - The '...' is added after the truncated portion, so total length is n + 3
103
+ * - Negative or non-integer values throw an error
33
104
  */
34
105
  truncate(n: number): string;
35
106
  /**
36
- * Reverses the characters in the string.
37
- * @returns The reversed string.
107
+ * Reverses the characters in the string, properly handling Unicode surrogate pairs.
108
+ *
109
+ * @this {string} The string to reverse
110
+ * @returns {string} The reversed string
111
+ *
112
+ * @example
113
+ * 'hello'.reverse(); // 'olleh'
114
+ * '👋world'.reverse(); // 'dlrow👋'
115
+ *
116
+ * @remarks
117
+ * - Uses spread operator to properly handle Unicode characters
118
+ * - Works correctly with emoji and other multi-byte characters
38
119
  */
39
120
  reverse(): string;
40
121
  /**
41
- * Checks if the string is empty or contains only whitespace.
42
- * @returns `true` if the string is empty or whitespace only, `false` otherwise.
122
+ * Checks if the string is empty or contains only whitespace characters.
123
+ *
124
+ * @this {string} The string to check
125
+ * @returns {boolean} True if the string is empty or whitespace-only, false otherwise
126
+ *
127
+ * @example
128
+ * ''.isEmpty(); // true
129
+ * ' '.isEmpty(); // true
130
+ * 'hello'.isEmpty(); // false
131
+ * ' hello '.isEmpty(); // false
132
+ *
133
+ * @remarks
134
+ * - Uses `trim()` internally, so handles all whitespace characters
43
135
  */
44
136
  isEmpty(): boolean;
45
137
  /**
46
- * Converts the string into a slug usable in URLs.
47
- * @returns A slugified version of the string.
138
+ * Converts the string into a URL-friendly slug format.
139
+ * Combines normalization, lowercasing, whitespace handling, and special character removal.
140
+ *
141
+ * @this {string} The string to slugify
142
+ * @returns {string} A URL-safe slug version of the string
143
+ *
144
+ * @example
145
+ * 'Hello World'.slugify(); // 'hello-world'
146
+ * 'Héllo Wørld'.slugify(); // 'hello-world'
147
+ * 'Hello World!!!'.slugify(); // 'hello-world'
148
+ *
149
+ * @remarks
150
+ * - Normalizes Unicode characters (NFD decomposition)
151
+ * - Removes accents and diacritical marks
152
+ * - Converts to lowercase
153
+ * - Replaces spaces and special characters with hyphens
154
+ * - Removes leading/trailing hyphens
155
+ * - Collapses multiple consecutive hyphens into one
48
156
  */
49
157
  slugify(): string;
50
158
  /**
51
159
  * Replaces a substring between `start` and `end` indices with a given string.
52
- * If `end` is not provided, only the character at `start` is replaced.
53
- * If `replaceString` is not provided, the range is simply removed.
160
+ * Provides precise control over which portion of the string to replace.
54
161
  *
55
- * @param start - Start index of the replacement (inclusive).
56
- * @param end - End index of the replacement (exclusive). Defaults to `start`.
57
- * @param replaceString - The string to insert in place. Defaults to `''`.
58
- * @returns A new string with the specified range replaced.
162
+ * @this {string} The string to modify
163
+ * @param {number} start - Start index of the replacement range (inclusive)
164
+ * @param {number} [end] - End index of the replacement range (exclusive); defaults to start + 1
165
+ * @param {string} [replaceString=''] - The string to insert in place of the removed portion
166
+ * @returns {string} A new string with the range replaced
167
+ *
168
+ * @example
169
+ * 'hello world'.replaceRange(0, 5, 'goodbye'); // 'goodbye world'
170
+ * 'hello'.replaceRange(2, 2, 'XX'); // 'heXXllo'
171
+ * 'hello'.replaceRange(1, 4); // 'ho'
172
+ *
173
+ * @remarks
174
+ * - If end is not provided, defaults to replacing only the character at start
175
+ * - If replaceString is not provided, the range is simply removed
176
+ * - Uses slice() internally for safe index handling
59
177
  */
60
178
  replaceRange(start: number, end: number, replaceString?: string): string;
61
179
  }
62
180
  }
181
+ export {};
@@ -1,7 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const utils_1 = require("../utils");
4
- (0, utils_1.defineIfNotExists)(String.prototype, 'splitWords', function () {
3
+ const core_utils_1 = require("../utils/core.utils");
4
+ /**
5
+ * @see String.prototype.splitWords
6
+ */
7
+ (0, core_utils_1.defineIfNotExists)(String.prototype, 'splitWords', function () {
5
8
  return this.replace(/([a-z0-9])([A-Z])/g, '$1 $2') // helloWorld → hello World
6
9
  .replace(/([A-Z])([A-Z][a-z])/g, '$1 $2') // HTMLParser → HTML Parser
7
10
  .replace(/[^a-zA-Z0-9]+/g, ' ')
@@ -9,47 +12,74 @@ const utils_1 = require("../utils");
9
12
  .split(/\s+/)
10
13
  .filter(Boolean);
11
14
  });
12
- (0, utils_1.defineIfNotExists)(String.prototype, 'camelCase', function () {
15
+ /**
16
+ * @see String.prototype.camelCase
17
+ */
18
+ (0, core_utils_1.defineIfNotExists)(String.prototype, 'camelCase', function () {
13
19
  const words = this.splitWords().map((w) => w.toLowerCase());
14
20
  return words
15
21
  .map((word, i) => (i === 0 ? word : word.charAt(0).toUpperCase() + word.slice(1)))
16
22
  .join('');
17
23
  });
18
- (0, utils_1.defineIfNotExists)(String.prototype, 'kebabCase', function () {
24
+ /**
25
+ * @see String.prototype.kebabCase
26
+ */
27
+ (0, core_utils_1.defineIfNotExists)(String.prototype, 'kebabCase', function () {
19
28
  return this.splitWords()
20
29
  .map((w) => w.toLowerCase())
21
30
  .join('-');
22
31
  });
23
- (0, utils_1.defineIfNotExists)(String.prototype, 'snakeCase', function () {
32
+ /**
33
+ * @see String.prototype.snakeCase
34
+ */
35
+ (0, core_utils_1.defineIfNotExists)(String.prototype, 'snakeCase', function () {
24
36
  return this.splitWords()
25
37
  .map((w) => w.toLowerCase())
26
38
  .join('_');
27
39
  });
28
- (0, utils_1.defineIfNotExists)(String.prototype, 'truncate', function (n) {
40
+ /**
41
+ * @see String.prototype.truncate
42
+ */
43
+ (0, core_utils_1.defineIfNotExists)(String.prototype, 'truncate', function (n) {
29
44
  if (typeof n !== 'number' || !Number.isInteger(n) || n < 0) {
30
45
  throw new TypeError('Truncate length must be a non-negative integer');
31
46
  }
32
47
  return this.length > n ? this.slice(0, n) + '...' : this.toString();
33
48
  });
34
- (0, utils_1.defineIfNotExists)(String.prototype, 'reverse', function () {
49
+ /**
50
+ * @see String.prototype.reverse
51
+ */
52
+ (0, core_utils_1.defineIfNotExists)(String.prototype, 'reverse', function () {
35
53
  return [...this].reverse().join('');
36
54
  });
37
- (0, utils_1.defineIfNotExists)(String.prototype, 'isEmpty', function () {
55
+ /**
56
+ * @see String.prototype.isEmpty
57
+ */
58
+ (0, core_utils_1.defineIfNotExists)(String.prototype, 'isEmpty', function () {
38
59
  return this.trim().length === 0;
39
60
  });
40
- (0, utils_1.defineIfNotExists)(String.prototype, 'slugify', function () {
61
+ /**
62
+ * @see String.prototype.slugify
63
+ */
64
+ (0, core_utils_1.defineIfNotExists)(String.prototype, 'slugify', function () {
41
65
  return this.normalize('NFD')
42
66
  .replace(/[̀-ͯ]/g, '')
43
67
  .replace(/[^a-zA-Z0-9]+/g, '-')
44
68
  .replace(/^-+|-+$/g, '')
45
69
  .toLowerCase();
46
70
  });
47
- (0, utils_1.defineIfNotExists)(String.prototype, 'capitalize', function () {
71
+ /**
72
+ * @see String.prototype.capitalize
73
+ */
74
+ (0, core_utils_1.defineIfNotExists)(String.prototype, 'capitalize', function () {
48
75
  if (this.length === 0)
49
76
  return '';
50
77
  return this.charAt(0).toUpperCase() + this.slice(1);
51
78
  });
52
- (0, utils_1.defineIfNotExists)(String.prototype, 'replaceRange', function (start, end, replaceString = '') {
79
+ /**
80
+ * @see String.prototype.replaceRange
81
+ */
82
+ (0, core_utils_1.defineIfNotExists)(String.prototype, 'replaceRange', function (start, end, replaceString = '') {
53
83
  if (!Number.isInteger(start) || !Number.isInteger(end)) {
54
84
  throw new TypeError('start and end must be integers');
55
85
  }
@@ -0,0 +1 @@
1
+ import '../string/string-prototype';