fix: #3232 fix type definitions of function format to support notations hex, bin, and oct

This commit is contained in:
Jos de Jong 2024-07-11 13:12:27 +02:00
parent b6b76cd11e
commit c118eaec90
3 changed files with 16 additions and 1 deletions

View File

@ -1,5 +1,10 @@
# History
# unpublished changes since 13.0.2
- Fix: #3232 fix type definitions of function `format` to support notations
`hex`, `bin`, and `oct`.
# 2024-07-04, 13.0.2
- Fix an error in the type definitions of `quantileSeq` (#3223).

View File

@ -2168,6 +2168,9 @@ Factory Test
const d = divide(a, b)
assert.strictEqual(format(c), '16/21')
assert.strictEqual(format(d), '7/9')
assert.strictEqual(format(255, { notation: 'bin' }), '0b11111111')
assert.strictEqual(format(255, { notation: 'hex' }), '0xff')
assert.strictEqual(format(255, { notation: 'oct' }), '0o377')
}
/**

9
types/index.d.ts vendored
View File

@ -4352,7 +4352,14 @@ export interface FormatOptions {
* elsewhere. Lower bound is included, upper bound is excluded. For
* example '123.4' and '1.4e7'.
*/
notation?: 'fixed' | 'exponential' | 'engineering' | 'auto'
notation?:
| 'fixed'
| 'exponential'
| 'engineering'
| 'auto'
| 'hex'
| 'bin'
| 'oct'
/**
* A number between 0 and 16 to round the digits of the number. In case