js-utils-kit 0.1.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +152 -2
- package/dist/char/index.cjs +1 -0
- package/dist/char/index.d.ts +41 -0
- package/dist/char/index.js +1 -0
- package/dist/cli/index.js +8 -13
- package/dist/env/index.cjs +1 -0
- package/dist/env/index.d.ts +128 -0
- package/dist/env/index.js +1 -0
- package/dist/file/index.cjs +49 -0
- package/dist/file/index.d.ts +75 -0
- package/dist/file/index.js +49 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +7 -71
- package/dist/index.js +1 -0
- package/dist/number/index.cjs +1 -0
- package/dist/number/index.d.ts +74 -0
- package/dist/number/index.js +1 -0
- package/dist/object/index.cjs +1 -0
- package/dist/object/index.d.ts +46 -0
- package/dist/object/index.js +1 -0
- package/dist/string/index.cjs +1 -0
- package/dist/string/index.d.ts +137 -0
- package/dist/string/index.js +1 -0
- package/package.json +68 -16
- package/dist/index.cjs.js +0 -54
- package/dist/index.esm.js +0 -54
package/README.md
CHANGED
|
@@ -1,3 +1,153 @@
|
|
|
1
|
-
|
|
1
|
+
<div align="center">
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://github.com/TenEplaysOfficial/js-utils-kit)
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/js-utils-kit)
|
|
6
|
+
[](https://github.com/TenEplaysOfficial/js-utils-kit/blob/main/LICENSE)
|
|
7
|
+
[](https://bundlephobia.com/package/js-utils-kit)
|
|
8
|
+
[](https://github.com/TenEplaysOfficial/js-utils-kit)
|
|
9
|
+
[](https://github.com/TenEplaysOfficial/js-utils-kit/stargazers)
|
|
10
|
+
[](https://github.com/TenEplaysOfficial/js-utils-kit/issues)
|
|
11
|
+
[](https://github.com/TenEplaysOfficial/js-utils-kit/pulls)
|
|
12
|
+
[](https://github.com/TenEplaysOfficial/js-utils-kit/commits)
|
|
13
|
+
[](https://github.com/TenEplaysOfficial/js-utils-kit/discussions)
|
|
14
|
+
[](https://www.npmjs.com/package/js-utils-kit)
|
|
15
|
+
[](https://github.com/TenEplaysOfficial/js-utils-kit)
|
|
16
|
+
[](https://github.com/TenEplaysOfficial/js-utils-kit)
|
|
17
|
+
[](https://github.com/sponsors/TenEplaysOfficial)
|
|
18
|
+
[](https://x.com/teneplays)
|
|
19
|
+
|
|
20
|
+
</div>
|
|
21
|
+
|
|
22
|
+
**JS Utils Kit** is a compact and reliable library of essential JavaScript utility functions. It includes helpers for arrays, objects, numbers, promises, type checking, and more. Designed for performance and modularity, it integrates easily into JavaScript and TypeScript projects with minimal impact on bundle size.
|
|
23
|
+
|
|
24
|
+
> Streamline your code with battle-tested, tree-shakable utilities.
|
|
25
|
+
|
|
26
|
+
This package includes utilities designed for both browser and Node.js environments, clearly organized and optimized for cross-platform compatibility.
|
|
27
|
+
|
|
28
|
+
## Installation
|
|
29
|
+
|
|
30
|
+
```sh
|
|
31
|
+
yarn add js-utils-kit
|
|
32
|
+
# or
|
|
33
|
+
npm install js-utils-kit
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Usage
|
|
37
|
+
|
|
38
|
+
`js-utils-kit` offers a modular structure for utilities across different categories like `number`, `string`, `array`, `object`, `env`, and more. You can use full or scoped imports depending on your preference and project setup.
|
|
39
|
+
|
|
40
|
+
### Recommended Import
|
|
41
|
+
|
|
42
|
+
Import only what you need by utility category:
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
import number from 'js-utils-kit/number';
|
|
46
|
+
import string from 'js-utils-kit/string';
|
|
47
|
+
import array from 'js-utils-kit/array';
|
|
48
|
+
import object from 'js-utils-kit/object';
|
|
49
|
+
import env from 'js-utils-kit/env';
|
|
50
|
+
|
|
51
|
+
console.log(number.clamp(150, 0, 100)); // 100
|
|
52
|
+
console.log(string.capitalize('hello world')); // 'Hello World'
|
|
53
|
+
console.log(array.unique([1, 2, 2, 3])); // [1, 2, 3]
|
|
54
|
+
console.log(object.isEmpty({})); // true
|
|
55
|
+
console.log(env.isBrowser()); // true/false
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Full Import (All utils in one namespace)
|
|
59
|
+
|
|
60
|
+
```ts
|
|
61
|
+
import * as kit from 'js-utils-kit';
|
|
62
|
+
|
|
63
|
+
console.log(kit.number.clamp(150, 0, 100)); // 100
|
|
64
|
+
console.log(kit.string.capitalize('hello')); // 'Hello'
|
|
65
|
+
console.log(kit.array.unique([1, 1, 2])); // [1, 2]
|
|
66
|
+
console.log(kit.object.isEmpty({})); // true
|
|
67
|
+
console.log(kit.env.isNode()); // true/false
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Named Imports
|
|
71
|
+
|
|
72
|
+
```ts
|
|
73
|
+
import { number, string, env } from 'js-utils-kit';
|
|
74
|
+
|
|
75
|
+
console.log(number.clamp(42, 0, 100)); // 42
|
|
76
|
+
console.log(string.capitalize('js-utils-kit')); // 'Js-utils-kit'
|
|
77
|
+
console.log(env.isDev()); // true/false
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### CommonJS Usage
|
|
81
|
+
|
|
82
|
+
```js
|
|
83
|
+
const { number, string, array, object, env } = require('js-utils-kit');
|
|
84
|
+
|
|
85
|
+
console.log(number.clamp(150, 0, 100)); // 100
|
|
86
|
+
console.log(string.capitalize('hello world')); // 'Hello World'
|
|
87
|
+
console.log(array.unique([1, 2, 2, 3])); // [1, 2, 3]
|
|
88
|
+
console.log(object.isEmpty({})); // true
|
|
89
|
+
console.log(env.isBrowser()); // true/false
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Features
|
|
93
|
+
|
|
94
|
+
- Organized by category (e.g., `number`, `string`, `file`, etc.)
|
|
95
|
+
- Fully typed with TypeScript
|
|
96
|
+
- Thoroughly tested with Jest
|
|
97
|
+
- Tree-shakable and supports both ESM and CJS
|
|
98
|
+
- CLI-ready tools for file and system operations
|
|
99
|
+
|
|
100
|
+
## Documentation
|
|
101
|
+
|
|
102
|
+
Full documentation available at [GitHub Pages](https://teneplaysofficial.github.io/js-utils-kit/)
|
|
103
|
+
|
|
104
|
+
## Requirements
|
|
105
|
+
|
|
106
|
+
- Node.js: Version `18.0.0` or higher
|
|
107
|
+
- Yarn (or npm as an alternative)
|
|
108
|
+
- TypeScript (optional, for TypeScript projects or development)
|
|
109
|
+
- Browsers: Modern browsers for browser-based usage
|
|
110
|
+
|
|
111
|
+
## Contributing
|
|
112
|
+
|
|
113
|
+
We welcome contributions whether it's fixing bugs, adding utilities, improving docs, or writing tests. See [CONTRIBUTING.md](./CONTRIBUTING.md) for guidelines and join our [GitHub Discussions](https://github.com/TenEplaysOfficial/js-utils-kit/discussions) to share ideas or propose features.
|
|
114
|
+
|
|
115
|
+
## FAQ
|
|
116
|
+
|
|
117
|
+
<details>
|
|
118
|
+
<summary>Does it work in browsers?</summary>
|
|
119
|
+
|
|
120
|
+
Yes, **JS Utils Kit** is compatible with modern browsers and Node.js.
|
|
121
|
+
|
|
122
|
+
</details>
|
|
123
|
+
|
|
124
|
+
<details>
|
|
125
|
+
<summary>Do I need TypeScript?</summary>
|
|
126
|
+
|
|
127
|
+
No, the library works in plain JavaScript, but TypeScript users benefit from full type definitions and editor support.
|
|
128
|
+
|
|
129
|
+
</details>
|
|
130
|
+
|
|
131
|
+
<details>
|
|
132
|
+
<summary>How do I report a bug?</summary>
|
|
133
|
+
|
|
134
|
+
Open an issue on [GitHub](https://github.com/TenEplaysOfficial/js-utils-kit/issues) or join the [Discussions](https://github.com/TenEplaysOfficial/js-utils-kit/discussions) to ask questions or share feedback.
|
|
135
|
+
|
|
136
|
+
</details>
|
|
137
|
+
|
|
138
|
+
<details>
|
|
139
|
+
<summary>How can I optimize bundle size?</summary>
|
|
140
|
+
|
|
141
|
+
Import only what you need:
|
|
142
|
+
|
|
143
|
+
```ts
|
|
144
|
+
import { clamp } from 'js-utils-kit/number';
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
This enables tree-shaking for smaller, optimized bundles.
|
|
148
|
+
|
|
149
|
+
</details>
|
|
150
|
+
|
|
151
|
+
## License
|
|
152
|
+
|
|
153
|
+
Released under the [MIT License](LICENSE)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const r=()=>Array.from({length:26},(r,e)=>String.fromCharCode(97+e)),e=()=>Array.from({length:26},(r,e)=>String.fromCharCode(65+e)),o=()=>Array.from({length:10},(r,e)=>String.fromCharCode(48+e)),t=()=>[...r(),...e(),...o()];var s={lowercase:r,uppercase:e,digits:o,all:t};exports.all=t,exports.default=s,exports.digits=o,exports.lowercase=r,exports.uppercase=e;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates an array of lowercase ASCII alphabet characters (a–z).
|
|
3
|
+
*
|
|
4
|
+
* @returns {string[]} An array containing 'a' to 'z'.
|
|
5
|
+
* @example
|
|
6
|
+
* lowercase(); // ['a', 'b', ..., 'z']
|
|
7
|
+
*/
|
|
8
|
+
declare const lowercase: () => string[];
|
|
9
|
+
/**
|
|
10
|
+
* Generates an array of uppercase ASCII alphabet characters (A–Z).
|
|
11
|
+
*
|
|
12
|
+
* @returns {string[]} An array containing 'A' to 'Z'.
|
|
13
|
+
* @example
|
|
14
|
+
* uppercase(); // ['A', 'B', ..., 'Z']
|
|
15
|
+
*/
|
|
16
|
+
declare const uppercase: () => string[];
|
|
17
|
+
/**
|
|
18
|
+
* Generates an array of ASCII digit characters (0–9).
|
|
19
|
+
*
|
|
20
|
+
* @returns {string[]} An array containing '0' to '9'.
|
|
21
|
+
* @example
|
|
22
|
+
* digits(); // ['0', '1', ..., '9']
|
|
23
|
+
*/
|
|
24
|
+
declare const digits: () => string[];
|
|
25
|
+
/**
|
|
26
|
+
* Combines lowercase, uppercase, and digit characters into a single array.
|
|
27
|
+
*
|
|
28
|
+
* @returns {string[]} An array containing 'a'–'z', 'A'–'Z', and '0'–'9'.
|
|
29
|
+
* @example
|
|
30
|
+
* all(); // ['a', ..., 'z', 'A', ..., 'Z', '0', ..., '9']
|
|
31
|
+
*/
|
|
32
|
+
declare const all: () => string[];
|
|
33
|
+
|
|
34
|
+
declare const _default: {
|
|
35
|
+
lowercase: () => string[];
|
|
36
|
+
uppercase: () => string[];
|
|
37
|
+
digits: () => string[];
|
|
38
|
+
all: () => string[];
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export { all, _default as default, digits, lowercase, uppercase };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const r=()=>Array.from({length:26},(r,a)=>String.fromCharCode(97+a)),a=()=>Array.from({length:26},(r,a)=>String.fromCharCode(65+a)),e=()=>Array.from({length:10},(r,a)=>String.fromCharCode(48+a)),o=()=>[...r(),...a(),...e()];var t={lowercase:r,uppercase:a,digits:e,all:o};export{o as all,t as default,e as digits,r as lowercase,a as uppercase};
|