@suchipi/quickjs 0.2.0 → 0.2.1

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 (182) hide show
  1. package/build/aarch64-apple-darwin/bin/qjs +0 -0
  2. package/build/aarch64-apple-darwin/bin/qjsbootstrap +0 -0
  3. package/build/aarch64-apple-darwin/bin/qjsbootstrap-bytecode +0 -0
  4. package/build/aarch64-apple-darwin/bin/qjsc +0 -0
  5. package/build/aarch64-apple-darwin/bin/quickjs-run +0 -0
  6. package/build/aarch64-apple-darwin/extras/fib.so +0 -0
  7. package/build/aarch64-apple-darwin/extras/is-stdin-a-tty +0 -0
  8. package/build/aarch64-apple-darwin/extras/log-argv +0 -0
  9. package/build/aarch64-apple-darwin/extras/point.so +0 -0
  10. package/build/aarch64-apple-darwin/extras/run-test262 +0 -0
  11. package/build/aarch64-apple-darwin/extras/sample-program/sum +0 -0
  12. package/build/aarch64-apple-darwin/extras/stack-limit-test +0 -0
  13. package/build/aarch64-apple-darwin/lib/quickjs-core.a +0 -0
  14. package/build/aarch64-apple-darwin/lib/quickjs-full.a +0 -0
  15. package/build/aarch64-unknown-linux-gnu/bin/qjs +0 -0
  16. package/build/aarch64-unknown-linux-gnu/bin/qjsbootstrap +0 -0
  17. package/build/aarch64-unknown-linux-gnu/bin/qjsbootstrap-bytecode +0 -0
  18. package/build/aarch64-unknown-linux-gnu/bin/qjsc +0 -0
  19. package/build/aarch64-unknown-linux-gnu/bin/quickjs-run +0 -0
  20. package/build/aarch64-unknown-linux-gnu/extras/fib.so +0 -0
  21. package/build/aarch64-unknown-linux-gnu/extras/is-stdin-a-tty +0 -0
  22. package/build/aarch64-unknown-linux-gnu/extras/log-argv +0 -0
  23. package/build/aarch64-unknown-linux-gnu/extras/point.so +0 -0
  24. package/build/aarch64-unknown-linux-gnu/extras/run-test262 +0 -0
  25. package/build/aarch64-unknown-linux-gnu/extras/sample-program/sum +0 -0
  26. package/build/aarch64-unknown-linux-gnu/extras/stack-limit-test +0 -0
  27. package/build/aarch64-unknown-linux-gnu/lib/quickjs-core.a +0 -0
  28. package/build/aarch64-unknown-linux-gnu/lib/quickjs-full.a +0 -0
  29. package/build/aarch64-unknown-linux-musl/bin/qjs +0 -0
  30. package/build/aarch64-unknown-linux-musl/bin/qjsbootstrap +0 -0
  31. package/build/aarch64-unknown-linux-musl/bin/qjsbootstrap-bytecode +0 -0
  32. package/build/aarch64-unknown-linux-musl/bin/qjsc +0 -0
  33. package/build/aarch64-unknown-linux-musl/bin/quickjs-run +0 -0
  34. package/build/aarch64-unknown-linux-musl/extras/fib.so +0 -0
  35. package/build/aarch64-unknown-linux-musl/extras/is-stdin-a-tty +0 -0
  36. package/build/aarch64-unknown-linux-musl/extras/log-argv +0 -0
  37. package/build/aarch64-unknown-linux-musl/extras/point.so +0 -0
  38. package/build/aarch64-unknown-linux-musl/extras/run-test262 +0 -0
  39. package/build/aarch64-unknown-linux-musl/extras/sample-program/sum +0 -0
  40. package/build/aarch64-unknown-linux-musl/extras/stack-limit-test +0 -0
  41. package/build/aarch64-unknown-linux-musl/lib/quickjs-core.a +0 -0
  42. package/build/aarch64-unknown-linux-musl/lib/quickjs-full.a +0 -0
  43. package/build/aarch64-unknown-linux-static/bin/qjs +0 -0
  44. package/build/aarch64-unknown-linux-static/bin/qjsbootstrap +0 -0
  45. package/build/aarch64-unknown-linux-static/bin/qjsbootstrap-bytecode +0 -0
  46. package/build/aarch64-unknown-linux-static/bin/qjsc +0 -0
  47. package/build/aarch64-unknown-linux-static/bin/quickjs-run +0 -0
  48. package/build/aarch64-unknown-linux-static/extras/fib.so +0 -0
  49. package/build/aarch64-unknown-linux-static/extras/is-stdin-a-tty +0 -0
  50. package/build/aarch64-unknown-linux-static/extras/log-argv +0 -0
  51. package/build/aarch64-unknown-linux-static/extras/point.so +0 -0
  52. package/build/aarch64-unknown-linux-static/extras/run-test262 +0 -0
  53. package/build/aarch64-unknown-linux-static/extras/sample-program/sum +0 -0
  54. package/build/aarch64-unknown-linux-static/extras/stack-limit-test +0 -0
  55. package/build/aarch64-unknown-linux-static/lib/quickjs-core.a +0 -0
  56. package/build/aarch64-unknown-linux-static/lib/quickjs-full.a +0 -0
  57. package/build/{aarch64-unknown-linux-musl/dts → dts}/quickjs-libc.d.ts +4 -0
  58. package/build/x86_64-apple-darwin/bin/qjs +0 -0
  59. package/build/x86_64-apple-darwin/bin/qjsbootstrap +0 -0
  60. package/build/x86_64-apple-darwin/bin/qjsbootstrap-bytecode +0 -0
  61. package/build/x86_64-apple-darwin/bin/qjsc +0 -0
  62. package/build/x86_64-apple-darwin/bin/quickjs-run +0 -0
  63. package/build/x86_64-apple-darwin/extras/fib.so +0 -0
  64. package/build/x86_64-apple-darwin/extras/is-stdin-a-tty +0 -0
  65. package/build/x86_64-apple-darwin/extras/log-argv +0 -0
  66. package/build/x86_64-apple-darwin/extras/point.so +0 -0
  67. package/build/x86_64-apple-darwin/extras/run-test262 +0 -0
  68. package/build/x86_64-apple-darwin/extras/sample-program/sum +0 -0
  69. package/build/x86_64-apple-darwin/extras/stack-limit-test +0 -0
  70. package/build/x86_64-apple-darwin/lib/quickjs-core.a +0 -0
  71. package/build/x86_64-apple-darwin/lib/quickjs-full.a +0 -0
  72. package/build/x86_64-pc-windows-static/bin/qjs.exe +0 -0
  73. package/build/x86_64-pc-windows-static/bin/qjsbootstrap-bytecode.exe +0 -0
  74. package/build/x86_64-pc-windows-static/bin/qjsbootstrap.exe +0 -0
  75. package/build/x86_64-pc-windows-static/bin/qjsc.exe +0 -0
  76. package/build/x86_64-pc-windows-static/bin/quickjs-run.exe +0 -0
  77. package/build/x86_64-pc-windows-static/extras/fib.so +1 -0
  78. package/build/x86_64-pc-windows-static/extras/is-stdin-a-tty.exe +0 -0
  79. package/build/x86_64-pc-windows-static/extras/log-argv.exe +0 -0
  80. package/build/x86_64-pc-windows-static/extras/point.so +1 -0
  81. package/build/x86_64-pc-windows-static/extras/run-test262.exe +0 -0
  82. package/build/x86_64-pc-windows-static/extras/sample-program/sum.exe +0 -0
  83. package/build/x86_64-pc-windows-static/extras/stack-limit-test.exe +0 -0
  84. package/build/x86_64-pc-windows-static/lib/quickjs-core.a +0 -0
  85. package/build/x86_64-pc-windows-static/lib/quickjs-full.a +0 -0
  86. package/build/x86_64-unknown-linux-gnu/bin/qjs +0 -0
  87. package/build/x86_64-unknown-linux-gnu/bin/qjsbootstrap +0 -0
  88. package/build/x86_64-unknown-linux-gnu/bin/qjsbootstrap-bytecode +0 -0
  89. package/build/x86_64-unknown-linux-gnu/bin/qjsc +0 -0
  90. package/build/x86_64-unknown-linux-gnu/bin/quickjs-run +0 -0
  91. package/build/x86_64-unknown-linux-gnu/extras/fib.so +0 -0
  92. package/build/x86_64-unknown-linux-gnu/extras/is-stdin-a-tty +0 -0
  93. package/build/x86_64-unknown-linux-gnu/extras/log-argv +0 -0
  94. package/build/x86_64-unknown-linux-gnu/extras/point.so +0 -0
  95. package/build/x86_64-unknown-linux-gnu/extras/run-test262 +0 -0
  96. package/build/x86_64-unknown-linux-gnu/extras/sample-program/sum +0 -0
  97. package/build/x86_64-unknown-linux-gnu/extras/stack-limit-test +0 -0
  98. package/build/x86_64-unknown-linux-gnu/lib/quickjs-core.a +0 -0
  99. package/build/x86_64-unknown-linux-gnu/lib/quickjs-full.a +0 -0
  100. package/build/x86_64-unknown-linux-musl/bin/qjs +0 -0
  101. package/build/x86_64-unknown-linux-musl/bin/qjsbootstrap +0 -0
  102. package/build/x86_64-unknown-linux-musl/bin/qjsbootstrap-bytecode +0 -0
  103. package/build/x86_64-unknown-linux-musl/bin/qjsc +0 -0
  104. package/build/x86_64-unknown-linux-musl/bin/quickjs-run +0 -0
  105. package/build/x86_64-unknown-linux-musl/extras/fib.so +0 -0
  106. package/build/x86_64-unknown-linux-musl/extras/is-stdin-a-tty +0 -0
  107. package/build/x86_64-unknown-linux-musl/extras/log-argv +0 -0
  108. package/build/x86_64-unknown-linux-musl/extras/point.so +0 -0
  109. package/build/x86_64-unknown-linux-musl/extras/run-test262 +0 -0
  110. package/build/x86_64-unknown-linux-musl/extras/sample-program/sum +0 -0
  111. package/build/x86_64-unknown-linux-musl/extras/stack-limit-test +0 -0
  112. package/build/x86_64-unknown-linux-musl/lib/quickjs-core.a +0 -0
  113. package/build/x86_64-unknown-linux-musl/lib/quickjs-full.a +0 -0
  114. package/build/x86_64-unknown-linux-static/bin/qjs +0 -0
  115. package/build/x86_64-unknown-linux-static/bin/qjsbootstrap +0 -0
  116. package/build/x86_64-unknown-linux-static/bin/qjsbootstrap-bytecode +0 -0
  117. package/build/x86_64-unknown-linux-static/bin/qjsc +0 -0
  118. package/build/x86_64-unknown-linux-static/bin/quickjs-run +0 -0
  119. package/build/x86_64-unknown-linux-static/extras/fib.so +0 -0
  120. package/build/x86_64-unknown-linux-static/extras/is-stdin-a-tty +0 -0
  121. package/build/x86_64-unknown-linux-static/extras/log-argv +0 -0
  122. package/build/x86_64-unknown-linux-static/extras/point.so +0 -0
  123. package/build/x86_64-unknown-linux-static/extras/run-test262 +0 -0
  124. package/build/x86_64-unknown-linux-static/extras/sample-program/sum +0 -0
  125. package/build/x86_64-unknown-linux-static/extras/stack-limit-test +0 -0
  126. package/build/x86_64-unknown-linux-static/lib/quickjs-core.a +0 -0
  127. package/build/x86_64-unknown-linux-static/lib/quickjs-full.a +0 -0
  128. package/package.json +1 -1
  129. package/tsconfig.json +11 -2
  130. package/build/aarch64-apple-darwin/dts/quickjs-libc.d.ts +0 -1355
  131. package/build/aarch64-unknown-linux-gnu/dts/inspect.d.ts +0 -123
  132. package/build/aarch64-unknown-linux-gnu/dts/quickjs-libbytecode.d.ts +0 -24
  133. package/build/aarch64-unknown-linux-gnu/dts/quickjs-libc.d.ts +0 -1355
  134. package/build/aarch64-unknown-linux-gnu/dts/quickjs-libcontext.d.ts +0 -179
  135. package/build/aarch64-unknown-linux-gnu/dts/quickjs-libpointer.d.ts +0 -14
  136. package/build/aarch64-unknown-linux-gnu/dts/quickjs.d.ts +0 -859
  137. package/build/aarch64-unknown-linux-musl/dts/inspect.d.ts +0 -123
  138. package/build/aarch64-unknown-linux-musl/dts/quickjs-libbytecode.d.ts +0 -24
  139. package/build/aarch64-unknown-linux-musl/dts/quickjs-libcontext.d.ts +0 -179
  140. package/build/aarch64-unknown-linux-musl/dts/quickjs-libpointer.d.ts +0 -14
  141. package/build/aarch64-unknown-linux-musl/dts/quickjs.d.ts +0 -859
  142. package/build/aarch64-unknown-linux-static/dts/inspect.d.ts +0 -123
  143. package/build/aarch64-unknown-linux-static/dts/quickjs-libbytecode.d.ts +0 -24
  144. package/build/aarch64-unknown-linux-static/dts/quickjs-libc.d.ts +0 -1355
  145. package/build/aarch64-unknown-linux-static/dts/quickjs-libcontext.d.ts +0 -179
  146. package/build/aarch64-unknown-linux-static/dts/quickjs-libpointer.d.ts +0 -14
  147. package/build/aarch64-unknown-linux-static/dts/quickjs.d.ts +0 -859
  148. package/build/x86_64-apple-darwin/dts/inspect.d.ts +0 -123
  149. package/build/x86_64-apple-darwin/dts/quickjs-libbytecode.d.ts +0 -24
  150. package/build/x86_64-apple-darwin/dts/quickjs-libc.d.ts +0 -1355
  151. package/build/x86_64-apple-darwin/dts/quickjs-libcontext.d.ts +0 -179
  152. package/build/x86_64-apple-darwin/dts/quickjs-libpointer.d.ts +0 -14
  153. package/build/x86_64-apple-darwin/dts/quickjs.d.ts +0 -859
  154. package/build/x86_64-pc-windows-static/dts/inspect.d.ts +0 -123
  155. package/build/x86_64-pc-windows-static/dts/quickjs-libbytecode.d.ts +0 -24
  156. package/build/x86_64-pc-windows-static/dts/quickjs-libc.d.ts +0 -1355
  157. package/build/x86_64-pc-windows-static/dts/quickjs-libcontext.d.ts +0 -179
  158. package/build/x86_64-pc-windows-static/dts/quickjs-libpointer.d.ts +0 -14
  159. package/build/x86_64-pc-windows-static/dts/quickjs.d.ts +0 -859
  160. package/build/x86_64-unknown-linux-gnu/dts/inspect.d.ts +0 -123
  161. package/build/x86_64-unknown-linux-gnu/dts/quickjs-libbytecode.d.ts +0 -24
  162. package/build/x86_64-unknown-linux-gnu/dts/quickjs-libc.d.ts +0 -1355
  163. package/build/x86_64-unknown-linux-gnu/dts/quickjs-libcontext.d.ts +0 -179
  164. package/build/x86_64-unknown-linux-gnu/dts/quickjs-libpointer.d.ts +0 -14
  165. package/build/x86_64-unknown-linux-gnu/dts/quickjs.d.ts +0 -859
  166. package/build/x86_64-unknown-linux-musl/dts/inspect.d.ts +0 -123
  167. package/build/x86_64-unknown-linux-musl/dts/quickjs-libbytecode.d.ts +0 -24
  168. package/build/x86_64-unknown-linux-musl/dts/quickjs-libc.d.ts +0 -1355
  169. package/build/x86_64-unknown-linux-musl/dts/quickjs-libcontext.d.ts +0 -179
  170. package/build/x86_64-unknown-linux-musl/dts/quickjs-libpointer.d.ts +0 -14
  171. package/build/x86_64-unknown-linux-musl/dts/quickjs.d.ts +0 -859
  172. package/build/x86_64-unknown-linux-static/dts/inspect.d.ts +0 -123
  173. package/build/x86_64-unknown-linux-static/dts/quickjs-libbytecode.d.ts +0 -24
  174. package/build/x86_64-unknown-linux-static/dts/quickjs-libc.d.ts +0 -1355
  175. package/build/x86_64-unknown-linux-static/dts/quickjs-libcontext.d.ts +0 -179
  176. package/build/x86_64-unknown-linux-static/dts/quickjs-libpointer.d.ts +0 -14
  177. package/build/x86_64-unknown-linux-static/dts/quickjs.d.ts +0 -859
  178. /package/build/{aarch64-apple-darwin/dts → dts}/inspect.d.ts +0 -0
  179. /package/build/{aarch64-apple-darwin/dts → dts}/quickjs-libbytecode.d.ts +0 -0
  180. /package/build/{aarch64-apple-darwin/dts → dts}/quickjs-libcontext.d.ts +0 -0
  181. /package/build/{aarch64-apple-darwin/dts → dts}/quickjs-libpointer.d.ts +0 -0
  182. /package/build/{aarch64-apple-darwin/dts → dts}/quickjs.d.ts +0 -0
