Skip to content

Commit

Permalink
Merge pull request #28 from jakeboone02/typedoc-docs
Browse files Browse the repository at this point in the history
Typedoc docs
  • Loading branch information
jakeboone02 committed Jul 27, 2023
2 parents 577eab5 + 5453479 commit 716d469
Show file tree
Hide file tree
Showing 35 changed files with 2,927 additions and 64 deletions.
5 changes: 2 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{
"editor.formatOnSave": true,
"prettier.prettierPath": "./node_modules/prettier"
}
"editor.formatOnSave": true
}
27 changes: 4 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
# 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`.

**[Full documentation](https://jakeboone02.github.io/numeric-quantity/)**

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 Expand Up @@ -51,24 +52,4 @@ As UMD (all exports are properties of the global object `NumericQuantity`):
</script>
```

## Other exports

| Name | Type | Description |
| --------------------------------- | ----------- | ---------------------------------------------------------------------------------------------------- |
| `numericRegex` | `RegExp` | Regular expression matching a string that resembles a number (using Arabic numerals) in its entirety |
| `numericRegexWithTrailingInvalid` | `RegExp` | Same as `numericRegex`, but allows/ignores trailing invalid characters. |
| `VulgarFraction` | `type` | Union type of all unicode vulgar fraction code points |
| `vulgarFractionsRegex` | `RegExp` | Regular expression matching the first unicode vulgar fraction code point |
| `vulgarFractionToAsciiMap` | `object` | Mapping of each vulgar fraction to its traditional ASCII representation (e.g., `'½'` to `'1/2'`) |
| `parseRomanNumerals` | `function` | Same function signature as `numericQuantity`, but only for Roman numerals (used internally) |
| `romanNumeralRegex` | `RegExp` | Regular expression matching valid Roman numeral sequences (uses modern, strict rules) |
| `romanNumeralUnicodeRegex` | `RegExp` | Regular expression matching any unicode Roman numeral code point |
| `romanNumeralUnicodeToAsciiMap` | `object` | Mapping of each Roman numeral to its traditional ASCII representation (e.g., `'Ⅻ'` to `'XII'`) |
| `romanNumeralValues` | `object` | Mapping of each valid Roman numeral sequence fragment to its numeric value |
| `NumericQuantityOptions` | `interface` | Shape of the (optional) second argument to `numericQuantity` |
| `RomanNumeralAscii` | `type` | Union type of allowable Roman numeral characters (uppercase only) |
| `RomanNumeralUnicode` | `type` | Union type of all Unicode Roman numeral characters (representing 1-12, 50, 100, 500, and 1000) |
| `RomanNumeral` | `type` | Union type of `RomanNumeralAscii` and `RomanNumeralUnicode` |
| `defaultOptions` | `object` | Object representing the default options |

[badge-npm]: https://img.shields.io/npm/v/numeric-quantity.svg?cacheSeconds=3600&logo=npm
6 changes: 0 additions & 6 deletions _config.yml

This file was deleted.

Binary file modified bun.lockb
Binary file not shown.
1 change: 1 addition & 0 deletions docs/.nojekyll
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TypeDoc added this file to prevent GitHub Pages from using Jekyll. You can turn off this behavior by setting the `githubPages` option to false.
120 changes: 120 additions & 0 deletions docs/assets/highlight.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
:root {
--light-hl-0: #AF00DB;
--dark-hl-0: #C586C0;
--light-hl-1: #000000;
--dark-hl-1: #D4D4D4;
--light-hl-2: #001080;
--dark-hl-2: #9CDCFE;
--light-hl-3: #A31515;
--dark-hl-3: #CE9178;
--light-hl-4: #795E26;
--dark-hl-4: #DCDCAA;
--light-hl-5: #008000;
--dark-hl-5: #6A9955;
--light-hl-6: #800000;
--dark-hl-6: #808080;
--light-hl-7: #800000;
--dark-hl-7: #569CD6;
--light-hl-8: #000000FF;
--dark-hl-8: #D4D4D4;
--light-hl-9: #E50000;
--dark-hl-9: #9CDCFE;
--light-hl-10: #0000FF;
--dark-hl-10: #CE9178;
--light-hl-11: #0000FF;
--dark-hl-11: #569CD6;
--light-hl-12: #098658;
--dark-hl-12: #B5CEA8;
--light-hl-13: #0070C1;
--dark-hl-13: #4FC1FF;
--light-code-background: #FFFFFF;
--dark-code-background: #1E1E1E;
}

@media (prefers-color-scheme: light) { :root {
--hl-0: var(--light-hl-0);
--hl-1: var(--light-hl-1);
--hl-2: var(--light-hl-2);
--hl-3: var(--light-hl-3);
--hl-4: var(--light-hl-4);
--hl-5: var(--light-hl-5);
--hl-6: var(--light-hl-6);
--hl-7: var(--light-hl-7);
--hl-8: var(--light-hl-8);
--hl-9: var(--light-hl-9);
--hl-10: var(--light-hl-10);
--hl-11: var(--light-hl-11);
--hl-12: var(--light-hl-12);
--hl-13: var(--light-hl-13);
--code-background: var(--light-code-background);
} }

@media (prefers-color-scheme: dark) { :root {
--hl-0: var(--dark-hl-0);
--hl-1: var(--dark-hl-1);
--hl-2: var(--dark-hl-2);
--hl-3: var(--dark-hl-3);
--hl-4: var(--dark-hl-4);
--hl-5: var(--dark-hl-5);
--hl-6: var(--dark-hl-6);
--hl-7: var(--dark-hl-7);
--hl-8: var(--dark-hl-8);
--hl-9: var(--dark-hl-9);
--hl-10: var(--dark-hl-10);
--hl-11: var(--dark-hl-11);
--hl-12: var(--dark-hl-12);
--hl-13: var(--dark-hl-13);
--code-background: var(--dark-code-background);
} }

:root[data-theme='light'] {
--hl-0: var(--light-hl-0);
--hl-1: var(--light-hl-1);
--hl-2: var(--light-hl-2);
--hl-3: var(--light-hl-3);
--hl-4: var(--light-hl-4);
--hl-5: var(--light-hl-5);
--hl-6: var(--light-hl-6);
--hl-7: var(--light-hl-7);
--hl-8: var(--light-hl-8);
--hl-9: var(--light-hl-9);
--hl-10: var(--light-hl-10);
--hl-11: var(--light-hl-11);
--hl-12: var(--light-hl-12);
--hl-13: var(--light-hl-13);
--code-background: var(--light-code-background);
}

:root[data-theme='dark'] {
--hl-0: var(--dark-hl-0);
--hl-1: var(--dark-hl-1);
--hl-2: var(--dark-hl-2);
--hl-3: var(--dark-hl-3);
--hl-4: var(--dark-hl-4);
--hl-5: var(--dark-hl-5);
--hl-6: var(--dark-hl-6);
--hl-7: var(--dark-hl-7);
--hl-8: var(--dark-hl-8);
--hl-9: var(--dark-hl-9);
--hl-10: var(--dark-hl-10);
--hl-11: var(--dark-hl-11);
--hl-12: var(--dark-hl-12);
--hl-13: var(--dark-hl-13);
--code-background: var(--dark-code-background);
}

.hl-0 { color: var(--hl-0); }
.hl-1 { color: var(--hl-1); }
.hl-2 { color: var(--hl-2); }
.hl-3 { color: var(--hl-3); }
.hl-4 { color: var(--hl-4); }
.hl-5 { color: var(--hl-5); }
.hl-6 { color: var(--hl-6); }
.hl-7 { color: var(--hl-7); }
.hl-8 { color: var(--hl-8); }
.hl-9 { color: var(--hl-9); }
.hl-10 { color: var(--hl-10); }
.hl-11 { color: var(--hl-11); }
.hl-12 { color: var(--hl-12); }
.hl-13 { color: var(--hl-13); }
pre, code { background: var(--code-background); }
58 changes: 58 additions & 0 deletions docs/assets/main.js

Large diffs are not rendered by default.

Loading

0 comments on commit 716d469

Please sign in to comment.