@uocdev/yauiselib 1.0.0 → 1.1.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.
@@ -1,2 +1,3 @@
1
1
  export { cout } from './cout/cout.js';
2
2
  export { coutint } from './cout/coutint.js';
3
+ export { randomInt } from './int/randomint.js';
package/dist/cjs/index.js CHANGED
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.coutint = exports.cout = void 0;
3
+ exports.randomInt = exports.coutint = exports.cout = void 0;
4
4
  var cout_js_1 = require("./cout/cout.js");
5
5
  Object.defineProperty(exports, "cout", { enumerable: true, get: function () { return cout_js_1.cout; } });
6
6
  var coutint_js_1 = require("./cout/coutint.js");
7
7
  Object.defineProperty(exports, "coutint", { enumerable: true, get: function () { return coutint_js_1.coutint; } });
8
+ var randomint_js_1 = require("./int/randomint.js");
9
+ Object.defineProperty(exports, "randomInt", { enumerable: true, get: function () { return randomint_js_1.randomInt; } });
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Generate random integer from 1 to max (inclusive)
3
+ * @param max upper bound (must be >= 1)
4
+ */
5
+ export declare function randomInt(max: number): number;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.randomInt = randomInt;
4
+ /**
5
+ * Generate random integer from 1 to max (inclusive)
6
+ * @param max upper bound (must be >= 1)
7
+ */
8
+ function randomInt(max) {
9
+ if (!Number.isInteger(max) || max < 1) {
10
+ throw new RangeError("int must >= 1");
11
+ }
12
+ // Math.random() -> [0, 1)
13
+ // * max -> [0, max)
14
+ // floor + 1 -> [1, max]
15
+ return Math.floor(Math.random() * max) + 1;
16
+ }
@@ -1,2 +1,3 @@
1
1
  export { cout } from './cout/cout.js';
2
2
  export { coutint } from './cout/coutint.js';
3
+ export { randomInt } from './int/randomint.js';
package/dist/esm/index.js CHANGED
@@ -1,2 +1,3 @@
1
1
  export { cout } from './cout/cout.js';
2
2
  export { coutint } from './cout/coutint.js';
3
+ export { randomInt } from './int/randomint.js';
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Generate random integer from 1 to max (inclusive)
3
+ * @param max upper bound (must be >= 1)
4
+ */
5
+ export declare function randomInt(max: number): number;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Generate random integer from 1 to max (inclusive)
3
+ * @param max upper bound (must be >= 1)
4
+ */
5
+ export function randomInt(max) {
6
+ if (!Number.isInteger(max) || max < 1) {
7
+ throw new RangeError("int must >= 1");
8
+ }
9
+ // Math.random() -> [0, 1)
10
+ // * max -> [0, max)
11
+ // floor + 1 -> [1, max]
12
+ return Math.floor(Math.random() * max) + 1;
13
+ }
package/package.json CHANGED
@@ -1,11 +1,10 @@
1
1
  {
2
2
  "name": "@uocdev/yauiselib",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "random package for NPM fun only :3",
5
5
  "license": "MIT",
6
6
  "author": "Uoc",
7
7
  "type": "module",
8
-
9
8
  "keywords": [
10
9
  "nodejs",
11
10
  "typescript",
@@ -14,23 +13,20 @@
14
13
  "playground",
15
14
  "random"
16
15
  ],
17
-
18
- "main": "./dist/cjs/index.cjs",
16
+ "main": "./dist/cjs/index.js",
19
17
  "types": "./dist/index.d.ts",
20
-
21
18
  "exports": {
22
19
  ".": {
23
20
  "import": "./dist/esm/index.js",
24
21
  "require": "./dist/cjs/index.cjs"
25
22
  }
26
23
  },
27
-
28
- "files": ["dist"],
29
-
24
+ "files": [
25
+ "dist"
26
+ ],
30
27
  "engines": {
31
28
  "node": ">=18"
32
29
  },
33
-
34
30
  "scripts": {
35
31
  "build:esm": "tsc -p tsconfig.esm.json",
36
32
  "build:cjs": "tsc -p tsconfig.cjs.json",
@@ -39,20 +35,16 @@
39
35
  "install:dev": "npm install --prefix ./tesyl",
40
36
  "test:dev": "node tesyl/index"
41
37
  },
42
-
43
38
  "devDependencies": {
44
39
  "typescript": "^5.3.3",
45
40
  "@types/node": "^25.0.9"
46
41
  },
47
-
48
42
  "repository": {
49
43
  "type": "git",
50
44
  "url": "https://github.com/UocDev/Yauiselib"
51
45
  },
52
-
53
46
  "bugs": {
54
47
  "url": "https://github.com/UocDev/Yauiselib/issues"
55
48
  },
56
-
57
49
  "homepage": "https://github.com/UocDev/Yauiselib#readme"
58
50
  }