Skip to content

Commit

Permalink
Bump version and rebuild
Browse files Browse the repository at this point in the history
  • Loading branch information
borgar committed Jul 4, 2024
1 parent 5993f4e commit 17a07e5
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 22 deletions.
32 changes: 17 additions & 15 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,21 +134,23 @@ Formats a value as a string and returns the result.
##### Parameters
| Name | Type | Default | Description |
| ------------------------- | --------- | ---------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| pattern | `string` | | A format pattern in the ECMA-376 number format. |
| value | `any` | | The value to format. |
| [options] | `object` | `{}` | Options |
| [options].dateErrorNumber | `boolean` | `true` | Should the formatter switch to a General number format when trying to format a date that is out of bounds? |
| [options].dateErrorThrows | `boolean` | `false` | Should the formatter throw an error when trying to format a date that is out of bounds? |
| [options].dateSpanLarge | `boolean` | `true` | Extends the allowed range of dates from Excel bounds (1900–9999) to Google Sheet bounds (0–99999). |
| [options].ignoreTimezone | `boolean` | `false` | Normally when date objects are used with the formatter, time zone is taken into account. This makes the formatter ignore the timezone offset. |
| [options].invalid | `string` | `"######"` | The string emitted when no-throw mode fails to parse a pattern. |
| [options].leap1900 | `boolean` | `true` | Simulate the Lotus 1-2-3 [1900 leap year bug](https://docs.microsoft.com/en-us/office/troubleshoot/excel/wrongly-assumes-1900-is-leap-year). It is a requirement in the Ecma OOXML specification so it is on by default. |
| [options].locale | `string` | `""` | A BCP 47 string tag. Locale default is english with a `\u00a0` grouping symbol (see [addLocale](#addLocale)) |
| [options].nbsp | `boolean` | `false` | By default the output will use a regular space, but in many cases you may desire a non-breaking-space instead. |
| [options].overflow | `string` | `"######"` | The string emitted when a formatter fails to format a date that is out of bounds. |
| [options].throws | `boolean` | `true` | Should the formatter throw an error if a provided pattern is invalid. If false, a formatter will be constructed which instead outputs an error string (see _invalid_ in this table). |
| Name | Type | Default | Description |
| ------------------------- | --------- | ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| pattern | `string` | | A format pattern in the ECMA-376 number format. |
| value | `any` | | The value to format. |
| [options] | `object` | `{}` | Options |
| [options].dateErrorNumber | `boolean` | `true` | Should the formatter switch to a General number format when trying to format a date that is out of bounds? |
| [options].dateErrorThrows | `boolean` | `false` | Should the formatter throw an error when trying to format a date that is out of bounds? |
| [options].dateSpanLarge | `boolean` | `true` | Extends the allowed range of dates from Excel bounds (1900–9999) to Google Sheet bounds (0–99999). |
| [options].fillChar | `boolean` | `""` | When the formatter encounters `*` it normally emits nothing instead of the `*` and the next character (like Excel TEXT function does). Setting this to a character will make the formatter emit that followed by the next one. |
| [options].ignoreTimezone | `boolean` | `false` | Normally when date objects are used with the formatter, time zone is taken into account. This makes the formatter ignore the timezone offset. |
| [options].invalid | `string` | `"######"` | The string emitted when no-throw mode fails to parse a pattern. |
| [options].leap1900 | `boolean` | `true` | Simulate the Lotus 1-2-3 [1900 leap year bug](https://docs.microsoft.com/en-us/office/troubleshoot/excel/wrongly-assumes-1900-is-leap-year). It is a requirement in the Ecma OOXML specification so it is on by default. |
| [options].locale | `string` | `""` | A BCP 47 string tag. Locale default is english with a `\u00a0` grouping symbol (see [addLocale](#addLocale)) |
| [options].nbsp | `boolean` | `false` | By default the output will use a regular space, but in many cases you may desire a non-breaking-space instead. |
| [options].overflow | `string` | `"######"` | The string emitted when a formatter fails to format a date that is out of bounds. |
| [options].skipChar | `boolean` | `""` | When the formatter encounters `_` it normally emits a single space instead of the `_` and the next character (like Excel TEXT function does). Setting this to a character will make the formatter emit that followed by the next one. |
| [options].throws | `boolean` | `true` | Should the formatter throw an error if a provided pattern is invalid. If false, a formatter will be constructed which instead outputs an error string (see _invalid_ in this table). |
##### Returns
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ Only the first section is mandatory, the others are filled in as needed. The sec
| `E-`, `E+` | Exponential format | `12200000` formatted with `0.00E+00` will emit `"1.22E+07"`
| `$`, `-`, `+`, `/`, `(`, `)`, ` ` | Pass-through | The symbol is printed as-is.
| `\` | Escape | Pass the the next character through as-is.
| `*` | Fill | Repeat the next character in the format enough times to fill the column to its current width. *Like Excel's TEXT function, numFmt emits nothing when this is used.*
| `_` | Skip width | Skip the width of the next character. *Like Excel's TEXT function, numFmt emits only a single space when this is used.*
| `*` | Fill | Repeat the next character in the format enough times to fill the column to its current width. By default numfmt emits nothing when this is used.
| `_` | Skip width | Skip the width of the next character. By default numfmt emits only a single space when this is used.
| `"text"` | Pass-through | Pass through whatever text is inside the quotation marks as-is. `7` formatted with `0 "bells"` will emit `"7 bells"`
| `@` | Text value | When value is a text, emit it as is: `foo` formatted with `"bar"@"bar"` will emit `"barfoobar"`
| `yy` | Years | Two digit year
Expand Down
20 changes: 20 additions & 0 deletions dist/numfmt.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ export declare function dateToSerial(date: (Date | Array<number>), options?: {
out of bounds?
* @param [options.dateSpanLarge=true] Extends the allowed range of dates from Excel bounds (1900–9999) to
Google Sheet bounds (0–99999).
* @param [options.fillChar=''] When the formatter encounters `*` it normally emits nothing instead of the
`*` and the next character (like Excel TEXT function does). Setting this
to a character will make the formatter emit that followed by the next one.
* @param [options.ignoreTimezone=false] Normally when date objects are used with the formatter, time zone is taken
into account. This makes the formatter ignore the timezone offset.
* @param [options.invalid="######"] The string emitted when no-throw mode fails to parse a pattern.
Expand All @@ -127,6 +130,10 @@ export declare function dateToSerial(date: (Date | Array<number>), options?: {
may desire a non-breaking-space instead.
* @param [options.overflow="######"] The string emitted when a formatter fails to format a date that is out
of bounds.
* @param [options.skipChar=''] When the formatter encounters `_` it normally emits a single space instead
of the `_` and the next character (like Excel TEXT function does). Setting
this to a character will make the formatter emit that followed by the next
one.
* @param [options.throws=true] Should the formatter throw an error if a provided pattern is invalid.
If false, a formatter will be constructed which instead outputs an error
string (see _invalid_ in this table).
Expand All @@ -148,6 +155,12 @@ export declare function format(pattern: string, value: any, options?: {
* Google Sheet bounds (0–99999).
*/
dateSpanLarge?: boolean;
/**
* When the formatter encounters `*` it normally emits nothing instead of the
* `*` and the next character (like Excel TEXT function does). Setting this
* to a character will make the formatter emit that followed by the next one.
*/
fillChar?: boolean;
/**
* Normally when date objects are used with the formatter, time zone is taken
* into account. This makes the formatter ignore the timezone offset.
Expand Down Expand Up @@ -175,6 +188,13 @@ export declare function format(pattern: string, value: any, options?: {
* of bounds.
*/
overflow?: string;
/**
* When the formatter encounters `_` it normally emits a single space instead
* of the `_` and the next character (like Excel TEXT function does). Setting
* this to a character will make the formatter emit that followed by the next
* one.
*/
skipChar?: boolean;
/**
* Should the formatter throw an error if a provided pattern is invalid.
* If false, a formatter will be constructed which instead outputs an error
Expand Down
4 changes: 2 additions & 2 deletions dist/numfmt.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "numfmt",
"description": "Full Excel style number formatting",
"author": "Borgar Þorsteinsson <[email protected]>",
"version": "3.0.0",
"version": "3.1.0",
"scripts": {
"build": "NODE_ENV=production rollup -c",
"build:types": "jsdoc -c tsd.json lib>dist/numfmt.d.ts",
Expand Down

0 comments on commit 17a07e5

Please sign in to comment.