@@ -1,859 +0,0 @@
1
- interface ObjectConstructor {
2
- /**
3
- * Convert the specified value to a primitive value.
4
- *
5
- * The provided hint indicates a preferred return type, which may or may not
6
- * be respected by the engine.
7
- *
8
- * See the abstract operation "ToPrimitive" in the ECMAScript standard for
9
- * more info.
10
- */
11
- toPrimitive(
12
- input: any,
13
- hint: "string" | "number" | "default"
14
- ): string | number | bigint | boolean | undefined | symbol | null;
15
-
16
- /**
17
- * Returns a boolean indicating whether the specified value is a primitive value.
18
- */
19
- isPrimitive(input: any): boolean;
20
- }
21
-
22
- interface SymbolConstructor {
23
- /**
24
- * A method that changes the result of using the `typeof` operator on the
25
- * object. Called by the semantics of the typeof operator.
26
- *
27
- * Note that the following semantics will come into play when use of the
28
- * `typeof` operator causes the engine to call a `Symbol.typeofValue` method
29
- * on an object:
30
- *
31
- * - If the method returns any value other than one of the string values
32
- * which are normally the result of using the `typeof` operator, the engine
33
- * behaves as if no `Symbol.typeofValue` method was present on the object.
34
- * - If an error is thrown from this method, or an error is thrown while
35
- * accessing this property, the error will be silently ignored, and the
36
- * engine will behave as if no `Symbol.typeofValue` method was present on
37
- * the object.
38
- * - If this property is present on an object, but the value of that property
39
- * is not a function, the engine will not consider that value when
40
- * determining the result of the `typeof` operation (it'll ignore it).
41
- */
42
- readonly typeofValue: unique symbol;
43
-
44
- /**
45
- * To override operators (+, -, ==, etc) for an object, set its
46
- * `Symbol.operatorSet` property to an `OperatorSet` object, which can be
47
- * created via `Operators.create`.
48
- */
49
- readonly operatorSet: unique symbol;
50
- }
51
-
52
- /**
53
- * An object that, if placed on another object's `Symbol.operatorSet` property,
54
- * will overload its operators to behave as defined by the functions this
55
- * OperatorSet was constructed with.
56
- *
57
- * You can create an OperatorSet via `Operators(...)` or
58
- * `Operators.create(...)`.
59
- */
60
- declare type OperatorSet = {
61
- /**
62
- * This property is not here at runtime; we just use it to make this type
63
- * differ from an empty object.
64
- */
65
- __is__: "OperatorSet";
66
- };
67
-
68
- interface OperatorFunctions<Left, Right> {
69
- "+": (left: Left, right: Right) => any;
70
- "-": (left: Left, right: Right) => any;
71
- "*": (left: Left, right: Right) => any;
72
- "/": (left: Left, right: Right) => any;
73
- "%": (left: Left, right: Right) => any;
74
- "**": (left: Left, right: Right) => any;
75
- "|": (left: Left, right: Right) => any;
76
- "&": (left: Left, right: Right) => any;
77
- "^": (left: Left, right: Right) => any;
78
- "<<": (left: Left, right: Right) => any;
79
- ">>": (left: Left, right: Right) => any;
80
- ">>>": (left: Left, right: Right) => any;
81
- "==": (left: Left, right: Right) => any;
82
- "<": (left: Left, right: Right) => any;
83
- pos: (left: Left, right: Right) => any;
84
- neg: (left: Left, right: Right) => any;
85
- "++": (left: Left, right: Right) => any;
86
- "--": (left: Left, right: Right) => any;
87
- "~": (left: Left, right: Right) => any;
88
- }
89
-
90
- interface SelfOperators<T> extends Partial<OperatorFunctions<T, T>> {
91
- left?: undefined;
92
- right?: undefined;
93
- }
94
-
95
- interface LeftOperators<T, Left> extends Partial<OperatorFunctions<Left, T>> {
96
- left: {};
97
- right?: undefined;
98
- }
99
-
100
- interface RightOperators<T, Right>
101
- extends Partial<OperatorFunctions<T, Right>> {
102
- left?: undefined;
103
- right: {};
104
- }
105
-
106
- interface OperatorsConstructor {
107
- /**
108
- * Creates a new OperatorSet object, which should be placed on an object's
109
- * Symbol.operatorSet property.
110
- */
111
- <T>(
112
- selfOperators?: SelfOperators<T>,
113
- ...otherOperators: Array<LeftOperators<T, any> | RightOperators<T, any>>
114
- ): OperatorSet;
115
-
116
- /**
117
- * Creates a new OperatorSet object, which should be placed on an object's
118
- * Symbol.operatorSet property.
119
- */
120
- create: <T>(
121
- selfOperators?: SelfOperators<T>,
122
- ...otherOperators: Array<LeftOperators<T, any> | RightOperators<T, any>>
123
- ) => OperatorSet;
124
-
125
- /**
126
- * In math mode, the BigInt division and power operators can be overloaded by
127
- * using this function.
128
- */
129
- updateBigIntOperators(
130
- ops: Pick<OperatorFunctions<BigInt, BigInt>, "/" | "**">
131
- ): void;
132
- }
133
-
134
- declare var Operators: OperatorsConstructor;
135
-
136
- interface Number {
137
- [Symbol.operatorSet]: OperatorSet;
138
- }
139
-
140
- interface Boolean {
141
- [Symbol.operatorSet]: OperatorSet;
142
- }
143
-
144
- interface String {
145
- [Symbol.operatorSet]: OperatorSet;
146
- }
147
-
148
- interface BigInt {
149
- [Symbol.operatorSet]: OperatorSet;
150
- }
151
-
152
- interface BigIntConstructor {
153
- /**
154
- * Return trunc(a/b).
155
- *
156
- * b = 0 raises a RangeError exception.
157
- */
158
- tdiv(a: bigint, b: bigint): bigint;
159
-
160
- /**
161
- * Return \lfloor a/b \rfloor.
162
- *
163
- * b = 0 raises a RangeError exception.
164
- */
165
- fdiv(a: bigint, b: bigint): bigint;
166
-
167
- /**
168
- * Return \lceil a/b \rceil.
169
- *
170
- * b = 0 raises a RangeError exception.
171
- */
172
- cdiv(a: bigint, b: bigint): bigint;
173
-
174
- /**
175
- * Return sgn(b) \lfloor a/{|b|} \rfloor (Euclidian division).
176
- *
177
- * b = 0 raises a RangeError exception.
178
- */
179
- ediv(a: bigint, b: bigint): bigint;
180
-
181
- /**
182
- * Perform trunc(a/b) and return an array of two elements. The first element
183
- * is the quotient, the second is the remainder.
184
- *
185
- * b = 0 raises a RangeError exception.
186
- */
187
- tdivrem(a: bigint, b: bigint): [bigint, bigint];
188
-
189
- /**
190
- * Perform \lfloor a/b \rfloor and return an array of two elements. The first
191
- * element is the quotient, the second is the remainder.
192
- *
193
- * b = 0 raises a RangeError exception.
194
- */
195
- fdivrem(a: bigint, b: bigint): [bigint, bigint];
196
-
197
- /**
198
- * Perform \lceil a/b \rceil and return an array of two elements. The first
199
- * element is the quotient, the second is the remainder.
200
- *
201
- * b = 0 raises a RangeError exception.
202
- */
203
- cdivrem(a: bigint, b: bigint): [bigint, bigint];
204
-
205
- /**
206
- * Perform sgn(b) \lfloor a/{|b|} \rfloor (Euclidian division) and return an
207
- * array of two elements. The first element is the quotient, the second is
208
- * the remainder.
209
- *
210
- * b = 0 raises a RangeError exception.
211
- */
212
- edivrem(a: bigint, b: bigint): [bigint, bigint];
213
-
214
- /**
215
- * Return \lfloor \sqrt(a) \rfloor.
216
- *
217
- * A RangeError exception is raised if a < 0.
218
- */
219
- sqrt(a: bigint): bigint;
220
-
221
- /**
222
- * Return an array of two elements. The first element is
223
- * \lfloor \sqrt{a} \rfloor. The second element is
224
- * a-\lfloor \sqrt{a} \rfloor^2.
225
- *
226
- * A RangeError exception is raised if a < 0.
227
- */
228
- sqrtrem(a: bigint): [bigint, bigint];
229
-
230
- /**
231
- * Return -1 if a \leq 0 otherwise return \lfloor \log2(a) \rfloor.
232
- */
233
- floorLog2(a: bigint): bigint;
234
-
235
- /**
236
- * Return the number of trailing zeros in the two’s complement binary representation of a.
237
- *
238
- * Return -1 if a=0.
239
- */
240
- ctz(a: bigint): bigint;
241
- }
242
-
243
- declare type BigFloatRoundingMode = number & {
244
- /**
245
- * This property is not here at runtime; we just use it to make this type
246
- * differ from a normal number
247
- */
248
- __is__: "BigFloatRoundingMode";
249
- };
250
-
251
- interface BigFloatEnvConstructor {
252
- /**
253
- * Creates a new floating point environment. Its status flags are reset.
254
- *
255
- * - If unspecified, `precision` defaults to the precision from the global floating point environment.
256
- * - If unspecified, `roundingMode` defaults to RNDN.
257
- */
258
- new (precision?: number, roundingMode?: BigFloatRoundingMode): BigFloatEnv;
259
-
260
- /**
261
- * The mantissa precision in bits of the global floating point environment.
262
- *
263
- * The initial value is 113.
264
- */
265
- get prec(): number;
266
-
267
- /**
268
- * The exponent size in bits of the global floating point environment,
269
- * assuming an IEEE 754 representation.
270
- *
271
- * The initial value is 15.
272
- */
273
- get expBits(): number;
274
-
275
- /**
276
- * Sets the mantissa precision of the global floating point environment to
277
- * `prec` and the exponent size to `expBits`, then calls the function `func`.
278
- * Then the precision and exponent size are reset to their previous values
279
- * and the return value of `func` is returned (or an exception is raised if
280
- * `func` raised an exception).
281
- *
282
- * If expBits is undefined, it is set to {@link BigFloatEnv.expBitsMax}.
283
- *
284
- * @param func The function to call within the modified environment
285
- * @param prec The mantissa precision (in bits) to use in the modified environment
286
- * @param expBits The exponent size (in bits) to use in the modified environment. Defaults to {@link BigFloatEnv.expBitsMax}.
287
- */
288
- setPrec<Ret>(func: () => Ret, prec: number, expBits?: number): Ret;
289
-
290
- /**
291
- * Integer; the minimum allowed precision. Must be at least 2.
292
- */
293
- readonly precMin: number;
294
-
295
- /**
296
- * Integer; the maximum allowed precision. Must be at least 113.
297
- */
298
- readonly precMax: number;
299
-
300
- /**
301
- * Integer; the minimum allowed exponent size in bits. Must be at least 3.
302
- */
303
- readonly expBitsMin: number;
304
-
305
- /**
306
- * Integer; the maximum allowed exponent size in bits. Must be at least 15.
307
- */
308
- readonly expBitsMax: number;
309
-
310
- /**
311
- * Round to nearest, with ties to even rounding mode.
312
- */
313
- readonly RNDN: BigFloatRoundingMode;
314
-
315
- /**
316
- * Round to zero rounding mode.
317
- */
318
- readonly RNDZ: BigFloatRoundingMode;
319
-
320
- /**
321
- * Round to -Infinity rounding mode.
322
- */
323
- readonly RNDD: BigFloatRoundingMode;
324
-
325
- /**
326
- * Round to +Infinity rounding mode.
327
- */
328
- readonly RNDU: BigFloatRoundingMode;
329
-
330
- /**
331
- * Round to nearest, with ties away from zero rounding mode.
332
- */
333
- readonly RNDNA: BigFloatRoundingMode;
334
-
335
- /**
336
- * Round away from zero rounding mode.
337
- */
338
- readonly RNDA: BigFloatRoundingMode;
339
-
340
- /**
341
- * Faithful rounding mode. The result is non-deterministically rounded to
342
- * -Infinity or +Infinity.
343
- *
344
- * This rounding mode usually gives a faster and deterministic running time
345
- * for the floating point operations.
346
- */
347
- readonly RNDF: BigFloatRoundingMode;
348
-
349
- prototype: BigFloatEnv;
350
- }
351
-
352
- declare var BigFloatEnv: BigFloatEnvConstructor;
353
-
354
- /**
355
- * A BigFloatEnv contains:
356
- *
357
- * - the mantissa precision in bits
358
- * - the exponent size in bits assuming an IEEE 754 representation;
359
- * - the subnormal flag (if true, subnormal floating point numbers can be generated by the floating point operations).
360
- * - the rounding mode
361
- * - the floating point status. The status flags can only be set by the floating point operations. They can be reset with BigFloatEnv.prototype.clearStatus() or with the various status flag setters.
362
- */
363
- interface BigFloatEnv {
364
- /**
365
- * The mantissa precision, in bits.
366
- *
367
- * If precision was not specified as an argument to the BigFloatEnv
368
- * constructor, defaults to the precision value of the global floating-point
369
- * environment ({@link BigFloatEnv.prec}).
370
- */
371
- get prec(): number;
372
- set prec(newValue: number);
373
-
374
- /**
375
- * The exponent size in bits assuming an IEEE 754 representation.
376
- *
377
- * Defaults to the exponent size of the global floating-point environment
378
- * ({@link BigFloatEnv.expBits}).
379
- */
380
- get expBits(): number;
381
- set expBits(newValue: number);
382
-
383
- /**
384
- * The rounding mode.
385
- *
386
- * If the rounding mode was not specified as an argument to the BigFloatEnv
387
- * constructor, defaults to {@link BigFloatEnv.RNDN}.
388
- */
389
- get rndMode(): BigFloatRoundingMode;
390
- set rndMode(newMode: BigFloatRoundingMode);
391
-
392
- /** subnormal flag. It is false when expBits = expBitsMax. Defaults to false. */
393
- get subnormal(): boolean;
394
- set subnormal(newValue: boolean);
395
-
396
- /** Status flag; cleared by `clearStatus`. */
397
- get invalidOperation(): boolean;
398
- set invalidOperation(newValue: boolean);
399
-
400
- /** Status flag; cleared by `clearStatus`. */
401
- get divideByZero(): boolean;
402
- set divideByZero(newValue: boolean);
403
-
404
- /** Status flag; cleared by `clearStatus`. */
405
- get overflow(): boolean;
406
- set overflow(newValue: boolean);
407
-
408
- /** Status flag; cleared by `clearStatus`. */
409
- get underflow(): boolean;
410
- set underflow(newValue: boolean);
411
-
412
- /** Status flag; cleared by `clearStatus`. */
413
- get inexact(): boolean;
414
- set inexact(newValue: boolean);
415
-
416
- /**
417
- * Clear the status flags (invalidOperation, divideByZero, overflow,
418
- * underflow, and inexact).
419
- */
420
- clearStatus(): void;
421
- }
422
-
423
- interface BigFloatConstructor {
424
- /**
425
- * If `value` is a numeric type, it is converted to BigFloat without rounding.
426
- *
427
- * If `value`` is a string, it is converted to BigFloat using the precision of the global floating point environment ({@link BigFloatEnv.prec}).
428
- */
429
- (value: number | string | BigInt | BigFloat): BigFloat;
430
-
431
- prototype: BigFloat;
432
-
433
- /**
434
- * The value of {@link Math.LN2} rounded to nearest, ties to even with the
435
- * current global precision.
436
- *
437
- * The constant values are cached for small precisions.
438
- */
439
- get LN2(): BigFloat;
440
-
441
- /**
442
- * The value of {@link Math.PI} rounded to nearest, ties to even with
443
- * the current global precision.
444
- *
445
- * The constant values are cached for small precisions.
446
- */
447
- get PI(): BigFloat;
448
-
449
- /**
450
- * The value of {@link Number.MIN_VALUE} as a BigFloat.
451
- */
452
- get MIN_VALUE(): BigFloat;
453
-
454
- /**
455
- * The value of {@link Number.MAX_VALUE} as a BigFloat.
456
- */
457
- get MAX_VALUE(): BigFloat;
458
-
459
- /**
460
- * The value of {@link Number.EPSILON} as a BigFloat.
461
- */
462
- get EPSILON(): BigFloat;
463
-
464
- /**
465
- * Rounds the floating point number `a` according to the floating point
466
- * environment `e` or the global environment if `e` is undefined.
467
- */
468
- fpRound(a: BigFloat, e?: BigFloatEnv): BigFloat;
469
-
470
- /**
471
- * Parses the string `a` as a floating point number in radix `radix`.
472
- *
473
- * The radix is 0 (default) or from 2 to 36. The radix 0 means radix 10
474
- * unless there is a hexadecimal or binary prefix.
475
- *
476
- * The result is rounded according to the floating point environment `e` or
477
- * the global environment if `e` is undefined.
478
- */
479
- parseFloat(a: string, radix?: number, e?: BigFloatEnv): BigFloat;
480
-
481
- /**
482
- * Returns true if `a` is a finite bigfloat. Returns false otherwise.
483
- */
484
- isFinite(a: BigFloat): boolean;
485
-
486
- /**
487
- * Returns true if a is a NaN bigfloat. Returns false otherwise.
488
- */
489
- isNaN(a: BigFloat): boolean;
490
-
491
- /**
492
- * Adds `a` and `b` together and rounds the resulting floating point number
493
- * according to the floating point environment `e`, or the global environment
494
- * if e is undefined.
495
- *
496
- * If `e` is specified, the floating point status flags on `e` are updated.
497
- */
498
- add(a: BigFloat, b: BigFloat, e?: BigFloatEnv): BigFloat;
499
-
500
- /**
501
- * Subtracts `b` from `a` and rounds the resulting floating point number
502
- * according to the floating point environment `e`, or the global environment
503
- * if e is undefined.
504
- *
505
- * If `e` is specified, the floating point status flags on `e` are updated.
506
- */
507
- sub(a: BigFloat, b: BigFloat, e?: BigFloatEnv): BigFloat;
508
-
509
- /**
510
- * Multiplies `a` and `b` together and rounds the resulting floating point
511
- * number according to the floating point environment `e`, or the global
512
- * environment if e is undefined.
513
- *
514
- * If `e` is specified, the floating point status flags on `e` are updated.
515
- */
516
- mul(a: BigFloat, b: BigFloat, e?: BigFloatEnv): BigFloat;
517
-
518
- /**
519
- * Divides `a` by `b` and rounds the resulting floating point number
520
- * according to the floating point environment `e`, or the global environment
521
- * if e is undefined.
522
- *
523
- * If `e` is specified, the floating point status flags on `e` are updated.
524
- */
525
- div(a: BigFloat, b: BigFloat, e?: BigFloatEnv): BigFloat;
526
-
527
- /**
528
- * Rounds `x` down to the nearest integer.
529
- *
530
- * No additional rounding (ie. BigFloatEnv-related rounding) is performed.
531
- */
532
- floor(x: BigFloat): BigFloat;
533
-
534
- /**
535
- * Rounds `x` up to the nearest integer.
536
- *
537
- * No additional rounding (ie. BigFloatEnv-related rounding) is performed.
538
- */
539
- ceil(x: BigFloat): BigFloat;
540
-
541
- /**
542
- * Rounds `x` to the nearest integer.
543
- *
544
- * No additional rounding (ie. BigFloatEnv-related rounding) is performed.
545
- */
546
- round(x: BigFloat): BigFloat;
547
-
548
- /**
549
- * Truncates the fractional part of `x`, resulting in an integer.
550
- *
551
- * No additional rounding (ie. BigFloatEnv-related rounding) is performed.
552
- */
553
- trunc(x: BigFloat): BigFloat;
554
-
555
- /**
556
- * Returns the absolute value of `x`.
557
- *
558
- * No additional rounding (ie. BigFloatEnv-related rounding) is performed.
559
- */
560
- abs(x: BigFloat): BigFloat;
561
-
562
- /**
563
- * Floating point remainder. The quotient is truncated to zero.
564
- *
565
- * `e` is an optional floating point environment.
566
- */
567
- fmod(x: BigFloat, y: BigFloat, e?: BigFloatEnv): BigFloat;
568
-
569
- /**
570
- * Floating point remainder. The quotient is rounded to the nearest integer
571
- * with ties to even.
572
- *
573
- * `e` is an optional floating point environment.
574
- */
575
- remainder(x: BigFloat, y: BigFloat, e?: BigFloatEnv): BigFloat;
576
-
577
- /**
578
- * Square root. Returns a rounded floating point number.
579
- *
580
- * e is an optional floating point environment.
581
- */
582
- sqrt(x: BigFloat, e?: BigFloatEnv): BigFloat;
583
-
584
- /**
585
- * Returns a rounded floating point number.
586
- *
587
- * `e` is an optional floating point environment.
588
- */
589
- sin(x: BigFloat, e?: BigFloatEnv): BigFloat;
590
-
591
- /**
592
- * Returns a rounded floating point number.
593
- *
594
- * `e` is an optional floating point environment.
595
- */
596
- cos(x: BigFloat, e?: BigFloatEnv): BigFloat;
597
-
598
- /**
599
- * Returns a rounded floating point number.
600
- *
601
- * `e` is an optional floating point environment.
602
- */
603
- tan(x: BigFloat, e?: BigFloatEnv): BigFloat;
604
-
605
- /**
606
- * Returns a rounded floating point number.
607
- *
608
- * `e` is an optional floating point environment.
609
- */
610
- asin(x: BigFloat, e?: BigFloatEnv): BigFloat;
611
-
612
- /**
613
- * Returns a rounded floating point number.
614
- *
615
- * `e` is an optional floating point environment.
616
- */
617
- acos(x: BigFloat, e?: BigFloatEnv): BigFloat;
618
-
619
- /**
620
- * Returns a rounded floating point number.
621
- *
622
- * `e` is an optional floating point environment.
623
- */
624
- atan(x: BigFloat, e?: BigFloatEnv): BigFloat;
625
-
626
- /**
627
- * Returns a rounded floating point number.
628
- *
629
- * `e` is an optional floating point environment.
630
- */
631
- atan2(x: BigFloat, y: BigFloat, e?: BigFloatEnv): BigFloat;
632
-
633
- /**
634
- * Returns a rounded floating point number.
635
- *
636
- * `e` is an optional floating point environment.
637
- */
638
- exp(x: BigFloat, e?: BigFloatEnv): BigFloat;
639
-
640
- /**
641
- * Returns a rounded floating point number.
642
- *
643
- * `e` is an optional floating point environment.
644
- */
645
- log(x: BigFloat, e?: BigFloatEnv): BigFloat;
646
-
647
- /**
648
- * Returns a rounded floating point number.
649
- *
650
- * `e` is an optional floating point environment.
651
- */
652
- pow(x: BigFloat, y: BigFloat, e?: BigFloatEnv): BigFloat;
653
- }
654
-
655
- declare var BigFloat: BigFloatConstructor;
656
-
657
- /**
658
- * The BigFloat type represents floating point numbers in base 2 with the IEEE 754 semantics.
659
- *
660
- * A floating point number is represented as a sign, mantissa and exponent.
661
- *
662
- * The special values NaN, +/-Infinity, +0 and -0 are supported.
663
- *
664
- * The mantissa and exponent can have any bit length with an implementation specific minimum and maximum.
665
- */
666
- interface BigFloat {
667
- valueOf(): BigFloat;
668
-
669
- /** radix must be between 2 and 36 */
670
- toString(radix?: number): string;
671
-
672
- /**
673
- * Returns a string containing a number represented either in exponential or
674
- * fixed-point notation with a specified number of digits.
675
- *
676
- * @param precision Number of significant digits. There is no range limit on this number.
677
- * @param roundingMode The rounding mode to use when representing the value. Defaults to {@link BigFloatEnv.RNDNA}.
678
- * @param radix The base to use when representing the value. Must be an integer between 2 and 36. Defaults to 10.
679
- */
680
- toPrecision(
681
- precision: number,
682
- roundingMode?: BigFloatRoundingMode,
683
- radix?: number
684
- ): string;
685
-
686
- /**
687
- * Returns a string representing a number in fixed-point notation.
688
- *
689
- * @param fractionDigits Number of digits after the decimal point. There is no range limit on this number.
690
- * @param roundingMode The rounding mode to use when representing the value. Defaults to {@link BigFloatEnv.RNDNA}.
691
- * @param radix The base to use when representing the value. Must be an integer between 2 and 36. Defaults to 10.
692
- */
693
- toFixed(
694
- fractionDigits: number,
695
- roundingMode?: BigFloatRoundingMode,
696
- radix?: number
697
- ): string;
698
-
699
- /**
700
- * Returns a string containing a number represented in exponential notation.
701
- *
702
- * @param fractionDigits Number of digits after the decimal point. Must be in the range 0 - 20, inclusive.
703
- * @param roundingMode The rounding mode to use when representing the value. Defaults to {@link BigFloatEnv.RNDNA}.
704
- * @param radix The base to use when representing the value. Must be an integer between 2 and 36. Defaults to 10.
705
- */
706
- toExponential(
707
- fractionDigits: number,
708
- roundingMode?: BigFloatRoundingMode,
709
- radix?: number
710
- ): string;
711
-
712
- [Symbol.typeofValue]: () => "bigfloat";
713
- }
714
-
715
- declare type BigDecimalRoundingMode =
716
- | "floor"
717
- | "ceiling"
718
- | "down"
719
- | "up"
720
- | "half-even"
721
- | "half-up";
722
-
723
- declare type BigDecimalRoundingObject =
724
- | {
725
- /** must be >= 1 */
726
- maximumSignificantDigits: number;
727
- roundingMode: BigDecimalRoundingMode;
728
- }
729
- | {
730
- /** must be >= 0 */
731
- maximumFractionDigits: number;
732
- roundingMode: BigDecimalRoundingMode;
733
- };
734
-
735
- interface BigDecimalConstructor {
736
- (): BigDecimal;
737
- (value: number | string | BigInt | BigFloat): BigDecimal;
738
-
739
- /**
740
- * Adds together `a` and `b` and rounds the result according to the rounding
741
- * object `e`. If the rounding object is not present, the operation is
742
- * executed with infinite precision; in other words, no rounding occurs when
743
- * the rounding object is not present.
744
- */
745
- add(a: BigDecimal, b: BigDecimal, e?: BigDecimalRoundingObject): BigDecimal;
746
-
747
- /**
748
- * Subtracts `b` from `a` and rounds the result according to the rounding
749
- * object `e`. If the rounding object is not present, the operation is
750
- * executed with infinite precision; in other words, no rounding occurs when
751
- * the rounding object is not present.
752
- */
753
- sub(a: BigDecimal, b: BigDecimal, e?: BigDecimalRoundingObject): BigDecimal;
754
-
755
- /**
756
- * Multiplies together `a` and `b` and rounds the result according to the
757
- * rounding object `e`. If the rounding object is not present, the operation
758
- * is executed with infinite precision; in other words, no rounding occurs
759
- * when the rounding object is not present.
760
- */
761
- mul(a: BigDecimal, b: BigDecimal, e?: BigDecimalRoundingObject): BigDecimal;
762
-
763
- /**
764
- * Divides `a` by `b` and rounds the result according to the rounding object
765
- * `e`.
766
- *
767
- * If the rounding object is not present, an attempt is made to perform the
768
- * operation with infinite precision. However, not all quotients can be
769
- * represented with infinite precision. If the quotient cannot be represented
770
- * with infinite precision, a RangeError is thrown.
771
- *
772
- * A RangeError is thrown when dividing by zero.
773
- */
774
- div(a: BigDecimal, b: BigDecimal, e?: BigDecimalRoundingObject): BigDecimal;
775
-
776
- /**
777
- * Perform the modulo operation of `a` by `b` and round the result according
778
- * to the rounding object `e`. If the rounding object is not present, the
779
- * operation is executed with infinite precision; in other words, no rounding
780
- * occurs when the rounding object is not present.
781
- */
782
- mod(a: BigDecimal, b: BigDecimal, e?: BigDecimalRoundingObject): BigDecimal;
783
-
784
- /**
785
- * Obtain the square root of `a`, rounding the result according to the
786
- * rounding object `e`.
787
- *
788
- * If `a` is less than zero, a RangeError will be thrown.
789
- *
790
- * Note that the rounding object is *required*.
791
- */
792
- sqrt(a: BigDecimal, e: BigDecimalRoundingObject): BigDecimal;
793
-
794
- /**
795
- * Rounds `a` using the rounding object `e`.
796
- */
797
- round(a: BigDecimal, e: BigDecimalRoundingObject): BigDecimal;
798
-
799
- prototype: BigDecimal;
800
- }
801
-
802
- declare var BigDecimal: BigDecimalConstructor;
803
-
804
- /**
805
- * The BigDecimal type represents floating point numbers in base 10.
806
- *
807
- * It is inspired from the proposal available at https://github.com/littledan/proposal-bigdecimal.
808
- *
809
- * The BigDecimal floating point numbers are always normalized and finite.
810
- * There is no concept of -0, Infinity or NaN. By default, all the computations
811
- * are done with infinite precision.
812
- */
813
- interface BigDecimal {
814
- /**
815
- * Returns the bigdecimal primitive value corresponding to this BigDecimal.
816
- */
817
- valueOf(): BigDecimal;
818
-
819
- /**
820
- * Converts this BigDecimal to a string with infinite precision in base 10.
821
- */
822
- toString(): string;
823
-
824
- /**
825
- * Returns a string containing a number represented either in exponential or
826
- * fixed-point notation with a specified number of digits.
827
- *
828
- * @param precision Number of significant digits. There is no range limit on this number.
829
- * @param roundingMode The rounding mode to use when representing the value. Defaults to "half-up".
830
- */
831
- toPrecision(precision: number, roundingMode?: BigDecimalRoundingMode): string;
832
-
833
- /**
834
- * Returns a string representing a number in fixed-point notation.
835
- *
836
- * @param fractionDigits Number of digits after the decimal point. There is no range limit on this number.
837
- * @param roundingMode The rounding mode to use when representing the value. Defaults to "half-up".
838
- */
839
- toFixed(
840
- fractionDigits: number,
841
- roundingMode?: BigDecimalRoundingMode
842
- ): string;
843
-
844
- /**
845
- * Returns a string containing a number represented in exponential notation.
846
- *
847
- * @param fractionDigits Number of digits after the decimal point. Must be in the range 0 - 20, inclusive.
848
- * @param roundingMode The rounding mode to use when representing the value. Defaults to "half-up".
849
- */
850
- toExponential(
851
- fractionDigits: number,
852
- roundingMode?: BigDecimalRoundingMode
853
- ): string;
854
- }
855
-
856
- // Note that BigFloat and BigDecimal have custom operator overloads defined in
857
- // QuickJS, but TypeScript does not support operator overloading. As such,
858
- // TypeScript will not understand or handle unary/binary operators for BigFloat
859
- // and BigDecimal properly.