@jackens/nnn 2025.11.4 → 2025.11.5
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/nnn.d.ts +1 -1
- package/nnn.js +2 -4
- package/package.json +1 -1
- package/readme.md +93 -3
package/nnn.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ export declare const c: (root: CRoot, splitter?: string) => string;
|
|
|
24
24
|
* - Each entry in `specs` is a tuple of:
|
|
25
25
|
* - `max_width`: maximum number of cells in a row (viewport width breakpoint).
|
|
26
26
|
* - `width` (optional, default: `1`): number of cells occupied by the element.
|
|
27
|
-
* - `height` (optional): number of cells in height occupied by the element.
|
|
27
|
+
* - `height` (optional, default: `1`): number of cells in height occupied by the element.
|
|
28
28
|
*/
|
|
29
29
|
export declare const rwd: (root: CRoot, selector: string, cell_width_px: number, cell_height_px: number, ...specs: [number, number?, number?][]) => void;
|
|
30
30
|
/** A tiny CSV parsing helper. */
|
package/nnn.js
CHANGED
|
@@ -61,6 +61,7 @@ var rwd = (root, selector, cell_width_px, cell_height_px, ...specs) => {
|
|
|
61
61
|
for (let [max_width, width, height] of specs) {
|
|
62
62
|
const node = max_width === 1 ? main : pro(root)[`@media(min-width:${cell_width_px * max_width}px)`][selector];
|
|
63
63
|
width ??= 1;
|
|
64
|
+
height ??= 1;
|
|
64
65
|
let gcd = 100 * width;
|
|
65
66
|
let tmp = max_width;
|
|
66
67
|
while (tmp) {
|
|
@@ -68,11 +69,8 @@ var rwd = (root, selector, cell_width_px, cell_height_px, ...specs) => {
|
|
|
68
69
|
}
|
|
69
70
|
const w_100_per_gcd = 100 * width / gcd;
|
|
70
71
|
node.width = max_width === gcd ? `${w_100_per_gcd}%` : `calc(${w_100_per_gcd}% / ${max_width / gcd})`;
|
|
71
|
-
|
|
72
|
-
node.height = `${cell_height_px * height}px`;
|
|
73
|
-
}
|
|
72
|
+
node.height = `${cell_height_px * height}px`;
|
|
74
73
|
}
|
|
75
|
-
console.log(root);
|
|
76
74
|
};
|
|
77
75
|
var csv_parse = (csv, separator = ",") => {
|
|
78
76
|
const main_pattern = /\n|(?<!")("(?:[^"]|"")*")(?!")/g;
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -676,8 +676,6 @@ JavaScript syntax highlighting helper (built on `nanolight`).
|
|
|
676
676
|
```ts
|
|
677
677
|
const code_js = "const answer_to_life_the_universe_and_everything = { 42: 42 }['42'] /* 42 */"
|
|
678
678
|
|
|
679
|
-
console.log(nanolight_js(code_js))
|
|
680
|
-
|
|
681
679
|
expect(nanolight_js(code_js)).to.deep.equal([
|
|
682
680
|
['span', { class: 'keyword' }, 'const'],
|
|
683
681
|
' ',
|
|
@@ -805,7 +803,54 @@ A responsive‑web‑design helper that generates CSS rules for a grid layout.
|
|
|
805
803
|
- Each entry in `specs` is a tuple of:
|
|
806
804
|
- `max_width`: maximum number of cells in a row (viewport width breakpoint).
|
|
807
805
|
- `width` (optional, default: `1`): number of cells occupied by the element.
|
|
808
|
-
- `height` (optional): number of cells in height occupied by the element.
|
|
806
|
+
- `height` (optional, default: `1`): number of cells in height occupied by the element.
|
|
807
|
+
|
|
808
|
+
#### Usage Examples
|
|
809
|
+
|
|
810
|
+
```ts
|
|
811
|
+
const css: CRoot = {
|
|
812
|
+
body: {
|
|
813
|
+
margin: 0
|
|
814
|
+
},
|
|
815
|
+
'.r6': {
|
|
816
|
+
border: 'solid red 1px',
|
|
817
|
+
'.no-border': {
|
|
818
|
+
border: 'none'
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
rwd(css, '.r6', 200, 50, [6], [3], [1, 1, 2])
|
|
824
|
+
|
|
825
|
+
expect(css).to.deep.equal({
|
|
826
|
+
body: {
|
|
827
|
+
margin: 0
|
|
828
|
+
},
|
|
829
|
+
'.r6': {
|
|
830
|
+
border: 'solid red 1px',
|
|
831
|
+
'.no-border': {
|
|
832
|
+
border: 'none'
|
|
833
|
+
},
|
|
834
|
+
boxSizing: 'border-box',
|
|
835
|
+
display: 'block',
|
|
836
|
+
float: 'left',
|
|
837
|
+
width: '100%',
|
|
838
|
+
height: '100px'
|
|
839
|
+
},
|
|
840
|
+
'@media(min-width:600px)': {
|
|
841
|
+
'.r6': {
|
|
842
|
+
width: 'calc(100% / 3)',
|
|
843
|
+
height: '50px'
|
|
844
|
+
}
|
|
845
|
+
},
|
|
846
|
+
'@media(min-width:1200px)': {
|
|
847
|
+
'.r6': {
|
|
848
|
+
width: 'calc(50% / 3)',
|
|
849
|
+
height: '50px'
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
})
|
|
853
|
+
```
|
|
809
854
|
|
|
810
855
|
### s
|
|
811
856
|
|
|
@@ -848,6 +893,51 @@ Generates a UUID v1 (time-based) identifier.
|
|
|
848
893
|
|
|
849
894
|
- Optional `node` must match `/^[0-9a-f]*$/`; it is trimmed to the last 12 characters and left-padded with zeros.
|
|
850
895
|
|
|
896
|
+
#### Usage Examples
|
|
897
|
+
|
|
898
|
+
```ts
|
|
899
|
+
for (let i = 1; i <= 22136; ++i) {
|
|
900
|
+
const uuid = uuid_v1()
|
|
901
|
+
|
|
902
|
+
if (i === 1) {
|
|
903
|
+
expect(uuid.split('-')[3]).to.deep.equal('8001')
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
if (i === 4095) {
|
|
907
|
+
expect(uuid.split('-')[3]).to.deep.equal('8fff')
|
|
908
|
+
}
|
|
909
|
+
|
|
910
|
+
if (i === 4096) {
|
|
911
|
+
expect(uuid.split('-')[3]).to.deep.equal('9000')
|
|
912
|
+
}
|
|
913
|
+
|
|
914
|
+
if (i === 9029) {
|
|
915
|
+
expect(uuid.split('-')[3]).to.deep.equal('a345')
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
if (i === 13398) {
|
|
919
|
+
expect(uuid.split('-')[3]).to.deep.equal('b456')
|
|
920
|
+
}
|
|
921
|
+
|
|
922
|
+
if (i === 16384) {
|
|
923
|
+
expect(uuid.split('-')[3]).to.deep.equal('8000')
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
if (i === 17767) {
|
|
927
|
+
expect(uuid.split('-')[3]).to.deep.equal('8567')
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
```
|
|
931
|
+
|
|
932
|
+
```ts
|
|
933
|
+
expect(uuid_v1(new Date(), '000123456789abc').split('-')[4]).to.deep.equal('123456789abc')
|
|
934
|
+
expect(uuid_v1(new Date(), '123456789').split('-')[4]).to.deep.equal('000123456789')
|
|
935
|
+
```
|
|
936
|
+
|
|
937
|
+
```ts
|
|
938
|
+
expect(uuid_v1(new Date(323325000000)).startsWith('c1399400-9a71-11bd')).to.be.true
|
|
939
|
+
```
|
|
940
|
+
|
|
851
941
|
## License
|
|
852
942
|
|
|
853
943
|
The MIT License (MIT)
|