Skip to content

Commit

Permalink
feat!: Drop intl-pluralrules/pseudo-number-format (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
eemeli committed Sep 3, 2022
1 parent d2955f9 commit 93cc416
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 168 deletions.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ const cat = { en: enCat, fr: frCat }
const getCategories = (lc, ord) => cat[lc][ord ? 'ordinal' : 'cardinal']

const range = { en: enRange, fr: frRange }
const getRangeSelector = (lc) => range[lc]
const getRangeSelector = lc => range[lc]

const PluralRules = getPluralRules(
Intl.NumberFormat, // Not available in IE 10
Expand All @@ -88,9 +88,8 @@ All arguments of
`getPluralRules(NumberFormat, getSelector, getCategories, getRangeSelector)`
are required.

- `NumberFormat` should be `Intl.NumberFormat`, or a minimal implementation
such as the one available at `intl-pluralrules/pseudo-number-format`. It
should at least support the `"en"` locale and all of the min/max digit count
- `NumberFormat` should be `Intl.NumberFormat`, or an implementation which
supports at least the `"en"` locale and all of the min/max digit count
options.
- `getSelector(lc)` should return a `function(n, ord)` returning the plural
category of `n`, using cardinal plural rules (by default), or ordinal rules if
Expand Down
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"files": [
"factory.*",
"plural-rules.*",
"pseudo-number-format.*",
"polyfill.*"
],
"type": "commonjs",
Expand All @@ -32,7 +31,6 @@
],
"./plural-rules": "./plural-rules.js",
"./polyfill": "./polyfill.js",
"./pseudo-number-format": "./pseudo-number-format.js",
"./package.json": "./package.json"
},
"browser": {
Expand Down
12 changes: 1 addition & 11 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ export default [
},
{
input: 'src/plural-rules.mjs',
context: 'this',
external: ['./factory.mjs', './pseudo-number-format.mjs'],
external: ['./factory.mjs'],
output: {
file: 'plural-rules.js',
format: 'cjs',
Expand All @@ -46,14 +45,5 @@ export default [
paths: id => id.replace(/^.*\/([^/]+)\.mjs$/, './$1.js')
},
plugins: [babel({ babelHelpers: 'bundled' })]
},
{
input: 'src/pseudo-number-format.mjs',
output: {
file: 'pseudo-number-format.js',
format: 'cjs',
exports: 'default'
},
plugins: [babel({ babelHelpers: 'bundled' })]
}
]
7 changes: 1 addition & 6 deletions src/plural-rules.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import * as C from 'make-plural/pluralCategories'
import * as R from 'make-plural/ranges'

import getPluralRules from './factory.mjs'
import PseudoNumberFormat from './pseudo-number-format.mjs'

// In a .mjs context, CommonJS imports only expose the default endpoint. We're
// using them here because with this many small functions, bundlers produce less
Expand All @@ -12,10 +11,6 @@ const Plurals = P.default || P
const Categories = C.default || C
const RangePlurals = R.default || R

const NumberFormat =
/* c8 ignore next */
(typeof Intl === 'object' && Intl.NumberFormat) || PseudoNumberFormat

// make-plural exports are cast with safe-identifier to be valid JS identifiers
const id = lc => (lc === 'pt-PT' ? 'pt_PT' : lc)

Expand All @@ -25,7 +20,7 @@ const getCategories = (lc, ord) =>
const getRangeSelector = lc => RangePlurals[id(lc)]

const PluralRules = getPluralRules(
NumberFormat,
Intl.NumberFormat,
getSelector,
getCategories,
getRangeSelector
Expand Down
70 changes: 0 additions & 70 deletions src/pseudo-number-format.mjs

This file was deleted.

75 changes: 0 additions & 75 deletions test/pseudo-numberformat.test.mjs

This file was deleted.

0 comments on commit 93cc416

Please sign in to comment.