@kamen/create-webapp 1.0.52 → 1.0.54

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.
Files changed (2) hide show
  1. package/README.md +33 -39
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -5,72 +5,66 @@
5
5
  ```bash
6
6
  $ npm init @kamen/webapp
7
7
  ```
8
+ or
9
+ ```bash
10
+ $ deno run npm:@kamen/create-webapp
11
+ ```
8
12
 
9
13
  ## Utility Functions
10
14
 
11
15
  ### Basic example
12
16
 
17
+ #### NPM Package
18
+
13
19
  ```js
14
20
  import {
15
21
  createRandomFromRange,
16
- createRandomFromList,
17
- createRandomColorFromSaturationLightnessAlpha
22
+ createRandomFromList
18
23
  } from '@kamen/create-webapp/helpers/random';
19
-
20
- const characters = Array
21
- .from({length: 26}, (_, index) => [
22
- String.fromCharCode(65 + index),
23
- String.fromCharCode(97 + index)
24
- ])
25
- .flat();
26
- const ageHandler = createRandomFromRange(0, 99);
27
- const colorHandler = createRandomFromList(['red', 'green', 'blue']);
28
- const stateHandler = createRandomFromList([true, false]);
29
- const identHandler = createRandomFromList(characters);
30
- const identFormatHandler = () => Array
31
- .from({length: 1 << 5}, identHandler)
32
- .join('');
33
- const data = Array
34
- .from({length: 1 << 8}, (_, index) => ({
35
- index,
36
- age: ageHandler(),
37
- color: colorHandler(),
38
- state: stateHandler(),
39
- ident: identFormatHandler()
40
- }));
41
-
42
- console.dir(data);
43
24
  ```
44
25
 
45
- ### Dynamic import from CDN
26
+ #### Dynamic import from CDN
46
27
 
47
28
  ```js
48
29
  const {
30
+ createRandomFromRange,
49
31
  createRandomFromList
50
32
  } = await import('https://esm.run/@kamen/create-webapp/helpers/random');
33
+ ```
51
34
 
52
- function createAlphabet() {
53
- const baseChar = 'a';
54
- const lowerCode = baseChar.charCodeAt();
55
- const upperCode = baseChar.toUpperCase().charCodeAt();
56
- const length = 'z'.charCodeAt() - lowerCode + 1;
35
+ ```js
36
+ function createCharacters() {
37
+ const [fromCharacter, toCharacter] = ['a', 'z'];
38
+ const lowerCharacterCode = fromCharacter.toLowerCase().charCodeAt();
39
+ const upperCharacterCode = fromCharacter.toUpperCase().charCodeAt();
40
+ const length = toCharacter.toLowerCase().charCodeAt() - lowerCharacterCode + 1;
57
41
  return Array
58
42
  .from({length}, (_, index) => [
59
- String.fromCharCode(lowerCode + index),
60
- String.fromCharCode(upperCode + index)
43
+ String.fromCharCode(lowerCharacterCode + index),
44
+ String.fromCharCode(upperCharacterCode + index)
61
45
  ])
62
46
  .flat();
63
47
  }
64
48
 
65
- const identHandler = createRandomFromList(createAlphabet());
66
- const identFormatHandler = () => Array
67
- .from({length: 1 << 5}, identHandler)
49
+ const ageHandler = createRandomFromRange(0, 99);
50
+ const colorHandler = createRandomFromList(['red', 'green', 'blue']);
51
+ const stateHandler = createRandomFromList([true, false]);
52
+ const characterHandler = createRandomFromList(createCharacters());
53
+ const identHandler = () => Array
54
+ .from({length: 1 << 5}, characterHandler)
68
55
  .join('');
56
+ const data = Array
57
+ .from({length: 1 << 8}, (_, index) => ({
58
+ index,
59
+ age: ageHandler(),
60
+ color: colorHandler(),
61
+ state: stateHandler(),
62
+ ident: identHandler()
63
+ }));
69
64
 
70
- console.log(identFormatHandler());
65
+ console.dir(data);
71
66
  ```
72
67
 
73
68
  ### Advanced example
74
69
 
75
70
  [SVG Path Generative Art](https://codepen.io/L1feF0rm/pen/GRzGxdb)
76
-
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kamen/create-webapp",
3
- "version": "1.0.52",
3
+ "version": "1.0.54",
4
4
  "description": "npm init @kamen/webapp",
5
5
  "keywords": [
6
6
  "init",