Skip to content

Commit

Permalink
Fix bun-types/lib:dom issue
Browse files Browse the repository at this point in the history
  • Loading branch information
jakeboone02 committed Jul 27, 2023
1 parent c4e1104 commit 248abbe
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 12 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
# numeric-quantity

[![npm][badge-npm]](https://www.npmjs.com/package/numeric-quantity)
![workflow status](https://github.com/jakeboone02/numeric-quantity/actions/workflows/main.yml/badge.svg)
[![codecov.io](https://codecov.io/github/jakeboone02/numeric-quantity/coverage.svg?branch=main)](https://codecov.io/github/jakeboone02/numeric-quantity?branch=main)
[![downloads](https://img.shields.io/npm/dm/numeric-quantity.svg)](http://npm-stat.com/charts.html?package=numeric-quantity&from=2015-08-01)
[![MIT License](https://img.shields.io/npm/l/numeric-quantity.svg)](http://opensource.org/licenses/MIT)

Converts a string to a number, like an enhanced version of `parseFloat`. The return value will be `NaN` if the provided string does not resemble a number.
Converts a string to a number, like an enhanced version of `parseFloat`.

Features:

- In addition to plain integers and decimals, `numeric-quantity` can parse numbers with comma or underscore separators (`'1,000'` or `'1_000'`), mixed numbers (`'1 2/3'`), vulgar fractions (`'1⅖'`), and the fraction slash character (`'1 2⁄3'`).
- To allow and ignore trailing invalid characters _à la_ `parseFloat`, pass `{ allowTrailingInvalid: true }` as the second argument.
- To parse Roman numerals like `'MCCXIV'` or `'Ⅻ'`, pass `{ romanNumerals: true }` as the second argument or call `parseRomanNumerals` directly.
- Results will be rounded to three decimal places by default. To avoid rounding, pass `{ round: false }` as the second argument. To round to a different number of decimal places, assign that number to the `round` option (`{ round: 5 }` will round to five decimal places).
- Returns `NaN` if the provided string does not resemble a number.

> _For the inverse operation—converting a number to an imperial measurement—check out [format-quantity](https://www.npmjs.com/package/format-quantity)._
>
Expand Down
Binary file modified bun.lockb
Binary file not shown.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"devDependencies": {
"@types/jest": "^29.5.3",
"@types/node": "^20.4.5",
"@types/web": "^0.0.111",
"bun-types": "^0.7.0",
"gh-pages": "^5.0.0",
"jest": "^29.6.1",
Expand Down
8 changes: 0 additions & 8 deletions src/dev.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
import { numericQuantity } from './index';
import { numericQuantityTests } from './numericQuantityTests';

// TODO: When bun-types is included, TS can't find the DOM lib
// even though it's included in ../tsconfig.json.
type HTMLDivElement = any;
declare const document: {
querySelector: <T>(...args: any[]) => any;
[k: string]: any;
};

const app = document.querySelector<HTMLDivElement>('#app')!;

(globalThis as any).numericQuantity = numericQuantity;
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"compilerOptions": {
"types": ["bun-types", "jest"],
"types": ["bun-types", "jest", "web"],
"isolatedModules": true,
"declaration": true,
"sourceMap": true,
Expand Down

0 comments on commit 248abbe

Please sign in to comment.