my-awesome-utils-ufeek 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.
- package/LICENSE +21 -0
- package/README.md +71 -0
- package/dist/index.d.mts +74 -0
- package/dist/index.d.ts +74 -0
- package/dist/index.js +157 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +115 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +35 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# my-awesome-utils
|
|
2
|
+
|
|
3
|
+
A simple collection of useful utility functions for JavaScript/TypeScript projects.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install my-awesome-utils
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { capitalize, slugify, formatRupiah, chunk, isEmpty } from "my-awesome-utils";
|
|
15
|
+
|
|
16
|
+
// String utilities
|
|
17
|
+
capitalize("hello"); // "Hello"
|
|
18
|
+
slugify("Hello World!"); // "hello-world"
|
|
19
|
+
|
|
20
|
+
// Number utilities
|
|
21
|
+
formatRupiah(50000); // "Rp 50.000"
|
|
22
|
+
|
|
23
|
+
// Array utilities
|
|
24
|
+
chunk([1, 2, 3, 4, 5], 2); // [[1,2], [3,4], [5]]
|
|
25
|
+
|
|
26
|
+
// Object utilities
|
|
27
|
+
isEmpty({}); // true
|
|
28
|
+
isEmpty(" "); // true
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## API Reference
|
|
32
|
+
|
|
33
|
+
### String Utilities
|
|
34
|
+
|
|
35
|
+
| Function | Description |
|
|
36
|
+
|----------|-------------|
|
|
37
|
+
| `capitalize(str)` | Capitalize the first letter of a string |
|
|
38
|
+
| `slugify(str)` | Convert a string to URL-friendly slug format |
|
|
39
|
+
| `truncate(str, maxLength, suffix?)` | Truncate a string with ellipsis |
|
|
40
|
+
| `randomString(length?)` | Generate a random alphanumeric string |
|
|
41
|
+
|
|
42
|
+
### Number Utilities
|
|
43
|
+
|
|
44
|
+
| Function | Description |
|
|
45
|
+
|----------|-------------|
|
|
46
|
+
| `clamp(value, min, max)` | Clamp a number between min and max |
|
|
47
|
+
| `randomInt(min, max)` | Generate a random integer (inclusive) |
|
|
48
|
+
| `formatRupiah(amount)` | Format number to Indonesian Rupiah |
|
|
49
|
+
| `percentage(value, total)` | Calculate percentage |
|
|
50
|
+
|
|
51
|
+
### Array Utilities
|
|
52
|
+
|
|
53
|
+
| Function | Description |
|
|
54
|
+
|----------|-------------|
|
|
55
|
+
| `shuffle(array)` | Shuffle an array (Fisher-Yates) |
|
|
56
|
+
| `unique(array)` | Get unique values from an array |
|
|
57
|
+
| `chunk(array, size)` | Split array into chunks |
|
|
58
|
+
| `groupBy(array, keyFn)` | Group array items by a key function |
|
|
59
|
+
|
|
60
|
+
### Object Utilities
|
|
61
|
+
|
|
62
|
+
| Function | Description |
|
|
63
|
+
|----------|-------------|
|
|
64
|
+
| `deepClone(obj)` | Deep clone an object |
|
|
65
|
+
| `pick(obj, keys)` | Pick specific keys from an object |
|
|
66
|
+
| `omit(obj, keys)` | Omit specific keys from an object |
|
|
67
|
+
| `isEmpty(value)` | Check if a value is empty |
|
|
68
|
+
|
|
69
|
+
## License
|
|
70
|
+
|
|
71
|
+
MIT
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Capitalize the first letter of a string
|
|
3
|
+
*/
|
|
4
|
+
declare function capitalize(str: string): string;
|
|
5
|
+
/**
|
|
6
|
+
* Convert a string to slug format (URL-friendly)
|
|
7
|
+
* @example slugify("Hello World!") => "hello-world"
|
|
8
|
+
*/
|
|
9
|
+
declare function slugify(str: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* Truncate a string to a specified length and append ellipsis
|
|
12
|
+
*/
|
|
13
|
+
declare function truncate(str: string, maxLength: number, suffix?: string): string;
|
|
14
|
+
/**
|
|
15
|
+
* Generate a random string with given length
|
|
16
|
+
*/
|
|
17
|
+
declare function randomString(length?: number): string;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Clamp a number between a minimum and maximum value
|
|
21
|
+
*/
|
|
22
|
+
declare function clamp(value: number, min: number, max: number): number;
|
|
23
|
+
/**
|
|
24
|
+
* Generate a random integer between min and max (inclusive)
|
|
25
|
+
*/
|
|
26
|
+
declare function randomInt(min: number, max: number): number;
|
|
27
|
+
/**
|
|
28
|
+
* Format a number to Indonesian Rupiah currency
|
|
29
|
+
* @example formatRupiah(50000) => "Rp 50.000"
|
|
30
|
+
*/
|
|
31
|
+
declare function formatRupiah(amount: number): string;
|
|
32
|
+
/**
|
|
33
|
+
* Calculate percentage of a value
|
|
34
|
+
*/
|
|
35
|
+
declare function percentage(value: number, total: number): number;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Shuffle an array using Fisher-Yates algorithm
|
|
39
|
+
*/
|
|
40
|
+
declare function shuffle<T>(array: T[]): T[];
|
|
41
|
+
/**
|
|
42
|
+
* Get unique values from an array
|
|
43
|
+
*/
|
|
44
|
+
declare function unique<T>(array: T[]): T[];
|
|
45
|
+
/**
|
|
46
|
+
* Chunk an array into smaller arrays of a specified size
|
|
47
|
+
* @example chunk([1,2,3,4,5], 2) => [[1,2],[3,4],[5]]
|
|
48
|
+
*/
|
|
49
|
+
declare function chunk<T>(array: T[], size: number): T[][];
|
|
50
|
+
/**
|
|
51
|
+
* Group array items by a key function
|
|
52
|
+
*/
|
|
53
|
+
declare function groupBy<T>(array: T[], keyFn: (item: T) => string): Record<string, T[]>;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Deep clone an object (structured clone)
|
|
57
|
+
*/
|
|
58
|
+
declare function deepClone<T>(obj: T): T;
|
|
59
|
+
/**
|
|
60
|
+
* Pick specific keys from an object
|
|
61
|
+
* @example pick({ a: 1, b: 2, c: 3 }, ['a', 'c']) => { a: 1, c: 3 }
|
|
62
|
+
*/
|
|
63
|
+
declare function pick<T extends Record<string, unknown>, K extends keyof T>(obj: T, keys: K[]): Pick<T, K>;
|
|
64
|
+
/**
|
|
65
|
+
* Omit specific keys from an object
|
|
66
|
+
* @example omit({ a: 1, b: 2, c: 3 }, ['b']) => { a: 1, c: 3 }
|
|
67
|
+
*/
|
|
68
|
+
declare function omit<T extends Record<string, unknown>, K extends keyof T>(obj: T, keys: K[]): Omit<T, K>;
|
|
69
|
+
/**
|
|
70
|
+
* Check if a value is empty (null, undefined, empty string, empty array, empty object)
|
|
71
|
+
*/
|
|
72
|
+
declare function isEmpty(value: unknown): boolean;
|
|
73
|
+
|
|
74
|
+
export { capitalize, chunk, clamp, deepClone, formatRupiah, groupBy, isEmpty, omit, percentage, pick, randomInt, randomString, shuffle, slugify, truncate, unique };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Capitalize the first letter of a string
|
|
3
|
+
*/
|
|
4
|
+
declare function capitalize(str: string): string;
|
|
5
|
+
/**
|
|
6
|
+
* Convert a string to slug format (URL-friendly)
|
|
7
|
+
* @example slugify("Hello World!") => "hello-world"
|
|
8
|
+
*/
|
|
9
|
+
declare function slugify(str: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* Truncate a string to a specified length and append ellipsis
|
|
12
|
+
*/
|
|
13
|
+
declare function truncate(str: string, maxLength: number, suffix?: string): string;
|
|
14
|
+
/**
|
|
15
|
+
* Generate a random string with given length
|
|
16
|
+
*/
|
|
17
|
+
declare function randomString(length?: number): string;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Clamp a number between a minimum and maximum value
|
|
21
|
+
*/
|
|
22
|
+
declare function clamp(value: number, min: number, max: number): number;
|
|
23
|
+
/**
|
|
24
|
+
* Generate a random integer between min and max (inclusive)
|
|
25
|
+
*/
|
|
26
|
+
declare function randomInt(min: number, max: number): number;
|
|
27
|
+
/**
|
|
28
|
+
* Format a number to Indonesian Rupiah currency
|
|
29
|
+
* @example formatRupiah(50000) => "Rp 50.000"
|
|
30
|
+
*/
|
|
31
|
+
declare function formatRupiah(amount: number): string;
|
|
32
|
+
/**
|
|
33
|
+
* Calculate percentage of a value
|
|
34
|
+
*/
|
|
35
|
+
declare function percentage(value: number, total: number): number;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Shuffle an array using Fisher-Yates algorithm
|
|
39
|
+
*/
|
|
40
|
+
declare function shuffle<T>(array: T[]): T[];
|
|
41
|
+
/**
|
|
42
|
+
* Get unique values from an array
|
|
43
|
+
*/
|
|
44
|
+
declare function unique<T>(array: T[]): T[];
|
|
45
|
+
/**
|
|
46
|
+
* Chunk an array into smaller arrays of a specified size
|
|
47
|
+
* @example chunk([1,2,3,4,5], 2) => [[1,2],[3,4],[5]]
|
|
48
|
+
*/
|
|
49
|
+
declare function chunk<T>(array: T[], size: number): T[][];
|
|
50
|
+
/**
|
|
51
|
+
* Group array items by a key function
|
|
52
|
+
*/
|
|
53
|
+
declare function groupBy<T>(array: T[], keyFn: (item: T) => string): Record<string, T[]>;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Deep clone an object (structured clone)
|
|
57
|
+
*/
|
|
58
|
+
declare function deepClone<T>(obj: T): T;
|
|
59
|
+
/**
|
|
60
|
+
* Pick specific keys from an object
|
|
61
|
+
* @example pick({ a: 1, b: 2, c: 3 }, ['a', 'c']) => { a: 1, c: 3 }
|
|
62
|
+
*/
|
|
63
|
+
declare function pick<T extends Record<string, unknown>, K extends keyof T>(obj: T, keys: K[]): Pick<T, K>;
|
|
64
|
+
/**
|
|
65
|
+
* Omit specific keys from an object
|
|
66
|
+
* @example omit({ a: 1, b: 2, c: 3 }, ['b']) => { a: 1, c: 3 }
|
|
67
|
+
*/
|
|
68
|
+
declare function omit<T extends Record<string, unknown>, K extends keyof T>(obj: T, keys: K[]): Omit<T, K>;
|
|
69
|
+
/**
|
|
70
|
+
* Check if a value is empty (null, undefined, empty string, empty array, empty object)
|
|
71
|
+
*/
|
|
72
|
+
declare function isEmpty(value: unknown): boolean;
|
|
73
|
+
|
|
74
|
+
export { capitalize, chunk, clamp, deepClone, formatRupiah, groupBy, isEmpty, omit, percentage, pick, randomInt, randomString, shuffle, slugify, truncate, unique };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
capitalize: () => capitalize,
|
|
24
|
+
chunk: () => chunk,
|
|
25
|
+
clamp: () => clamp,
|
|
26
|
+
deepClone: () => deepClone,
|
|
27
|
+
formatRupiah: () => formatRupiah,
|
|
28
|
+
groupBy: () => groupBy,
|
|
29
|
+
isEmpty: () => isEmpty,
|
|
30
|
+
omit: () => omit,
|
|
31
|
+
percentage: () => percentage,
|
|
32
|
+
pick: () => pick,
|
|
33
|
+
randomInt: () => randomInt,
|
|
34
|
+
randomString: () => randomString,
|
|
35
|
+
shuffle: () => shuffle,
|
|
36
|
+
slugify: () => slugify,
|
|
37
|
+
truncate: () => truncate,
|
|
38
|
+
unique: () => unique
|
|
39
|
+
});
|
|
40
|
+
module.exports = __toCommonJS(index_exports);
|
|
41
|
+
|
|
42
|
+
// src/string.ts
|
|
43
|
+
function capitalize(str) {
|
|
44
|
+
if (!str) return str;
|
|
45
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
46
|
+
}
|
|
47
|
+
function slugify(str) {
|
|
48
|
+
return str.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_]+/g, "-").replace(/^-+|-+$/g, "");
|
|
49
|
+
}
|
|
50
|
+
function truncate(str, maxLength, suffix = "...") {
|
|
51
|
+
if (str.length <= maxLength) return str;
|
|
52
|
+
return str.slice(0, maxLength - suffix.length) + suffix;
|
|
53
|
+
}
|
|
54
|
+
function randomString(length = 8) {
|
|
55
|
+
const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
56
|
+
let result = "";
|
|
57
|
+
for (let i = 0; i < length; i++) {
|
|
58
|
+
result += chars.charAt(Math.floor(Math.random() * chars.length));
|
|
59
|
+
}
|
|
60
|
+
return result;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// src/number.ts
|
|
64
|
+
function clamp(value, min, max) {
|
|
65
|
+
return Math.min(Math.max(value, min), max);
|
|
66
|
+
}
|
|
67
|
+
function randomInt(min, max) {
|
|
68
|
+
return Math.floor(Math.random() * (max - min + 1)) + min;
|
|
69
|
+
}
|
|
70
|
+
function formatRupiah(amount) {
|
|
71
|
+
return "Rp " + amount.toFixed(0).replace(/\B(?=(\d{3})+(?!\d))/g, ".");
|
|
72
|
+
}
|
|
73
|
+
function percentage(value, total) {
|
|
74
|
+
if (total === 0) return 0;
|
|
75
|
+
return value / total * 100;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// src/array.ts
|
|
79
|
+
function shuffle(array) {
|
|
80
|
+
const result = [...array];
|
|
81
|
+
for (let i = result.length - 1; i > 0; i--) {
|
|
82
|
+
const j = Math.floor(Math.random() * (i + 1));
|
|
83
|
+
[result[i], result[j]] = [result[j], result[i]];
|
|
84
|
+
}
|
|
85
|
+
return result;
|
|
86
|
+
}
|
|
87
|
+
function unique(array) {
|
|
88
|
+
return [...new Set(array)];
|
|
89
|
+
}
|
|
90
|
+
function chunk(array, size) {
|
|
91
|
+
const result = [];
|
|
92
|
+
for (let i = 0; i < array.length; i += size) {
|
|
93
|
+
result.push(array.slice(i, i + size));
|
|
94
|
+
}
|
|
95
|
+
return result;
|
|
96
|
+
}
|
|
97
|
+
function groupBy(array, keyFn) {
|
|
98
|
+
return array.reduce(
|
|
99
|
+
(result, item) => {
|
|
100
|
+
const key = keyFn(item);
|
|
101
|
+
if (!result[key]) {
|
|
102
|
+
result[key] = [];
|
|
103
|
+
}
|
|
104
|
+
result[key].push(item);
|
|
105
|
+
return result;
|
|
106
|
+
},
|
|
107
|
+
{}
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// src/object.ts
|
|
112
|
+
function deepClone(obj) {
|
|
113
|
+
return JSON.parse(JSON.stringify(obj));
|
|
114
|
+
}
|
|
115
|
+
function pick(obj, keys) {
|
|
116
|
+
const result = {};
|
|
117
|
+
for (const key of keys) {
|
|
118
|
+
if (key in obj) {
|
|
119
|
+
result[key] = obj[key];
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return result;
|
|
123
|
+
}
|
|
124
|
+
function omit(obj, keys) {
|
|
125
|
+
const result = { ...obj };
|
|
126
|
+
for (const key of keys) {
|
|
127
|
+
delete result[key];
|
|
128
|
+
}
|
|
129
|
+
return result;
|
|
130
|
+
}
|
|
131
|
+
function isEmpty(value) {
|
|
132
|
+
if (value == null) return true;
|
|
133
|
+
if (typeof value === "string") return value.trim().length === 0;
|
|
134
|
+
if (Array.isArray(value)) return value.length === 0;
|
|
135
|
+
if (typeof value === "object") return Object.keys(value).length === 0;
|
|
136
|
+
return false;
|
|
137
|
+
}
|
|
138
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
139
|
+
0 && (module.exports = {
|
|
140
|
+
capitalize,
|
|
141
|
+
chunk,
|
|
142
|
+
clamp,
|
|
143
|
+
deepClone,
|
|
144
|
+
formatRupiah,
|
|
145
|
+
groupBy,
|
|
146
|
+
isEmpty,
|
|
147
|
+
omit,
|
|
148
|
+
percentage,
|
|
149
|
+
pick,
|
|
150
|
+
randomInt,
|
|
151
|
+
randomString,
|
|
152
|
+
shuffle,
|
|
153
|
+
slugify,
|
|
154
|
+
truncate,
|
|
155
|
+
unique
|
|
156
|
+
});
|
|
157
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/string.ts","../src/number.ts","../src/array.ts","../src/object.ts"],"sourcesContent":["// String utilities\nexport { capitalize, slugify, truncate, randomString } from \"./string\";\n\n// Number utilities\nexport { clamp, randomInt, formatRupiah, percentage } from \"./number\";\n\n// Array utilities\nexport { shuffle, unique, chunk, groupBy } from \"./array\";\n\n// Object utilities\nexport { deepClone, pick, omit, isEmpty } from \"./object\";\n","/**\n * Capitalize the first letter of a string\n */\nexport function capitalize(str: string): string {\n if (!str) return str;\n return str.charAt(0).toUpperCase() + str.slice(1);\n}\n\n/**\n * Convert a string to slug format (URL-friendly)\n * @example slugify(\"Hello World!\") => \"hello-world\"\n */\nexport function slugify(str: string): string {\n return str\n .toLowerCase()\n .trim()\n .replace(/[^\\w\\s-]/g, \"\")\n .replace(/[\\s_]+/g, \"-\")\n .replace(/^-+|-+$/g, \"\");\n}\n\n/**\n * Truncate a string to a specified length and append ellipsis\n */\nexport function truncate(str: string, maxLength: number, suffix = \"...\"): string {\n if (str.length <= maxLength) return str;\n return str.slice(0, maxLength - suffix.length) + suffix;\n}\n\n/**\n * Generate a random string with given length\n */\nexport function randomString(length: number = 8): string {\n const chars = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\";\n let result = \"\";\n for (let i = 0; i < length; i++) {\n result += chars.charAt(Math.floor(Math.random() * chars.length));\n }\n return result;\n}\n","/**\n * Clamp a number between a minimum and maximum value\n */\nexport function clamp(value: number, min: number, max: number): number {\n return Math.min(Math.max(value, min), max);\n}\n\n/**\n * Generate a random integer between min and max (inclusive)\n */\nexport function randomInt(min: number, max: number): number {\n return Math.floor(Math.random() * (max - min + 1)) + min;\n}\n\n/**\n * Format a number to Indonesian Rupiah currency\n * @example formatRupiah(50000) => \"Rp 50.000\"\n */\nexport function formatRupiah(amount: number): string {\n return \"Rp \" + amount.toFixed(0).replace(/\\B(?=(\\d{3})+(?!\\d))/g, \".\");\n}\n\n/**\n * Calculate percentage of a value\n */\nexport function percentage(value: number, total: number): number {\n if (total === 0) return 0;\n return (value / total) * 100;\n}\n","/**\n * Shuffle an array using Fisher-Yates algorithm\n */\nexport function shuffle<T>(array: T[]): T[] {\n const result = [...array];\n for (let i = result.length - 1; i > 0; i--) {\n const j = Math.floor(Math.random() * (i + 1));\n [result[i], result[j]] = [result[j], result[i]];\n }\n return result;\n}\n\n/**\n * Get unique values from an array\n */\nexport function unique<T>(array: T[]): T[] {\n return [...new Set(array)];\n}\n\n/**\n * Chunk an array into smaller arrays of a specified size\n * @example chunk([1,2,3,4,5], 2) => [[1,2],[3,4],[5]]\n */\nexport function chunk<T>(array: T[], size: number): T[][] {\n const result: T[][] = [];\n for (let i = 0; i < array.length; i += size) {\n result.push(array.slice(i, i + size));\n }\n return result;\n}\n\n/**\n * Group array items by a key function\n */\nexport function groupBy<T>(array: T[], keyFn: (item: T) => string): Record<string, T[]> {\n return array.reduce(\n (result, item) => {\n const key = keyFn(item);\n if (!result[key]) {\n result[key] = [];\n }\n result[key].push(item);\n return result;\n },\n {} as Record<string, T[]>\n );\n}\n","/**\n * Deep clone an object (structured clone)\n */\nexport function deepClone<T>(obj: T): T {\n return JSON.parse(JSON.stringify(obj));\n}\n\n/**\n * Pick specific keys from an object\n * @example pick({ a: 1, b: 2, c: 3 }, ['a', 'c']) => { a: 1, c: 3 }\n */\nexport function pick<T extends Record<string, unknown>, K extends keyof T>(\n obj: T,\n keys: K[]\n): Pick<T, K> {\n const result = {} as Pick<T, K>;\n for (const key of keys) {\n if (key in obj) {\n result[key] = obj[key];\n }\n }\n return result;\n}\n\n/**\n * Omit specific keys from an object\n * @example omit({ a: 1, b: 2, c: 3 }, ['b']) => { a: 1, c: 3 }\n */\nexport function omit<T extends Record<string, unknown>, K extends keyof T>(\n obj: T,\n keys: K[]\n): Omit<T, K> {\n const result = { ...obj };\n for (const key of keys) {\n delete result[key];\n }\n return result as Omit<T, K>;\n}\n\n/**\n * Check if a value is empty (null, undefined, empty string, empty array, empty object)\n */\nexport function isEmpty(value: unknown): boolean {\n if (value == null) return true;\n if (typeof value === \"string\") return value.trim().length === 0;\n if (Array.isArray(value)) return value.length === 0;\n if (typeof value === \"object\") return Object.keys(value as object).length === 0;\n return false;\n}\n"],"mappings":"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","names":[]}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
// src/string.ts
|
|
2
|
+
function capitalize(str) {
|
|
3
|
+
if (!str) return str;
|
|
4
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
5
|
+
}
|
|
6
|
+
function slugify(str) {
|
|
7
|
+
return str.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_]+/g, "-").replace(/^-+|-+$/g, "");
|
|
8
|
+
}
|
|
9
|
+
function truncate(str, maxLength, suffix = "...") {
|
|
10
|
+
if (str.length <= maxLength) return str;
|
|
11
|
+
return str.slice(0, maxLength - suffix.length) + suffix;
|
|
12
|
+
}
|
|
13
|
+
function randomString(length = 8) {
|
|
14
|
+
const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
15
|
+
let result = "";
|
|
16
|
+
for (let i = 0; i < length; i++) {
|
|
17
|
+
result += chars.charAt(Math.floor(Math.random() * chars.length));
|
|
18
|
+
}
|
|
19
|
+
return result;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// src/number.ts
|
|
23
|
+
function clamp(value, min, max) {
|
|
24
|
+
return Math.min(Math.max(value, min), max);
|
|
25
|
+
}
|
|
26
|
+
function randomInt(min, max) {
|
|
27
|
+
return Math.floor(Math.random() * (max - min + 1)) + min;
|
|
28
|
+
}
|
|
29
|
+
function formatRupiah(amount) {
|
|
30
|
+
return "Rp " + amount.toFixed(0).replace(/\B(?=(\d{3})+(?!\d))/g, ".");
|
|
31
|
+
}
|
|
32
|
+
function percentage(value, total) {
|
|
33
|
+
if (total === 0) return 0;
|
|
34
|
+
return value / total * 100;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// src/array.ts
|
|
38
|
+
function shuffle(array) {
|
|
39
|
+
const result = [...array];
|
|
40
|
+
for (let i = result.length - 1; i > 0; i--) {
|
|
41
|
+
const j = Math.floor(Math.random() * (i + 1));
|
|
42
|
+
[result[i], result[j]] = [result[j], result[i]];
|
|
43
|
+
}
|
|
44
|
+
return result;
|
|
45
|
+
}
|
|
46
|
+
function unique(array) {
|
|
47
|
+
return [...new Set(array)];
|
|
48
|
+
}
|
|
49
|
+
function chunk(array, size) {
|
|
50
|
+
const result = [];
|
|
51
|
+
for (let i = 0; i < array.length; i += size) {
|
|
52
|
+
result.push(array.slice(i, i + size));
|
|
53
|
+
}
|
|
54
|
+
return result;
|
|
55
|
+
}
|
|
56
|
+
function groupBy(array, keyFn) {
|
|
57
|
+
return array.reduce(
|
|
58
|
+
(result, item) => {
|
|
59
|
+
const key = keyFn(item);
|
|
60
|
+
if (!result[key]) {
|
|
61
|
+
result[key] = [];
|
|
62
|
+
}
|
|
63
|
+
result[key].push(item);
|
|
64
|
+
return result;
|
|
65
|
+
},
|
|
66
|
+
{}
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// src/object.ts
|
|
71
|
+
function deepClone(obj) {
|
|
72
|
+
return JSON.parse(JSON.stringify(obj));
|
|
73
|
+
}
|
|
74
|
+
function pick(obj, keys) {
|
|
75
|
+
const result = {};
|
|
76
|
+
for (const key of keys) {
|
|
77
|
+
if (key in obj) {
|
|
78
|
+
result[key] = obj[key];
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return result;
|
|
82
|
+
}
|
|
83
|
+
function omit(obj, keys) {
|
|
84
|
+
const result = { ...obj };
|
|
85
|
+
for (const key of keys) {
|
|
86
|
+
delete result[key];
|
|
87
|
+
}
|
|
88
|
+
return result;
|
|
89
|
+
}
|
|
90
|
+
function isEmpty(value) {
|
|
91
|
+
if (value == null) return true;
|
|
92
|
+
if (typeof value === "string") return value.trim().length === 0;
|
|
93
|
+
if (Array.isArray(value)) return value.length === 0;
|
|
94
|
+
if (typeof value === "object") return Object.keys(value).length === 0;
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
export {
|
|
98
|
+
capitalize,
|
|
99
|
+
chunk,
|
|
100
|
+
clamp,
|
|
101
|
+
deepClone,
|
|
102
|
+
formatRupiah,
|
|
103
|
+
groupBy,
|
|
104
|
+
isEmpty,
|
|
105
|
+
omit,
|
|
106
|
+
percentage,
|
|
107
|
+
pick,
|
|
108
|
+
randomInt,
|
|
109
|
+
randomString,
|
|
110
|
+
shuffle,
|
|
111
|
+
slugify,
|
|
112
|
+
truncate,
|
|
113
|
+
unique
|
|
114
|
+
};
|
|
115
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/string.ts","../src/number.ts","../src/array.ts","../src/object.ts"],"sourcesContent":["/**\n * Capitalize the first letter of a string\n */\nexport function capitalize(str: string): string {\n if (!str) return str;\n return str.charAt(0).toUpperCase() + str.slice(1);\n}\n\n/**\n * Convert a string to slug format (URL-friendly)\n * @example slugify(\"Hello World!\") => \"hello-world\"\n */\nexport function slugify(str: string): string {\n return str\n .toLowerCase()\n .trim()\n .replace(/[^\\w\\s-]/g, \"\")\n .replace(/[\\s_]+/g, \"-\")\n .replace(/^-+|-+$/g, \"\");\n}\n\n/**\n * Truncate a string to a specified length and append ellipsis\n */\nexport function truncate(str: string, maxLength: number, suffix = \"...\"): string {\n if (str.length <= maxLength) return str;\n return str.slice(0, maxLength - suffix.length) + suffix;\n}\n\n/**\n * Generate a random string with given length\n */\nexport function randomString(length: number = 8): string {\n const chars = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\";\n let result = \"\";\n for (let i = 0; i < length; i++) {\n result += chars.charAt(Math.floor(Math.random() * chars.length));\n }\n return result;\n}\n","/**\n * Clamp a number between a minimum and maximum value\n */\nexport function clamp(value: number, min: number, max: number): number {\n return Math.min(Math.max(value, min), max);\n}\n\n/**\n * Generate a random integer between min and max (inclusive)\n */\nexport function randomInt(min: number, max: number): number {\n return Math.floor(Math.random() * (max - min + 1)) + min;\n}\n\n/**\n * Format a number to Indonesian Rupiah currency\n * @example formatRupiah(50000) => \"Rp 50.000\"\n */\nexport function formatRupiah(amount: number): string {\n return \"Rp \" + amount.toFixed(0).replace(/\\B(?=(\\d{3})+(?!\\d))/g, \".\");\n}\n\n/**\n * Calculate percentage of a value\n */\nexport function percentage(value: number, total: number): number {\n if (total === 0) return 0;\n return (value / total) * 100;\n}\n","/**\n * Shuffle an array using Fisher-Yates algorithm\n */\nexport function shuffle<T>(array: T[]): T[] {\n const result = [...array];\n for (let i = result.length - 1; i > 0; i--) {\n const j = Math.floor(Math.random() * (i + 1));\n [result[i], result[j]] = [result[j], result[i]];\n }\n return result;\n}\n\n/**\n * Get unique values from an array\n */\nexport function unique<T>(array: T[]): T[] {\n return [...new Set(array)];\n}\n\n/**\n * Chunk an array into smaller arrays of a specified size\n * @example chunk([1,2,3,4,5], 2) => [[1,2],[3,4],[5]]\n */\nexport function chunk<T>(array: T[], size: number): T[][] {\n const result: T[][] = [];\n for (let i = 0; i < array.length; i += size) {\n result.push(array.slice(i, i + size));\n }\n return result;\n}\n\n/**\n * Group array items by a key function\n */\nexport function groupBy<T>(array: T[], keyFn: (item: T) => string): Record<string, T[]> {\n return array.reduce(\n (result, item) => {\n const key = keyFn(item);\n if (!result[key]) {\n result[key] = [];\n }\n result[key].push(item);\n return result;\n },\n {} as Record<string, T[]>\n );\n}\n","/**\n * Deep clone an object (structured clone)\n */\nexport function deepClone<T>(obj: T): T {\n return JSON.parse(JSON.stringify(obj));\n}\n\n/**\n * Pick specific keys from an object\n * @example pick({ a: 1, b: 2, c: 3 }, ['a', 'c']) => { a: 1, c: 3 }\n */\nexport function pick<T extends Record<string, unknown>, K extends keyof T>(\n obj: T,\n keys: K[]\n): Pick<T, K> {\n const result = {} as Pick<T, K>;\n for (const key of keys) {\n if (key in obj) {\n result[key] = obj[key];\n }\n }\n return result;\n}\n\n/**\n * Omit specific keys from an object\n * @example omit({ a: 1, b: 2, c: 3 }, ['b']) => { a: 1, c: 3 }\n */\nexport function omit<T extends Record<string, unknown>, K extends keyof T>(\n obj: T,\n keys: K[]\n): Omit<T, K> {\n const result = { ...obj };\n for (const key of keys) {\n delete result[key];\n }\n return result as Omit<T, K>;\n}\n\n/**\n * Check if a value is empty (null, undefined, empty string, empty array, empty object)\n */\nexport function isEmpty(value: unknown): boolean {\n if (value == null) return true;\n if (typeof value === \"string\") return value.trim().length === 0;\n if (Array.isArray(value)) return value.length === 0;\n if (typeof value === \"object\") return Object.keys(value as object).length === 0;\n return false;\n}\n"],"mappings":"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","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "my-awesome-utils-ufeek",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A simple collection of useful utility functions",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.mjs",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.mjs",
|
|
12
|
+
"require": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "tsup",
|
|
20
|
+
"dev": "tsup --watch",
|
|
21
|
+
"prepublishOnly": "npm run build"
|
|
22
|
+
},
|
|
23
|
+
"keywords": [
|
|
24
|
+
"utils",
|
|
25
|
+
"utility",
|
|
26
|
+
"helpers",
|
|
27
|
+
"typescript"
|
|
28
|
+
],
|
|
29
|
+
"author": "",
|
|
30
|
+
"license": "MIT",
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"tsup": "^8.0.0",
|
|
33
|
+
"typescript": "^5.3.0"
|
|
34
|
+
}
|
|
35
|
+
}
|