@kamen/create-webapp 1.0.44 → 1.0.46

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 (3) hide show
  1. package/README.md +28 -0
  2. package/index.js +27 -0
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -42,6 +42,34 @@ const data = Array
42
42
  console.dir(data);
43
43
  ```
44
44
 
45
+ ### Dynamic import from CDN
46
+
47
+ ```js
48
+ const {
49
+ createRandomFromList
50
+ } = await import('https://esm.run/@kamen/create-webapp');
51
+
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;
57
+ return Array
58
+ .from({length}, (_, index) => [
59
+ String.fromCharCode(lowerCode + index),
60
+ String.fromCharCode(upperCode + index)
61
+ ])
62
+ .flat();
63
+ }
64
+
65
+ const identHandler = createRandomFromList(createAlphabet());
66
+ const identFormatHandler = () => Array
67
+ .from({length: 1 << 5}, identHandler)
68
+ .join('');
69
+
70
+ console.log(identFormatHandler());
71
+ ```
72
+
45
73
  ### Advanced example
46
74
 
47
75
  [SVG Path Generative Art](https://codepen.io/L1feF0rm/pen/GRzGxdb)
package/index.js CHANGED
@@ -2,6 +2,26 @@ const primitiveTypeRe = /^string|number|bigint|boolean|symbol$/;
2
2
  const objectTypeRe = /^object|function$/;
3
3
  export {default as temporal} from './temporal.js';
4
4
 
5
+ export class DOMUtils {
6
+ static namespaces = class {
7
+ static HTML = 'http://www.w3.org/1999/xhtml';
8
+ static MathML = 'http://www.w3.org/1998/Math/MathML';
9
+ static SVG = 'http://www.w3.org/2000/svg';
10
+ };
11
+
12
+ static createHTMLElement(tag) {
13
+ return document.createElementNS(this.namespaces.HTML, tag);
14
+ }
15
+
16
+ static createMathMLElement() {
17
+ return document.createElementNS(this.namespaces.MathML, tag);
18
+ }
19
+
20
+ static createSVGElement() {
21
+ return document.createElementNS(this.namespaces.SVG, tag);
22
+ }
23
+ }
24
+
5
25
  /**
6
26
  * @param {*} value
7
27
  * @returns {boolean}
@@ -47,6 +67,13 @@ export function clamp(value, min = 0, max = 255) {
47
67
  return Math.min(Math.max(value, min), max);
48
68
  }
49
69
 
70
+ /**
71
+ * @returns {string}
72
+ */
73
+ export function randomSlug() {
74
+ return Math.random().toString(36).slice(2);
75
+ }
76
+
50
77
  /**
51
78
  * @param {number} [min=0]
52
79
  * @param {number} [max=255]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kamen/create-webapp",
3
- "version": "1.0.44",
3
+ "version": "1.0.46",
4
4
  "description": "npm init @kamen/webapp",
5
5
  "keywords": [
6
6
  "init",
@@ -20,7 +20,7 @@
20
20
  },
21
21
  "author": {
22
22
  "name": "Kamen Balabanov",
23
- "email": "kbalabanov@gmail.com"
23
+ "email": "k.balabanov@gmail.com"
24
24
  },
25
25
  "repository": {
26
26
  "type": "git",