Skip to content

Commit a7fc7b1

Browse files
committed
Move docs NPM structure to toplevel
Also, make sure docs align with polyfill. Also, remove node_modules.
1 parent fb37598 commit a7fc7b1

File tree

811 files changed

+178
-51552
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

811 files changed

+178
-51552
lines changed

docs/buildDocs.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,8 @@ async function build() {
175175
await mkdirp(outputDir);
176176

177177
// Read header and footer templates
178-
const head = await fs.readFile('head.html.part', { encoding });
179-
const tail = await fs.readFile('tail.html.part', { encoding });
178+
const head = await fs.readFile(path.join(__dirname, 'head.html.part'), { encoding });
179+
const tail = await fs.readFile(path.join(__dirname, 'tail.html.part'), { encoding });
180180

181181
// Get all markdown files
182182
const files = await fs.readdir(__dirname);
@@ -188,14 +188,14 @@ async function build() {
188188
}
189189

190190
// Copy prism.css - using okaidia theme for vibrant syntax highlighting
191-
const prismCss = path.join(__dirname, 'node_modules/prismjs/themes/prism-okaidia.css');
191+
const prismCss = path.join(__dirname, '..', 'node_modules/prismjs/themes/prism-okaidia.css');
192192
const prismDest = path.join(outputDir, 'prism.css');
193193
await fs.copyFile(prismCss, prismDest);
194194
console.log(` → ${prismDest}`);
195195

196196
// Build and copy proposal-decimal polyfill as browser bundle
197197
const { execSync } = require('child_process');
198-
const polyfillSrc = path.join(__dirname, 'node_modules/proposal-decimal/src/Decimal.mjs');
198+
const polyfillSrc = path.join(__dirname, '..', 'node_modules/proposal-decimal/src/Decimal.mjs');
199199
const polyfillDest = path.join(outputDir, 'decimal-polyfill.js');
200200

201201
// Build IIFE bundle that exposes DecimalPolyfill globally
@@ -205,6 +205,11 @@ async function build() {
205205
});
206206
console.log(` → ${polyfillDest}`);
207207

