@brightspace-ui/intl
Advanced tools
Comparing version 3.9.1 to 3.10.0
@@ -62,3 +62,3 @@ export const defaultLocale = 'en'; | ||
} | ||
for (var i in obj2) { | ||
for (const i in obj2) { | ||
// eslint-disable-next-line no-prototype-builtins | ||
@@ -65,0 +65,0 @@ if (obj1.hasOwnProperty(i)) { |
@@ -357,4 +357,4 @@ import { getDocumentLocaleSettings, getLanguage, merge } from './common.js'; | ||
for (var i = 0; i < parts.length; i++) { | ||
var part = parts[i].trim(); | ||
for (let i = 0; i < parts.length; i++) { | ||
const part = parts[i].trim(); | ||
switch (part) { | ||
@@ -609,3 +609,3 @@ case 'dd': | ||
let reStr = ''; | ||
Object.keys(replacements).forEach(function(key) { | ||
Object.keys(replacements).forEach((key) => { | ||
reStr += ((reStr === '') ? '' : '|') + key; | ||
@@ -616,3 +616,3 @@ }); | ||
const doReplacements = function(buf) { | ||
return buf.replace(re, function(m) { | ||
return buf.replace(re, (m) => { | ||
return replacements[m]; | ||
@@ -619,0 +619,0 @@ }); |
@@ -0,3 +1,3 @@ | ||
import { getLanguage, validateFormatValue } from './common.js'; | ||
import { formatNumber } from './number.js'; | ||
import { getLanguage, validateFormatValue } from './common.js'; | ||
@@ -4,0 +4,0 @@ export function getFileSizeDescriptor() { |
@@ -15,3 +15,3 @@ import { | ||
const valueStr = '' + value; | ||
const valueStr = `${value}`; | ||
let ret = ''; | ||
@@ -91,3 +91,3 @@ | ||
if (isNaN(value) || typeof value !== 'number' || (min !== undefined && value < min) || (max !== undefined && value > max)) { | ||
throw new RangeError(name + ' value is out of range.'); | ||
throw new RangeError(`${name} value is out of range.`); | ||
} | ||
@@ -258,3 +258,3 @@ | ||
value = value.replace( | ||
new RegExp('\\s|[' + descriptor.symbols.group + ']', 'g'), | ||
new RegExp(`\\s|[${descriptor.symbols.group}]`, 'g'), | ||
'' | ||
@@ -261,0 +261,0 @@ ); |
{ | ||
"name": "@brightspace-ui/intl", | ||
"version": "3.9.1", | ||
"version": "3.10.0", | ||
"description": "Internationalization APIs for number, date, time and file size formatting and parsing in D2L Brightspace.", | ||
"main": "lib/number.js", | ||
"scripts": { | ||
"lint": "eslint lib test --ext .js", | ||
"lint": "eslint . --ext .js", | ||
"test:unit": "concurrently -p name -n serve,test -s first -k \"http-server -p 8080 . -s\" \"mocha-headless-chrome -f http://localhost:8080/test/index.html -a no-sandbox -a disable-setuid-sandbox\"", | ||
@@ -43,9 +43,10 @@ "test": "npm run lint -s && npm run test:unit -s" | ||
"eslint": "^8", | ||
"eslint-config-brightspace": "^0.16", | ||
"eslint-config-brightspace": "^0.18", | ||
"eslint-plugin-html": "^6", | ||
"eslint-plugin-import": "^2", | ||
"eslint-plugin-sort-class-members": "^1", | ||
"http-server": "^14.0", | ||
"mocha": "^9", | ||
"mocha": "^10", | ||
"mocha-headless-chrome": "^4" | ||
} | ||
} |
@@ -25,4 +25,4 @@ # intl | ||
```javascript | ||
import {formatDate, formatTime} from '@brightspace-ui/intl/lib/dateTime.js'; | ||
import {formatNumber, formatPercent} from '@brightspace-ui/intl/lib/number.js'; | ||
import { formatDate, formatTime } from '@brightspace-ui/intl/lib/dateTime.js'; | ||
import { formatNumber, formatPercent } from '@brightspace-ui/intl/lib/number.js'; | ||
``` | ||
@@ -37,3 +37,3 @@ | ||
```javascript | ||
import {formatNumber, formatPercent} from '@brightspace-ui/intl/lib/number.js'; | ||
import { formatNumber, formatPercent } from '@brightspace-ui/intl/lib/number.js'; | ||
@@ -52,3 +52,3 @@ const number = formatNumber(8902.72, [options]); // -> '8,902.72' in en-US | ||
```javascript | ||
import {formatNumber} from '@brightspace-ui/intl/lib/number.js'; | ||
import { formatNumber } from '@brightspace-ui/intl/lib/number.js'; | ||
@@ -63,3 +63,3 @@ const value = formatNumber(89.72, { | ||
```javascript | ||
import {formatPercent} from '@brightspace-ui/intl/lib/number.js'; | ||
import { formatPercent } from '@brightspace-ui/intl/lib/number.js'; | ||
@@ -77,3 +77,3 @@ const value = formatPercent(0.333, { | ||
```javascript | ||
import {parseNumber} from '@brightspace-ui/intl/lib/number.js'; | ||
import { parseNumber } from '@brightspace-ui/intl/lib/number.js'; | ||
@@ -92,3 +92,3 @@ const value = parseNumber('-8 942,39'); // -> -8942.39 in fr-CA | ||
```javascript | ||
import {formatDateTime} from '@brightspace-ui/intl/lib/dateTime.js'; | ||
import { formatDateTime } from '@brightspace-ui/intl/lib/dateTime.js'; | ||
@@ -146,3 +146,3 @@ const date = formatDateTime( | ||
```javascript | ||
import {formatDate} from '@brightspace-ui/intl/lib/dateTime.js'; | ||
import { formatDate } from '@brightspace-ui/intl/lib/dateTime.js'; | ||
@@ -171,3 +171,3 @@ const value = formatDate( | ||
```javascript | ||
import {formatTime} from '@brightspace-ui/intl/lib/dateTime.js'; | ||
import { formatTime } from '@brightspace-ui/intl/lib/dateTime.js'; | ||
@@ -189,3 +189,3 @@ const time = formatTime( | ||
```javascript | ||
import {parseDate} from '@brightspace-ui/intl/lib/dateTime.js'; | ||
import { parseDate } from '@brightspace-ui/intl/lib/dateTime.js'; | ||
@@ -203,3 +203,3 @@ const date = parseDate('2015-09-23'); // in fr-CA | ||
```javascript | ||
import {parseTime} from '@brightspace-ui/intl/lib/dateTime.js'; | ||
import { parseTime } from '@brightspace-ui/intl/lib/dateTime.js'; | ||
@@ -215,3 +215,3 @@ const date = parseTime('14 h 05'); // in fr-CA | ||
```javascript | ||
import {convertUTCToLocalDateTime} from '@brightspace-ui/intl/lib/dateTime.js'; | ||
import { convertUTCToLocalDateTime } from '@brightspace-ui/intl/lib/dateTime.js'; | ||
@@ -233,3 +233,3 @@ const UTCDateTime = { | ||
```javascript | ||
import {convertLocalToUTCDateTime} from '@brightspace-ui/intl/lib/dateTime.js'; | ||
import { convertLocalToUTCDateTime } from '@brightspace-ui/intl/lib/dateTime.js'; | ||
@@ -254,3 +254,3 @@ const localDateTime = { | ||
```javascript | ||
import {formatFileSize} from '@brightspace-ui/intl/lib/fileSize.js'; | ||
import { formatFileSize } from '@brightspace-ui/intl/lib/fileSize.js'; | ||
@@ -260,2 +260,16 @@ const fileSize = formatFileSize(100); // -> '100 bytes' in en-US | ||
## List Formatting | ||
Use `getSeparator` to get the appropriate list separator for the current locale. This is a separator that would be used in spoken language; note that the separator includes a space, for locales where it is appropriate. | ||
```javascript | ||
import { getSeparator } from '@brightspace-ui/intl/lib/list.js'; | ||
const separator = getSeparator(); // -> ', ' in en-US | ||
const separator = getSeparator({ nonBreaking: true }); // -> ',\xa0' in en-US | ||
``` | ||
Options: | ||
- **nonBreaking**: a Boolean flag, whether to use non-breaking spaces instead of standard spaces; default is `false` | ||
## Contributing | ||
@@ -262,0 +276,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
72941
8
1599
303
12