metanum 1.2.0 → 1.4.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "metanum",
3
- "version": "1.2.0",
3
+ "version": "1.4.0",
4
4
  "description": "A javascript library that handles numbers as large as f_ε₀(9e15)",
5
5
  "main": "metanum.js",
6
6
  "scripts": {
@@ -33,9 +33,47 @@
33
33
  <h1>MetaNum Test Interface</h1>
34
34
 
35
35
  <h2>test in console</h2>
36
+
37
+ <button id="runTestBtn">run test_mixed.js</button>
38
+ <div id="consoleOutput" style="margin-top: 20px; padding: 10px; background-color: #f0f0f0; border-radius: 4px; min-height: 100px; font-family: monospace; font-size: 14px; white-space: pre-wrap;"></div>
39
+
40
+ <script>
41
+ document.getElementById('runTestBtn').addEventListener('click', function() {
42
+ const outputDiv = document.getElementById('consoleOutput');
43
+ outputDiv.innerHTML = '';
44
+
45
+ // save original console.log
46
+ const originalLog = console.log;
47
+
48
+ // rewrite console.log to output to the div
49
+ console.log = function(...args) {
50
+ originalLog.apply(console, args);
51
+ const logEntry = document.createElement('div');
52
+ logEntry.textContent = args.map(arg => {
53
+ if (typeof arg === 'object') {
54
+ return JSON.stringify(arg, null, 2);
55
+ }
56
+ return String(arg);
57
+ }).join(' ');
58
+ outputDiv.appendChild(logEntry);
59
+ };
36
60
 
61
+ // load test_mixed.js
62
+ const script = document.createElement('script');
63
+ script.src = './test_mixed.js';
64
+ script.onload = function() {
65
+ console.log('test_mixed.js loaded');
66
+ };
67
+ script.onerror = function() {
68
+ console.log('Failed to load test_mixed.js');
69
+ console.log = originalLog;
70
+ };
71
+ document.head.appendChild(script);
72
+ });
73
+ </script>
37
74
  </div>
38
75
  <script src="./metanum.js"></script>
76
+ <script src="./format-metanum.js"></script>
39
77
  <script>
40
78
  // test in console
41
79
  console.log('=== MetaNum Library by dlsdl ===');