208+
// Also copy the original ES module
209+
const polyfillMjsDest = path.join(outputDir, 'decimal-polyfill.mjs');
210+
await fs.copyFile(polyfillSrc, polyfillMjsDest);
211+
console.log(` → ${polyfillMjsDest}`);
212+
208213
console.log('\nBuild complete!');
209214
} catch (error) {
210215
console.error('Build failed:', error);

docs/decimal.md

Lines changed: 29 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,6 @@ d5 = new Decimal(0.1); // Actually Decimal("0.1000000000000000055511151231257827
4444
d6 = new Decimal(123n);
4545
```
4646

47-
## Static Methods
48-
49-
### Decimal.**from**(_value_: string | number | bigint | Decimal) : Decimal
50-
51-
Converts a value to a `Decimal`. Unlike the constructor, this method also accepts existing `Decimal` objects (returning them unchanged).
52-
53-
```js
54-
Decimal.from("123.45"); // => Decimal("123.45")
55-
Decimal.from(123.45); // => Decimal("123.45")
56-
Decimal.from(123n); // => Decimal("123")
57-
Decimal.from(existingDecimal); // => existingDecimal (same object)
58-
```
59-
6047
## Special Values
6148

6249
### NaN (Not a Number)
@@ -87,43 +74,43 @@ posInf.add(new Decimal("1")).toString(); // => "Infinity"
8774
new Decimal("1").divide(new Decimal("0")).toString(); // => "Infinity"
8875
```
8976

90-
## Properties
77+
## Methods
9178

92-
### **magnitude** : bigint
79+
### **significand()** : bigint
9380

9481
Returns the significand (mantissa) of the decimal number as a bigint, without regard to the exponent.
9582

9683
```js
97-
new Decimal("123.45").magnitude; // => 12345n
98-
new Decimal("0.00123").magnitude; // => 123n
84+
new Decimal("123.45").significand(); // => 12345n
85+
new Decimal("0.00123").significand(); // => 123n
9986
```
10087

101-
### **exponent** : number
88+
### **exponent()** : number
10289

10390
Returns the base-10 exponent of the decimal number.
10491

10592
```js
106-
new Decimal("123.45").exponent; // => -2 (representing 12345 × 10^-2)
107-
new Decimal("1.23e5").exponent; // => 3 (representing 123 × 10^3)
93+
new Decimal("123.45").exponent(); // => -2 (representing 12345 × 10^-2)
94+
new Decimal("1.23e5").exponent(); // => 3 (representing 123 × 10^3)
10895
```
10996

110-
### **isNaN** : boolean
97+
### **isNaN()** : boolean
11198

11299
Returns true if the value is NaN (Not a Number).
113100

114101
```js
115-
new Decimal("NaN").isNaN; // => true
116-
new Decimal("123").isNaN; // => false
102+
new Decimal("NaN").isNaN(); // => true
103+
new Decimal("123").isNaN(); // => false
117104
```
118105

119-
### **isFinite** : boolean
106+
### **isFinite()** : boolean
120107

121108
Returns true if the value is finite (not NaN or infinity).
122109

123110
```js
124-
new Decimal("123").isFinite; // => true
125-
new Decimal("Infinity").isFinite; // => false
126-
new Decimal("NaN").isFinite; // => false
111+
new Decimal("123").isFinite(); // => true
112+
new Decimal("Infinity").isFinite(); // => false
113+
new Decimal("NaN").isFinite(); // => false
127114
```
128115

129116
## Arithmetic Methods
@@ -215,7 +202,7 @@ Rounds to a given number of decimal places.
215202
**Parameters:**
216203

217204
- `scale` (number): Number of decimal places to round to (default: 0)
218-
- `options.roundingMode` (string): One of "ceil", "floor", "trunc", "halfEven" (default), or "halfAwayFromZero"
205+
- `options.roundingMode` (string): One of "ceil", "floor", "trunc", "halfEven" (default), or "halfExpand"
219206

220207
```js
221208
const d = new Decimal("123.456");
@@ -286,35 +273,35 @@ new Decimal("123.45").toString(); // => "123.45"
286273
new Decimal("1.23e5").toString(); // => "123000"
287274
```
288275

289-
### **toFixed**(_digits_: number) : string
276+
### **toFixed**({_digits_: number}) : string
290277

291278
Returns a string with a fixed number of decimal places.
292279

293280
```js
294281
const d = new Decimal("123.456");
295-
d.toFixed(0); // => "123"
296-
d.toFixed(2); // => "123.46"
297-
d.toFixed(5); // => "123.45600"
282+
d.toFixed({ digits: 0 }); // => "123"
283+
d.toFixed({ digits: 2 }); // => "123.46"
284+
d.toFixed({ digits: 5 }); // => "123.45600"
298285
```
299286

300-
### **toExponential**(_fractionDigits_?: number) : string
287+
### **toExponential**({_digits_: number}?) : string
301288

302289
Returns a string in exponential notation.
303290

304291
```js
305292
const d = new Decimal("123.456");
306293
d.toExponential(); // => "1.23456e+2"
307-
d.toExponential(2); // => "1.23e+2"
294+
d.toExponential({ digits: 2 }); // => "1.23e+2"
308295
```
309296

310-
### **toPrecision**(_precision_: number) : string
297+
### **toPrecision**({ _digits_: number}) : string
311298

312299
Returns a string with the specified number of significant digits.
313300

314301
```js
315302
const d = new Decimal("123.456");
316-
d.toPrecision(2); // => "1.2e+2"
317-
d.toPrecision(5); // => "123.46"
303+
d.toPrecision({ digits: 2 }); // => "1.2e+2"
304+
d.toPrecision({ digits: 5 }); // => "123.46"
318305
```
319306

320307
### **toNumber**() : number
@@ -328,17 +315,14 @@ new Decimal("123.456789012345678901234567890123").toNumber(); // => 123.45678901
328315

329316
### **toBigInt**() : bigint
330317

331-
Converts to a BigInt, truncating any fractional part.
318+
Converts to a BigInt, throwing if the number isn't actually an integer:
332319

333320
```js
334-
new Decimal("123.45").toBigInt(); // => 123n
335-
new Decimal("123.99").toBigInt(); // => 123n
321+
new Decimal("123").toBigInt(); // => 123n
322+
new Decimal("123.99").toBigInt(); // throws
336323
```
337324

338-
### **valueOf**() : string
325+
### **valueOf**()
339326

340-
Returns the string representation. This method is called by JavaScript when a primitive value is needed.
341-
342-
```js
343-
new Decimal("123.45").valueOf(); // => "123.45"
327+
This method always throws, since there is currently no primitive that would exactly match the numeric representation of a Decimal.
344328
```

docs/node_modules/.bin/marked

Lines changed: 0 additions & 1 deletion
This file was deleted.

docs/node_modules/.bin/mkdirp

Lines changed: 0 additions & 1 deletion
This file was deleted.

docs/node_modules/.package-lock.json

Lines changed: 0 additions & 69 deletions
This file was deleted.

docs/node_modules/marked/LICENSE.md

Lines changed: 0 additions & 44 deletions
This file was deleted.

0 commit comments

Comments
 (0)