@dephub/random-letter 0.0.0-stage â 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 +57 -2
- package/dist/core/random-letter.d.ts +10 -0
- package/dist/core/random-letter.js +18 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/package.json +69 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025-2026 Estarlin R
|
|
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
CHANGED
|
@@ -1,3 +1,58 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @dephub/random-letter đ˛
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> A tiny, dependency-free utility that generates random lowercase strings.
|
|
4
|
+
|
|
5
|
+
[](https://npmjs.org/package/@dephub/random-letter)
|
|
6
|
+
|
|
7
|
+
## Features â¨
|
|
8
|
+
|
|
9
|
+
- đ¤ Generates random lowercase ASCII letters (`aâz`)
|
|
10
|
+
- đ Configurable length, defaults to `10`
|
|
11
|
+
- đĄī¸ Input validation â throws `RangeError` for non-integers or negative lengths
|
|
12
|
+
- đĒļ Zero runtime dependencies
|
|
13
|
+
- đĻ Fully typed, ships with TypeScript declarations
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Installation đĻ
|
|
18
|
+
|
|
19
|
+
- npm: `npm install @dephub/random-letter`
|
|
20
|
+
- pnpm: `pnpm add @dephub/random-letter`
|
|
21
|
+
- yarn: `yarn add @dephub/random-letter`
|
|
22
|
+
- bun: `bun add @dephub/random-letter`
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## Usage đ¯
|
|
27
|
+
|
|
28
|
+
### API đ§Š
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
import { randomLetters } from '@dephub/random-letter';
|
|
32
|
+
|
|
33
|
+
// Default length (10)
|
|
34
|
+
randomLetters();
|
|
35
|
+
// e.g. "qzkvabczde"
|
|
36
|
+
|
|
37
|
+
// Custom length
|
|
38
|
+
randomLetters(5);
|
|
39
|
+
// e.g. "mqzva"
|
|
40
|
+
|
|
41
|
+
// Invalid input
|
|
42
|
+
randomLetters(-1);
|
|
43
|
+
// throws RangeError: Length must be a non-negative integer
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Available exports
|
|
47
|
+
|
|
48
|
+
| Category | Functions |
|
|
49
|
+
| ---------- | --------------- |
|
|
50
|
+
| **Random** | `randomLetters` |
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## License đ
|
|
55
|
+
|
|
56
|
+
MIT License â see [LICENSE](LICENSE) for details.
|
|
57
|
+
|
|
58
|
+
**Author:** Estarlin R ([estarlincito.com](https://estarlincito.com))
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates a random string of lowercase ASCII letters (aâz).
|
|
3
|
+
*
|
|
4
|
+
* @param length - The number of letters to generate. Must be a non-negative integer. Defaults to `10`.
|
|
5
|
+
* @returns A string of exactly `length` random lowercase letters.
|
|
6
|
+
* @throws {RangeError} If `length` is not a non-negative integer (e.g. `-1`, `1.5`, `NaN`).
|
|
7
|
+
* @example
|
|
8
|
+
* randomLetters(5); // e.g. "qzkva"
|
|
9
|
+
*/
|
|
10
|
+
export declare function randomLetters(length?: number): string;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// src/core/random-letter.ts
|
|
2
|
+
var ALPHABET = "abcdefghijklmnopqrstuvwxyz";
|
|
3
|
+
/**
|
|
4
|
+
* Generates a random string of lowercase ASCII letters (aâz).
|
|
5
|
+
*
|
|
6
|
+
* @param length - The number of letters to generate. Must be a non-negative integer. Defaults to `10`.
|
|
7
|
+
* @returns A string of exactly `length` random lowercase letters.
|
|
8
|
+
* @throws {RangeError} If `length` is not a non-negative integer (e.g. `-1`, `1.5`, `NaN`).
|
|
9
|
+
* @example
|
|
10
|
+
* randomLetters(5); // e.g. "qzkva"
|
|
11
|
+
*/
|
|
12
|
+
function randomLetters(length = 10) {
|
|
13
|
+
if (!Number.isInteger(length) || length < 0) throw new RangeError("Length must be a non-negative integer");
|
|
14
|
+
let result = "";
|
|
15
|
+
for (let i = 0; i < length; i += 1) result += ALPHABET.charAt(Math.floor(Math.random() * 26));
|
|
16
|
+
return result;
|
|
17
|
+
}
|
|
18
|
+
export { randomLetters };
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { randomLetters as default, randomLetters } from "./core/random-letter.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,72 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dephub/random-letter",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"description": "A tiny, dependency-free utility that generates random lowercase strings.",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"main": "dist/index.js",
|
|
8
|
+
"keywords": [
|
|
9
|
+
"random-letter",
|
|
10
|
+
"node",
|
|
11
|
+
"typescript",
|
|
12
|
+
"javascript",
|
|
13
|
+
"random-string",
|
|
14
|
+
"random",
|
|
15
|
+
"generator",
|
|
16
|
+
"alphabet",
|
|
17
|
+
"letters"
|
|
18
|
+
],
|
|
19
|
+
"author": {
|
|
20
|
+
"name": "Estarlin R",
|
|
21
|
+
"email": "dev@estarlincito.com",
|
|
22
|
+
"url": "https://estarlincito.com"
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"LICENSE",
|
|
26
|
+
"README.md",
|
|
27
|
+
"dist"
|
|
28
|
+
],
|
|
29
|
+
"license": "MIT",
|
|
30
|
+
"homepage": "https://github.com/dephub-js/random-letter#readme",
|
|
31
|
+
"repository": {
|
|
32
|
+
"type": "git",
|
|
33
|
+
"url": "https://github.com/dephub-js/random-letter.git"
|
|
34
|
+
},
|
|
35
|
+
"bugs": {
|
|
36
|
+
"url": "https://github.com/dephub-js/random-letter/issues"
|
|
37
|
+
},
|
|
38
|
+
"publishConfig": {
|
|
39
|
+
"access": "public"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@dephub/eslint-ts": "^1.0.5",
|
|
43
|
+
"@dephub/glob": "^1.0.2",
|
|
44
|
+
"@dephub/path": "^2.0.0",
|
|
45
|
+
"@dephub/schema": "^1.0.0",
|
|
46
|
+
"@types/node": "^26.6.6",
|
|
47
|
+
"eslint": "^10.15.0",
|
|
48
|
+
"prettier": "^3.10.1",
|
|
49
|
+
"typescript": "6.0.3",
|
|
50
|
+
"vite": "^8.3.8",
|
|
51
|
+
"vite-plugin-dts": "^5.1.2"
|
|
52
|
+
},
|
|
53
|
+
"imports": {
|
|
54
|
+
"#/*": "./src/*"
|
|
55
|
+
},
|
|
56
|
+
"engines": {
|
|
57
|
+
"node": ">=24.0.0"
|
|
58
|
+
},
|
|
59
|
+
"scripts": {
|
|
60
|
+
"release": "pnpm publish",
|
|
61
|
+
"docs": "lineo md 'src/**/*.ts' --outFile code.md --outDir temp",
|
|
62
|
+
"test": "node --test",
|
|
63
|
+
"check": "pnpm fmt && pnpm lint && pnpm check-types",
|
|
64
|
+
"check-types": "tsc --noEmit --skipLibCheck",
|
|
65
|
+
"lint": "eslint . --fix --max-warnings 0",
|
|
66
|
+
"fmt": "prettier --write .",
|
|
67
|
+
"clean": "rm -rf dist .layer",
|
|
68
|
+
"pack": "pnpm pack",
|
|
69
|
+
"build": "vite build",
|
|
70
|
+
"dev": "vite build -w --mode development"
|
|
71
|
+
}
|
|
6
72
|
}
|