[d3-format] v1.1

* [Enhancement] Add optional `numerals` property to `FormatLocaleDefinition`
* [Enhancement] Replaced union type of `decimal` and `thousand` with `string` type in `FormatLocaleDefinition` to generalize
* Bumped minor version number
This commit is contained in:
Tom Wanzek 2017-03-07 20:54:48 -05:00
parent 868ecf81e9
commit 082f42fd5b
2 changed files with 23 additions and 8 deletions

View File

@ -63,11 +63,6 @@ num = d3Format.precisionRound(0.0005, 3000);
// Test Locale Definition
// ----------------------------------------------------------------------
let decimal: '.' | ',' = localeDef.decimal;
let thousands: '.' | ',' | '\u00a0' | "'" = localeDef.thousands;
let grouping: Array<number> = localeDef.grouping;
let currency: [string, string] = localeDef.currency;
localeDef = {
decimal: ',',
thousands: '.',
@ -75,6 +70,20 @@ localeDef = {
currency: ['EUR', '']
};
localeDef = {
decimal: "\u066b",
thousands: "\u066c",
grouping: [3],
currency: ["", ""],
numerals : ["\u0660", "\u0661", "\u0662", "\u0663", "\u0664", "\u0665", "\u0666", "\u0667", "\u0668", "\u0669"]
}
let decimal: string = localeDef.decimal;
let thousands: string = localeDef.thousands;
let grouping: Array<number> = localeDef.grouping;
let currency: [string, string] = localeDef.currency;
let numerals: string[] | undefined = localeDef.numerals;
localeObj = d3Format.formatLocale(localeDef);
localeObj = d3Format.formatDefaultLocale(localeDef);

12
d3-format/index.d.ts vendored
View File

@ -1,8 +1,10 @@
// Type definitions for D3JS d3-format module v1.0.2
// Type definitions for D3JS d3-format module 1.1
// Project: https://github.com/d3/d3-format/
// Definitions by: Tom Wanzek <https://github.com/tomwanzek>, Alex Ford <https://github.com/gustavderdrache>, Boris Yankov <https://github.com/borisyankov>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// Last module patch version validated against: 1.1.0
/**
* Specification of locale to use when creating a new FormatLocaleObject
*/
@ -10,12 +12,12 @@ export interface FormatLocaleDefinition {
/**
* The decimal point (e.g., ".")
*/
decimal: '.' | ',';
decimal: string;
/**
* The group separator (e.g., ","). Note that the thousands property is a misnomer, as\
* the grouping definition allows groups other than thousands.
*/
thousands: '.' | ',' | '\u00a0' | "'";
thousands: string;
/**
* The array of group sizes (e.g., [3]), cycled as needed.
*/
@ -24,6 +26,10 @@ export interface FormatLocaleDefinition {
* The currency prefix and suffix (e.g., ["$", ""])
*/
currency: [string, string];
/**
* An array of ten strings to replace the numerals 0-9.
*/
numerals?: string[];
}
/**