@kamen/create-webapp 1.0.12 → 1.0.15
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/index.js +65 -13
- package/package.json +7 -4
- package/scripts/index.js +7 -4
package/index.js
CHANGED
|
@@ -1,13 +1,65 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
1
|
+
const primitiveTypeRe = /^string|number|bigint|boolean|symbol$/;
|
|
2
|
+
const objectTypeRe = /^object|function$/;
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @param {*} value
|
|
6
|
+
* @returns {boolean}
|
|
7
|
+
*/
|
|
8
|
+
export function isPrimitive(value) {
|
|
9
|
+
return primitiveTypeRe.test(typeof value);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @param {*} value
|
|
14
|
+
* @returns {boolean}
|
|
15
|
+
*/
|
|
16
|
+
export function isObject(value) {
|
|
17
|
+
return value !== null && objectTypeRe.test(typeof value);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @param {number} offset
|
|
22
|
+
* @param {number} length
|
|
23
|
+
* @return {number}
|
|
24
|
+
*/
|
|
25
|
+
export function modulo(offset, length) {
|
|
26
|
+
return ((offset % length) + length) % length;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @param {number} [min=0]
|
|
31
|
+
* @param {number} [max=255]
|
|
32
|
+
* @param {number} [step=1]
|
|
33
|
+
* @return {number[]}
|
|
34
|
+
*/
|
|
35
|
+
export function range(min = 0, max = 255, step = 1) {
|
|
36
|
+
return Array.from({length: (max - min) / step + 1}, (_, index) => index * step + min);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @param {number} value
|
|
41
|
+
* @param {number} [min=0]
|
|
42
|
+
* @param {number} [max=255]
|
|
43
|
+
* @return {number}
|
|
44
|
+
*/
|
|
45
|
+
export function clamp(value, min = 0, max = 255) {
|
|
46
|
+
return Math.min(Math.max(value, min), max);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @param {number} [min=0]
|
|
51
|
+
* @param {number} [max=255]
|
|
52
|
+
* @return {number}
|
|
53
|
+
*/
|
|
54
|
+
export function randomFromRange(min = 0, max = 255) {
|
|
55
|
+
return Math.floor(Math.random() * (max - min + 1) + min);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* @template T
|
|
60
|
+
* @param {T[]} [list=[]]
|
|
61
|
+
* @returns {T}
|
|
62
|
+
*/
|
|
63
|
+
export function randomFromList(list = []) {
|
|
64
|
+
return list[randomFromRange(0, list.length - 1)];
|
|
65
|
+
}
|
package/package.json
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kamen/create-webapp",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.15",
|
|
4
4
|
"description": "npm init @kamen/webapp",
|
|
5
5
|
"homepage": "https://www.npmjs.com/package/@kamen/create-webapp",
|
|
6
6
|
"license": "UNLICENSED",
|
|
7
7
|
"private": false,
|
|
8
|
-
"keywords": ["web"],
|
|
8
|
+
"keywords": ["init", "utlity", "web"],
|
|
9
9
|
"type": "module",
|
|
10
10
|
"main": "index.js",
|
|
11
11
|
"bin": {
|
|
12
12
|
"create-webapp": "scripts/index.js"
|
|
13
13
|
},
|
|
14
|
+
"exports": {
|
|
15
|
+
".": "./index.js"
|
|
16
|
+
},
|
|
14
17
|
"author": {
|
|
15
18
|
"name": "Kamen Balabanov",
|
|
16
19
|
"email": "kbalabanov@gmail.com"
|
|
@@ -20,8 +23,8 @@
|
|
|
20
23
|
"url": "git+https://github.com/L1feF0rm/special-octo-barnacle.git"
|
|
21
24
|
},
|
|
22
25
|
"engines": {
|
|
23
|
-
"node": ">=
|
|
24
|
-
"npm": ">=
|
|
26
|
+
"node": ">=20",
|
|
27
|
+
"npm": ">=10"
|
|
25
28
|
},
|
|
26
29
|
"scripts": {
|
|
27
30
|
"test": "echo \"Error: no test specified\" && exit 1"
|
package/scripts/index.js
CHANGED
|
@@ -2,11 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
import {cwd, versions} from 'node:process';
|
|
4
4
|
|
|
5
|
+
import home, {named} from '@kamen/create-webapp';
|
|
6
|
+
|
|
5
7
|
console.log('package default binary');
|
|
6
8
|
|
|
7
|
-
console.log(
|
|
8
|
-
console.log(
|
|
9
|
-
|
|
10
|
-
console.log(
|
|
9
|
+
console.log('home', home);
|
|
10
|
+
console.log('named', named);
|
|
11
|
+
|
|
12
|
+
console.log('versions', versions);
|
|
13
|
+
console.log('cwd()', cwd());
|
|
11
14
|
|
|
12
15
|
process.exit(0);
|