eyeling 1.19.5 → 1.19.6

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 (35) hide show
  1. package/examples/deck/extra.md +169 -0
  2. package/examples/extra/collatz-1000.js +138 -0
  3. package/examples/extra/control-system.js +68 -0
  4. package/examples/extra/deep-taxonomy-100000.js +95 -0
  5. package/examples/extra/delfour.js +110 -0
  6. package/examples/extra/euler-identity.js +41 -0
  7. package/examples/extra/fibonacci.js +81 -0
  8. package/examples/extra/goldbach-1000.js +112 -0
  9. package/examples/extra/gps.js +274 -0
  10. package/examples/extra/kaprekar-6174.js +112 -0
  11. package/examples/extra/matrix-mechanics.js +69 -0
  12. package/examples/extra/odrl-dpv-ehds-risk-ranked.js +255 -0
  13. package/examples/extra/output/collatz-1000.txt +18 -0
  14. package/examples/extra/output/control-system.txt +14 -0
  15. package/examples/extra/output/deep-taxonomy-100000.txt +15 -0
  16. package/examples/extra/output/delfour.txt +20 -0
  17. package/examples/extra/output/euler-identity.txt +12 -0
  18. package/examples/extra/output/fibonacci.txt +21 -0
  19. package/examples/extra/output/goldbach-1000.txt +17 -0
  20. package/examples/extra/output/gps.txt +33 -0
  21. package/examples/extra/output/kaprekar-6174.txt +17 -0
  22. package/examples/extra/output/matrix-mechanics.txt +14 -0
  23. package/examples/extra/output/odrl-dpv-ehds-risk-ranked.txt +48 -0
  24. package/examples/extra/output/path-discovery.txt +28 -0
  25. package/examples/extra/output/pn-junction-tunneling.txt +15 -0
  26. package/examples/extra/output/polynomial.txt +20 -0
  27. package/examples/extra/output/sudoku.txt +47 -0
  28. package/examples/extra/output/transistor-switch.txt +16 -0
  29. package/examples/extra/path-discovery.js +45114 -0
  30. package/examples/extra/pn-junction-tunneling.js +69 -0
  31. package/examples/extra/polynomial.js +181 -0
  32. package/examples/extra/sudoku.js +330 -0
  33. package/examples/extra/transistor-switch.js +93 -0
  34. package/package.json +3 -2
  35. package/test/extra.test.js +100 -0
@@ -0,0 +1,100 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ const fs = require('node:fs');
5
+ const path = require('node:path');
6
+ const cp = require('node:child_process');
7
+
8
+ const TTY = process.stdout.isTTY;
9
+ const C = TTY
10
+ ? { g: '\x1b[32m', r: '\x1b[31m', y: '\x1b[33m', dim: '\x1b[2m', n: '\x1b[0m' }
11
+ : { g: '', r: '', y: '', dim: '', n: '' };
12
+ const msTag = (ms) => `${C.dim}(${ms} ms)${C.n}`;
13
+
14
+ function ok(msg) {
15
+ console.log(`${C.g}OK${C.n} ${msg}`);
16
+ }
17
+ function fail(msg) {
18
+ console.error(`${C.r}FAIL${C.n} ${msg}`);
19
+ }
20
+ function info(msg) {
21
+ console.log(`${C.y}==${C.n} ${msg}`);
22
+ }
23
+
24
+ function main() {
25
+ const suiteStart = Date.now();
26
+ const root = path.resolve(__dirname, '..');
27
+ const extraDir = path.join(root, 'examples', 'extra');
28
+ const outputDir = path.join(extraDir, 'output');
29
+ const nodePath = process.execPath;
30
+
31
+ if (!fs.existsSync(extraDir)) {
32
+ fail(`Cannot find examples/extra directory: ${extraDir}`);
33
+ process.exit(1);
34
+ }
35
+
36
+ fs.mkdirSync(outputDir, { recursive: true });
37
+
38
+ const files = fs
39
+ .readdirSync(extraDir)
40
+ .filter((f) => f.endsWith('.js'))
41
+ .sort((a, b) => a.localeCompare(b));
42
+
43
+ info(`Running ${files.length} extra examples`);
44
+ console.log(`${C.dim}node ${process.version}${C.n}`);
45
+
46
+ if (files.length === 0) {
47
+ ok('No .js files found in examples/extra/');
48
+ process.exit(0);
49
+ }
50
+
51
+ let passed = 0;
52
+ let failed = 0;
53
+ const idxWidth = String(files.length).length;
54
+
55
+ for (let i = 0; i < files.length; i += 1) {
56
+ const idx = String(i + 1).padStart(idxWidth, '0');
57
+ const file = files[i];
58
+ const start = Date.now();
59
+
60
+ const inputPath = path.join(extraDir, file);
61
+ const outputPath = path.join(outputDir, file.replace(/\.js$/i, '.txt'));
62
+
63
+ const r = cp.spawnSync(nodePath, [inputPath], {
64
+ cwd: extraDir,
65
+ encoding: 'utf8',
66
+ maxBuffer: 200 * 1024 * 1024,
67
+ stdio: ['ignore', 'pipe', 'pipe'],
68
+ });
69
+
70
+ const stdout = r.stdout || '';
71
+ fs.writeFileSync(outputPath, stdout, 'utf8');
72
+
73
+ const rc = r.status == null ? 1 : r.status;
74
+ const ms = Date.now() - start;
75
+
76
+ if (rc === 0) {
77
+ ok(`${idx} ${file} -> output/${path.basename(outputPath)} ${msTag(ms)}`);
78
+ passed += 1;
79
+ } else {
80
+ fail(`${idx} ${file} ${msTag(ms)}`);
81
+ fail(`Exit code ${rc}`);
82
+ if (r.stderr) process.stderr.write(r.stderr);
83
+ failed += 1;
84
+ }
85
+ }
86
+
87
+ console.log('');
88
+ const suiteMs = Date.now() - suiteStart;
89
+ info(`Total elapsed: ${suiteMs} ms (${(suiteMs / 1000).toFixed(2)} s)`);
90
+
91
+ if (failed === 0) {
92
+ ok(`All extra examples passed (${passed}/${files.length})`);
93
+ process.exit(0);
94
+ }
95
+
96
+ fail(`Some extra examples failed (${passed}/${files.length})`);
97
+ process.exit(2);
98
+ }
99
+
100
+ main();