@naman_deep_singh/utils 2.1.0 → 2.2.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/README.md +1 -1
- package/dist/cjs/array/array-extensions.js +23 -23
- package/dist/cjs/array/index.js +2 -2
- package/dist/cjs/core/index.js +2 -2
- package/dist/cjs/core/performance.js +2 -2
- package/dist/cjs/extensions/index.js +4 -4
- package/dist/cjs/index.js +29 -75
- package/dist/cjs/init/index.js +2 -2
- package/dist/cjs/init/initializer.js +10 -11
- package/dist/cjs/number/index.js +2 -2
- package/dist/cjs/number/number-extensions.js +23 -23
- package/dist/cjs/object/index.js +2 -2
- package/dist/cjs/object/object-extensions.js +14 -14
- package/dist/cjs/string/index.js +2 -2
- package/dist/cjs/string/string-extensions.js +22 -22
- package/dist/cjs/types/index.js +2 -2
- package/dist/cjs/utils/index.js +3 -3
- package/dist/esm/array/array-extensions.js +1 -1
- package/dist/esm/array/index.js +1 -1
- package/dist/esm/core/index.js +2 -2
- package/dist/esm/core/performance.js +1 -1
- package/dist/esm/extensions/index.js +4 -4
- package/dist/esm/index.js +15 -68
- package/dist/esm/init/index.js +2 -2
- package/dist/esm/init/initializer.js +5 -6
- package/dist/esm/number/index.js +1 -1
- package/dist/esm/number/number-extensions.js +2 -2
- package/dist/esm/object/index.js +1 -1
- package/dist/esm/object/object-extensions.js +1 -1
- package/dist/esm/string/index.js +1 -1
- package/dist/esm/string/string-extensions.js +1 -1
- package/dist/esm/types/index.js +2 -2
- package/dist/esm/utils/index.js +3 -3
- package/dist/types/array/index.d.ts +1 -1
- package/dist/types/core/index.d.ts +2 -2
- package/dist/types/extensions/index.d.ts +4 -4
- package/dist/types/index.d.ts +10 -61
- package/dist/types/init/index.d.ts +2 -2
- package/dist/types/init/initializer.d.ts +1 -1
- package/dist/types/init/options.d.ts +1 -1
- package/dist/types/number/index.d.ts +1 -1
- package/dist/types/object/index.d.ts +1 -1
- package/dist/types/string/index.d.ts +1 -1
- package/dist/types/types/extension-types.d.ts +1 -1
- package/dist/types/types/global-augmentations.d.ts +37 -24
- package/dist/types/types/index.d.ts +2 -2
- package/dist/types/utils/config.d.ts +1 -1
- package/dist/types/utils/index.d.ts +3 -3
- package/package.json +52 -4
- package/dist/cjs/array/array-extensions.d.ts +0 -1
- package/dist/cjs/array/index.d.ts +0 -1
- package/dist/cjs/core/index.d.ts +0 -2
- package/dist/cjs/core/performance.d.ts +0 -17
- package/dist/cjs/core/validation.d.ts +0 -4
- package/dist/cjs/core/version.d.ts +0 -1
- package/dist/cjs/extensions/index.d.ts +0 -4
- package/dist/cjs/index.d.ts +0 -61
- package/dist/cjs/init/index.d.ts +0 -2
- package/dist/cjs/init/initializer.d.ts +0 -3
- package/dist/cjs/init/options.d.ts +0 -3
- package/dist/cjs/number/index.d.ts +0 -1
- package/dist/cjs/number/number-extensions.d.ts +0 -1
- package/dist/cjs/object/index.d.ts +0 -1
- package/dist/cjs/object/object-extensions.d.ts +0 -1
- package/dist/cjs/string/index.d.ts +0 -1
- package/dist/cjs/string/string-extensions.d.ts +0 -1
- package/dist/cjs/types/extension-types.d.ts +0 -9
- package/dist/cjs/types/global-augmentations.d.ts +0 -72
- package/dist/cjs/types/index.d.ts +0 -2
- package/dist/cjs/utils/config.d.ts +0 -4
- package/dist/cjs/utils/defineExtension.d.ts +0 -1
- package/dist/cjs/utils/helpers.d.ts +0 -5
- package/dist/cjs/utils/index.d.ts +0 -3
- package/dist/esm/array/array-extensions.d.ts +0 -1
- package/dist/esm/array/index.d.ts +0 -1
- package/dist/esm/core/index.d.ts +0 -2
- package/dist/esm/core/performance.d.ts +0 -17
- package/dist/esm/core/validation.d.ts +0 -4
- package/dist/esm/core/version.d.ts +0 -1
- package/dist/esm/extensions/index.d.ts +0 -4
- package/dist/esm/index.d.ts +0 -61
- package/dist/esm/init/index.d.ts +0 -2
- package/dist/esm/init/initializer.d.ts +0 -3
- package/dist/esm/init/options.d.ts +0 -3
- package/dist/esm/number/index.d.ts +0 -1
- package/dist/esm/number/number-extensions.d.ts +0 -1
- package/dist/esm/object/index.d.ts +0 -1
- package/dist/esm/object/object-extensions.d.ts +0 -1
- package/dist/esm/string/index.d.ts +0 -1
- package/dist/esm/string/string-extensions.d.ts +0 -1
- package/dist/esm/types/extension-types.d.ts +0 -9
- package/dist/esm/types/global-augmentations.d.ts +0 -72
- package/dist/esm/types/index.d.ts +0 -2
- package/dist/esm/utils/config.d.ts +0 -4
- package/dist/esm/utils/defineExtension.d.ts +0 -1
- package/dist/esm/utils/helpers.d.ts +0 -5
- package/dist/esm/utils/index.d.ts +0 -3
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.extendString = extendString;
|
|
4
|
-
const
|
|
4
|
+
const index_js_1 = require("../utils/index.js");
|
|
5
5
|
let stringExtended = false;
|
|
6
6
|
function extendString() {
|
|
7
7
|
if (stringExtended)
|
|
8
8
|
return;
|
|
9
9
|
stringExtended = true;
|
|
10
|
-
(0,
|
|
10
|
+
(0, index_js_1.defineExtension)(String.prototype, 'toCapitalize', function () {
|
|
11
11
|
return this.charAt(0).toUpperCase() + this.slice(1).toLowerCase();
|
|
12
12
|
});
|
|
13
|
-
(0,
|
|
13
|
+
(0, index_js_1.defineExtension)(String.prototype, 'toCamelCase', function () {
|
|
14
14
|
return this.replace(/[-_\s]+(.)?/g, (_, char) => char ? char.toUpperCase() : '');
|
|
15
15
|
});
|
|
16
|
-
(0,
|
|
16
|
+
(0, index_js_1.defineExtension)(String.prototype, 'toKebabCase', function () {
|
|
17
17
|
return this.replace(/([a-z])([A-Z])/g, '$1-$2')
|
|
18
18
|
.replace(/[\s_]+/g, '-')
|
|
19
19
|
.toLowerCase();
|
|
20
20
|
});
|
|
21
|
-
(0,
|
|
21
|
+
(0, index_js_1.defineExtension)(String.prototype, 'toSnakeCase', function () {
|
|
22
22
|
return this.replace(/([a-z])([A-Z])/g, '$1_$2')
|
|
23
23
|
.replace(/[\s-]+/g, '_')
|
|
24
24
|
.toLowerCase();
|
|
25
25
|
});
|
|
26
|
-
(0,
|
|
26
|
+
(0, index_js_1.defineExtension)(String.prototype, 'truncate', function (length, suffix = '...') {
|
|
27
27
|
if (!Number.isInteger(length) || length < 0) {
|
|
28
28
|
throw new TypeError(`truncate: length must be a non-negative integer, got ${length}`);
|
|
29
29
|
}
|
|
@@ -31,11 +31,11 @@ function extendString() {
|
|
|
31
31
|
? this.substring(0, length) + suffix
|
|
32
32
|
: this.toString();
|
|
33
33
|
});
|
|
34
|
-
(0,
|
|
34
|
+
(0, index_js_1.defineExtension)(String.prototype, 'isEmail', function () {
|
|
35
35
|
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
36
36
|
return emailRegex.test(this.toString());
|
|
37
37
|
});
|
|
38
|
-
(0,
|
|
38
|
+
(0, index_js_1.defineExtension)(String.prototype, 'isUrl', function () {
|
|
39
39
|
try {
|
|
40
40
|
new URL(this.toString());
|
|
41
41
|
return true;
|
|
@@ -44,23 +44,23 @@ function extendString() {
|
|
|
44
44
|
return false;
|
|
45
45
|
}
|
|
46
46
|
});
|
|
47
|
-
(0,
|
|
47
|
+
(0, index_js_1.defineExtension)(String.prototype, 'removeWhitespace', function () {
|
|
48
48
|
return this.replace(/\s+/g, '');
|
|
49
49
|
});
|
|
50
|
-
(0,
|
|
50
|
+
(0, index_js_1.defineExtension)(String.prototype, 'reverse', function () {
|
|
51
51
|
return this.split('').reverse().join('');
|
|
52
52
|
});
|
|
53
|
-
(0,
|
|
53
|
+
(0, index_js_1.defineExtension)(String.prototype, 'isPalindrome', function () {
|
|
54
54
|
const cleaned = this.toLowerCase().replace(/[^a-z0-9]/g, '');
|
|
55
55
|
return cleaned === cleaned.split('').reverse().join('');
|
|
56
56
|
});
|
|
57
|
-
(0,
|
|
57
|
+
(0, index_js_1.defineExtension)(String.prototype, 'toTitleCase', function () {
|
|
58
58
|
return this.replace(/\w\S*/g, (txt) => txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase());
|
|
59
59
|
});
|
|
60
|
-
(0,
|
|
60
|
+
(0, index_js_1.defineExtension)(String.prototype, 'stripHtml', function () {
|
|
61
61
|
return this.replace(/<[^>]*>/g, '');
|
|
62
62
|
});
|
|
63
|
-
(0,
|
|
63
|
+
(0, index_js_1.defineExtension)(String.prototype, 'padStart', function (targetLength, padString = ' ') {
|
|
64
64
|
if (!Number.isInteger(targetLength) || targetLength < 0) {
|
|
65
65
|
throw new TypeError(`padStart: targetLength must be a non-negative integer, got ${targetLength}`);
|
|
66
66
|
}
|
|
@@ -72,7 +72,7 @@ function extendString() {
|
|
|
72
72
|
}
|
|
73
73
|
return this.toString().padStart(targetLength, padString);
|
|
74
74
|
});
|
|
75
|
-
(0,
|
|
75
|
+
(0, index_js_1.defineExtension)(String.prototype, 'padEnd', function (targetLength, padString = ' ') {
|
|
76
76
|
if (!Number.isInteger(targetLength) || targetLength < 0) {
|
|
77
77
|
throw new TypeError(`padEnd: targetLength must be a non-negative integer, got ${targetLength}`);
|
|
78
78
|
}
|
|
@@ -84,7 +84,7 @@ function extendString() {
|
|
|
84
84
|
}
|
|
85
85
|
return this.toString().padEnd(targetLength, padString);
|
|
86
86
|
});
|
|
87
|
-
(0,
|
|
87
|
+
(0, index_js_1.defineExtension)(String.prototype, 'count', function (substring) {
|
|
88
88
|
if (typeof substring !== 'string') {
|
|
89
89
|
throw new TypeError(`count: substring must be a string, got ${typeof substring}`);
|
|
90
90
|
}
|
|
@@ -94,21 +94,21 @@ function extendString() {
|
|
|
94
94
|
const escaped = substring.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
95
95
|
return (this.match(new RegExp(escaped, 'g')) || []).length;
|
|
96
96
|
});
|
|
97
|
-
(0,
|
|
97
|
+
(0, index_js_1.defineExtension)(String.prototype, 'words', function () {
|
|
98
98
|
return this.trim()
|
|
99
99
|
.split(/\s+/)
|
|
100
100
|
.filter((word) => word.length > 0);
|
|
101
101
|
});
|
|
102
|
-
(0,
|
|
102
|
+
(0, index_js_1.defineExtension)(String.prototype, 'lines', function () {
|
|
103
103
|
return this.split(/\r?\n/);
|
|
104
104
|
});
|
|
105
|
-
(0,
|
|
105
|
+
(0, index_js_1.defineExtension)(String.prototype, 'capitalizeWords', function () {
|
|
106
106
|
return this.toString().replace(/\b\w/g, (char) => char.toUpperCase());
|
|
107
107
|
});
|
|
108
|
-
(0,
|
|
108
|
+
(0, index_js_1.defineExtension)(String.prototype, 'reverseWords', function () {
|
|
109
109
|
return this.toString().split(/\s+/).reverse().join(' ');
|
|
110
110
|
});
|
|
111
|
-
(0,
|
|
111
|
+
(0, index_js_1.defineExtension)(String.prototype, 'truncateWords', function (count, suffix = '...') {
|
|
112
112
|
if (!Number.isInteger(count) || count < 0) {
|
|
113
113
|
throw new TypeError(`truncateWords: count must be a non-negative integer, got ${count}`);
|
|
114
114
|
}
|
|
@@ -117,7 +117,7 @@ function extendString() {
|
|
|
117
117
|
return this.toString();
|
|
118
118
|
return words.slice(0, count).join(' ') + suffix;
|
|
119
119
|
});
|
|
120
|
-
(0,
|
|
120
|
+
(0, index_js_1.defineExtension)(String.prototype, 'slugify', function () {
|
|
121
121
|
return this.toString()
|
|
122
122
|
.toLowerCase()
|
|
123
123
|
.replace(/[^\w\s-]/g, '')
|
package/dist/cjs/types/index.js
CHANGED
|
@@ -15,5 +15,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
// Re-export all types
|
|
18
|
-
__exportStar(require("./extension-types"), exports);
|
|
19
|
-
__exportStar(require("./global-augmentations"), exports);
|
|
18
|
+
__exportStar(require("./extension-types.js"), exports);
|
|
19
|
+
__exportStar(require("./global-augmentations.js"), exports);
|
package/dist/cjs/utils/index.js
CHANGED
|
@@ -15,6 +15,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
// Re-export all utilities
|
|
18
|
-
__exportStar(require("./config"), exports);
|
|
19
|
-
__exportStar(require("./helpers"), exports);
|
|
20
|
-
__exportStar(require("./defineExtension"), exports);
|
|
18
|
+
__exportStar(require("./config.js"), exports);
|
|
19
|
+
__exportStar(require("./helpers.js"), exports);
|
|
20
|
+
__exportStar(require("./defineExtension.js"), exports);
|
package/dist/esm/array/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { extendArray } from './array-extensions';
|
|
1
|
+
export { extendArray } from './array-extensions.js';
|
package/dist/esm/core/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// Re-export core utilities
|
|
2
|
-
export * from './validation';
|
|
3
|
-
export * from './performance';
|
|
2
|
+
export * from './validation.js';
|
|
3
|
+
export * from './performance.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Re-export all extensions
|
|
2
|
-
export * from '../string';
|
|
3
|
-
export * from '../array';
|
|
4
|
-
export * from '../object';
|
|
5
|
-
export * from '../number';
|
|
2
|
+
export * from '../string/index.js';
|
|
3
|
+
export * from '../array/index.js';
|
|
4
|
+
export * from '../object/index.js';
|
|
5
|
+
export * from '../number/index.js';
|
package/dist/esm/index.js
CHANGED
|
@@ -1,68 +1,15 @@
|
|
|
1
|
-
//
|
|
2
|
-
import '
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
//
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
export { withCache };
|
|
17
|
-
// Import initialization functions
|
|
18
|
-
import { extendAll, initExtensions } from './init/initializer';
|
|
19
|
-
/**
|
|
20
|
-
* Initialize JavaScript prototype extensions
|
|
21
|
-
* @param options - Configure which extensions to enable (default: all enabled)
|
|
22
|
-
*/
|
|
23
|
-
export function initializeExtensions(options = {}) {
|
|
24
|
-
initExtensions(options);
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Initialize all extensions (convenience function)
|
|
28
|
-
*/
|
|
29
|
-
export { extendAll };
|
|
30
|
-
/**
|
|
31
|
-
* Selective prototype extension helpers
|
|
32
|
-
* Initialize only specific extensions
|
|
33
|
-
*/
|
|
34
|
-
export const extend = {
|
|
35
|
-
string: extendString,
|
|
36
|
-
array: extendArray,
|
|
37
|
-
object: extendObject,
|
|
38
|
-
number: extendNumber,
|
|
39
|
-
};
|
|
40
|
-
// Export validation utilities
|
|
41
|
-
export { validateExtensionInput, validateArrayInput, validateNumberRange, validatePositiveInteger, };
|
|
42
|
-
// Export utility functions
|
|
43
|
-
export { validateConfig, validatePerformanceSettings, mergeConfigs, isValidArrayIndex, ensurePositiveInteger, safeClone, getPathSegments, hasOwnProperty, };
|
|
44
|
-
// Export performance utilities
|
|
45
|
-
export { LRUCache, setPerformanceConfig, getPerformanceConfig };
|
|
46
|
-
// Default export
|
|
47
|
-
export default {
|
|
48
|
-
initializeExtensions,
|
|
49
|
-
extendAll,
|
|
50
|
-
extend,
|
|
51
|
-
LRUCache,
|
|
52
|
-
setPerformanceConfig,
|
|
53
|
-
getPerformanceConfig,
|
|
54
|
-
// Validation utilities
|
|
55
|
-
validateExtensionInput,
|
|
56
|
-
validateArrayInput,
|
|
57
|
-
validateNumberRange,
|
|
58
|
-
validatePositiveInteger,
|
|
59
|
-
// Utility functions
|
|
60
|
-
validateConfig,
|
|
61
|
-
validatePerformanceSettings,
|
|
62
|
-
mergeConfigs,
|
|
63
|
-
isValidArrayIndex,
|
|
64
|
-
ensurePositiveInteger,
|
|
65
|
-
safeClone,
|
|
66
|
-
getPathSegments,
|
|
67
|
-
hasOwnProperty,
|
|
68
|
-
};
|
|
1
|
+
// Global type / prototype augmentations
|
|
2
|
+
import './types/global-augmentations.js';
|
|
3
|
+
// Core language extensions
|
|
4
|
+
export * from './array/index.js';
|
|
5
|
+
export * from './number/index.js';
|
|
6
|
+
export * from './string/index.js';
|
|
7
|
+
export * from './object/index.js';
|
|
8
|
+
// Core framework & utilities
|
|
9
|
+
export * from './core/index.js';
|
|
10
|
+
export * from './utils/index.js';
|
|
11
|
+
// Initialization & setup
|
|
12
|
+
export * from './init/index.js';
|
|
13
|
+
export * from './extensions/index.js';
|
|
14
|
+
// Types
|
|
15
|
+
export * from './types/index.js';
|
package/dist/esm/init/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// Re-export initialization logic
|
|
2
|
-
export * from './initializer';
|
|
3
|
-
export * from './options';
|
|
2
|
+
export * from './initializer.js';
|
|
3
|
+
export * from './options.js';
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { extendString } from '../string';
|
|
1
|
+
import { extendArray } from "../array/index.js";
|
|
2
|
+
import { setPerformanceConfig } from "../core/index.js";
|
|
3
|
+
import { extendNumber } from "../number/index.js";
|
|
4
|
+
import { extendObject } from "../object/index.js";
|
|
5
|
+
import { extendString } from "../string/index.js";
|
|
7
6
|
export function initExtensions(options = {}) {
|
|
8
7
|
const { string = true, array = true, object = true, number = true, performance, } = options;
|
|
9
8
|
if (performance) {
|
package/dist/esm/number/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { extendNumber } from './number-extensions';
|
|
1
|
+
export { extendNumber } from './number-extensions.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { makeInternalCacheKey, withCache } from "../core/index.js";
|
|
2
|
+
import { defineExtension } from "../utils/index.js";
|
|
3
3
|
let numberExtended = false;
|
|
4
4
|
export function extendNumber() {
|
|
5
5
|
if (numberExtended)
|
package/dist/esm/object/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { extendObject } from './object-extensions';
|
|
1
|
+
export { extendObject } from './object-extensions.js';
|
package/dist/esm/string/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { extendString } from './string-extensions';
|
|
1
|
+
export { extendString } from './string-extensions.js';
|
package/dist/esm/types/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// Re-export all types
|
|
2
|
-
export * from './extension-types';
|
|
3
|
-
export * from './global-augmentations';
|
|
2
|
+
export * from './extension-types.js';
|
|
3
|
+
export * from './global-augmentations.js';
|
package/dist/esm/utils/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// Re-export all utilities
|
|
2
|
-
export * from './config';
|
|
3
|
-
export * from './helpers';
|
|
4
|
-
export * from './defineExtension';
|
|
2
|
+
export * from './config.js';
|
|
3
|
+
export * from './helpers.js';
|
|
4
|
+
export * from './defineExtension.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { extendArray } from './array-extensions';
|
|
1
|
+
export { extendArray } from './array-extensions.js';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './validation';
|
|
2
|
-
export * from './performance';
|
|
1
|
+
export * from './validation.js';
|
|
2
|
+
export * from './performance.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from '../string';
|
|
2
|
-
export * from '../array';
|
|
3
|
-
export * from '../object';
|
|
4
|
-
export * from '../number';
|
|
1
|
+
export * from '../string/index.js';
|
|
2
|
+
export * from '../array/index.js';
|
|
3
|
+
export * from '../object/index.js';
|
|
4
|
+
export * from '../number/index.js';
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,61 +1,10 @@
|
|
|
1
|
-
import '
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export { ExtensionOptions, PerformanceConfig };
|
|
12
|
-
export { withCache };
|
|
13
|
-
import { extendAll } from './init/initializer';
|
|
14
|
-
/**
|
|
15
|
-
* Initialize JavaScript prototype extensions
|
|
16
|
-
* @param options - Configure which extensions to enable (default: all enabled)
|
|
17
|
-
*/
|
|
18
|
-
export declare function initializeExtensions(options?: ExtensionOptions): void;
|
|
19
|
-
/**
|
|
20
|
-
* Initialize all extensions (convenience function)
|
|
21
|
-
*/
|
|
22
|
-
export { extendAll };
|
|
23
|
-
/**
|
|
24
|
-
* Selective prototype extension helpers
|
|
25
|
-
* Initialize only specific extensions
|
|
26
|
-
*/
|
|
27
|
-
export declare const extend: {
|
|
28
|
-
string: typeof extendString;
|
|
29
|
-
array: typeof extendArray;
|
|
30
|
-
object: typeof extendObject;
|
|
31
|
-
number: typeof extendNumber;
|
|
32
|
-
};
|
|
33
|
-
export { validateExtensionInput, validateArrayInput, validateNumberRange, validatePositiveInteger, };
|
|
34
|
-
export { validateConfig, validatePerformanceSettings, mergeConfigs, isValidArrayIndex, ensurePositiveInteger, safeClone, getPathSegments, hasOwnProperty, };
|
|
35
|
-
export { LRUCache, setPerformanceConfig, getPerformanceConfig };
|
|
36
|
-
declare const _default: {
|
|
37
|
-
initializeExtensions: typeof initializeExtensions;
|
|
38
|
-
extendAll: typeof extendAll;
|
|
39
|
-
extend: {
|
|
40
|
-
string: typeof extendString;
|
|
41
|
-
array: typeof extendArray;
|
|
42
|
-
object: typeof extendObject;
|
|
43
|
-
number: typeof extendNumber;
|
|
44
|
-
};
|
|
45
|
-
LRUCache: typeof LRUCache;
|
|
46
|
-
setPerformanceConfig: typeof setPerformanceConfig;
|
|
47
|
-
getPerformanceConfig: typeof getPerformanceConfig;
|
|
48
|
-
validateExtensionInput: typeof validateExtensionInput;
|
|
49
|
-
validateArrayInput: typeof validateArrayInput;
|
|
50
|
-
validateNumberRange: typeof validateNumberRange;
|
|
51
|
-
validatePositiveInteger: typeof validatePositiveInteger;
|
|
52
|
-
validateConfig: typeof validateConfig;
|
|
53
|
-
validatePerformanceSettings: typeof validatePerformanceSettings;
|
|
54
|
-
mergeConfigs: typeof mergeConfigs;
|
|
55
|
-
isValidArrayIndex: typeof isValidArrayIndex;
|
|
56
|
-
ensurePositiveInteger: typeof ensurePositiveInteger;
|
|
57
|
-
safeClone: typeof safeClone;
|
|
58
|
-
getPathSegments: typeof getPathSegments;
|
|
59
|
-
hasOwnProperty: typeof hasOwnProperty;
|
|
60
|
-
};
|
|
61
|
-
export default _default;
|
|
1
|
+
import './types/global-augmentations.js';
|
|
2
|
+
export * from './array/index.js';
|
|
3
|
+
export * from './number/index.js';
|
|
4
|
+
export * from './string/index.js';
|
|
5
|
+
export * from './object/index.js';
|
|
6
|
+
export * from './core/index.js';
|
|
7
|
+
export * from './utils/index.js';
|
|
8
|
+
export * from './init/index.js';
|
|
9
|
+
export * from './extensions/index.js';
|
|
10
|
+
export * from './types/index.js';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './initializer';
|
|
2
|
-
export * from './options';
|
|
1
|
+
export * from './initializer.js';
|
|
2
|
+
export * from './options.js';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { ExtensionOptions } from
|
|
1
|
+
import type { ExtensionOptions } from "../types/index.js";
|
|
2
2
|
export declare function validateExtensionOptions(options: Partial<ExtensionOptions>): ExtensionOptions;
|
|
3
3
|
export declare function createExtensionOptions(enableString?: boolean, enableArray?: boolean, enableObject?: boolean, enableNumber?: boolean, performanceConfig?: any): ExtensionOptions;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { extendNumber } from './number-extensions';
|
|
1
|
+
export { extendNumber } from './number-extensions.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { extendObject } from './object-extensions';
|
|
1
|
+
export { extendObject } from './object-extensions.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { extendString } from './string-extensions';
|
|
1
|
+
export { extendString } from './string-extensions.js';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export {};
|
|
1
2
|
declare global {
|
|
2
3
|
interface String {
|
|
3
4
|
toCapitalize(): string;
|
|
@@ -5,21 +6,46 @@ declare global {
|
|
|
5
6
|
toKebabCase(): string;
|
|
6
7
|
toSnakeCase(): string;
|
|
7
8
|
truncate(length: number, suffix?: string): string;
|
|
9
|
+
truncateWords(count: number, suffix?: string): string;
|
|
10
|
+
toTitleCase(): string;
|
|
11
|
+
capitalizeWords(): string;
|
|
12
|
+
reverseWords(): string;
|
|
8
13
|
isEmail(): boolean;
|
|
9
14
|
isUrl(): boolean;
|
|
10
|
-
removeWhitespace(): string;
|
|
11
|
-
reverse(): string;
|
|
12
15
|
isPalindrome(): boolean;
|
|
13
|
-
|
|
16
|
+
removeWhitespace(): string;
|
|
14
17
|
stripHtml(): string;
|
|
15
18
|
padStart(targetLength: number, padString?: string): string;
|
|
16
19
|
padEnd(targetLength: number, padString?: string): string;
|
|
17
20
|
count(substring: string): number;
|
|
18
21
|
words(): string[];
|
|
19
22
|
lines(): string[];
|
|
23
|
+
reverse(): string;
|
|
24
|
+
slugify(): string;
|
|
25
|
+
}
|
|
26
|
+
interface Number {
|
|
27
|
+
toPercent(decimals?: number): string;
|
|
28
|
+
toCurrency(currency?: string, locale?: string): string;
|
|
29
|
+
clamp(min: number, max: number): number;
|
|
30
|
+
inRange(min: number, max: number): boolean;
|
|
31
|
+
isEven(): boolean;
|
|
32
|
+
isOdd(): boolean;
|
|
33
|
+
isPrime(): boolean;
|
|
34
|
+
factorial(): number;
|
|
35
|
+
toOrdinal(): string;
|
|
36
|
+
toRoman(): string;
|
|
37
|
+
round(decimals?: number): number;
|
|
38
|
+
ceil(decimals?: number): number;
|
|
39
|
+
floor(decimals?: number): number;
|
|
40
|
+
toFixedNumber(decimals?: number): number;
|
|
41
|
+
abs(): number;
|
|
42
|
+
sign(): number;
|
|
43
|
+
times(callback: (index: number) => void): void;
|
|
44
|
+
randomUpTo(): number;
|
|
20
45
|
}
|
|
21
46
|
interface Array<T> {
|
|
22
47
|
unique(): T[];
|
|
48
|
+
uniqueBy<K>(keyFn: (item: T) => K): T[];
|
|
23
49
|
shuffle(): T[];
|
|
24
50
|
chunk(size: number): T[][];
|
|
25
51
|
groupBy<K extends string | number>(keyFn: (item: T) => K): Record<K, T[]>;
|
|
@@ -38,35 +64,22 @@ declare global {
|
|
|
38
64
|
sample(): T | undefined;
|
|
39
65
|
take(count: number): T[];
|
|
40
66
|
drop(count: number): T[];
|
|
67
|
+
sortBy(keyFn: (item: T) => any): T[];
|
|
68
|
+
last(): T | undefined;
|
|
41
69
|
}
|
|
42
70
|
interface Object {
|
|
43
71
|
isEmpty(): boolean;
|
|
44
72
|
pick<T extends Record<string, any>, K extends keyof T>(keys: K[]): Pick<T, K>;
|
|
45
73
|
omit<T extends Record<string, any>, K extends keyof T>(keys: K[]): Omit<T, K>;
|
|
74
|
+
merge<T extends object>(other: Partial<T>): T;
|
|
46
75
|
deepClone<T>(): T;
|
|
47
|
-
merge(other: Record<string, any>): Record<string, any>;
|
|
48
76
|
deepFreeze<T>(): T;
|
|
49
77
|
hasPath(path: string): boolean;
|
|
50
78
|
getPath(path: string, defaultValue?: any): any;
|
|
51
|
-
setPath(path: string, value: any):
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
clamp(min: number, max: number): number;
|
|
57
|
-
isEven(): boolean;
|
|
58
|
-
isOdd(): boolean;
|
|
59
|
-
isPrime(): boolean;
|
|
60
|
-
factorial(): number;
|
|
61
|
-
toOrdinal(): string;
|
|
62
|
-
toRoman(): string;
|
|
63
|
-
inRange(min: number, max: number): boolean;
|
|
64
|
-
round(decimals?: number): number;
|
|
65
|
-
ceil(decimals?: number): number;
|
|
66
|
-
floor(decimals?: number): number;
|
|
67
|
-
abs(): number;
|
|
68
|
-
sign(): number;
|
|
69
|
-
times(callback: (index: number) => void): void;
|
|
79
|
+
setPath(path: string, value: any): this;
|
|
80
|
+
mapValues<T extends Record<string, any>>(fn: (value: T[keyof T], key: keyof T) => any): Record<string, any>;
|
|
81
|
+
mapKeys<T extends Record<string, any>>(fn: (key: keyof T) => string | number | symbol): Record<string, any>;
|
|
82
|
+
filterKeys<T extends Record<string, any>>(keys: (keyof T)[]): Partial<T>;
|
|
83
|
+
filterValues<T extends Record<string, any>>(fn: (value: T[keyof T], key: keyof T) => boolean): Partial<T>;
|
|
70
84
|
}
|
|
71
85
|
}
|
|
72
|
-
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './extension-types';
|
|
2
|
-
export * from './global-augmentations';
|
|
1
|
+
export * from './extension-types.js';
|
|
2
|
+
export * from './global-augmentations.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PerformanceConfig } from
|
|
1
|
+
import type { PerformanceConfig } from "../core/index.js";
|
|
2
2
|
export declare function validateConfig(config: Partial<PerformanceConfig>, defaultConfig: PerformanceConfig): PerformanceConfig;
|
|
3
3
|
export declare function validatePerformanceSettings(settings: Partial<PerformanceConfig>): PerformanceConfig;
|
|
4
4
|
export declare function mergeConfigs<T extends Record<string, any>>(base: T, override: Partial<T>): T;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './config';
|
|
2
|
-
export * from './helpers';
|
|
3
|
-
export * from './defineExtension';
|
|
1
|
+
export * from './config.js';
|
|
2
|
+
export * from './helpers.js';
|
|
3
|
+
export * from './defineExtension.js';
|