Skip to content

Commit

Permalink
Require Node.js 12.20 and move to ESM
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Nov 4, 2021
1 parent 405e194 commit 5c1138b
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 30 deletions.
3 changes: 0 additions & 3 deletions .github/funding.yml

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ jobs:
fail-fast: false
matrix:
node-version:
- 16
- 14
- 12
- 10
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- run: npm install
Expand Down
14 changes: 6 additions & 8 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/**
Pluralize a word.
@param word - Word to pluralize.
@param plural - Pluralized word.
@param word - The word to pluralize.
@param plural - Explicitly provide the pluralized word.
The plural suffix will match the case of the last letter in the word.
This option is only for extreme edge-cases. You probably won't need it.
Expand All @@ -13,11 +13,11 @@ Default:
- Words ending in *y* that are preceded by a consonant will be pluralized by replacing *y* with *-ies* (eg. *puppies*).
- All other words will have "s" added to the end (eg. *days*).
@param count - Count to determine whether to use singular or plural.
@param count - The count to determine whether to use singular or plural.
@example
```
import plur = require('plur');
import plur from 'plur';
plur('unicorn', 4);
//=> 'unicorns'
Expand All @@ -32,7 +32,5 @@ plur('cactus', 2);
//=> 'cacti'
```
*/
declare function plur(word: string, count: number): string;
declare function plur(word: string, plural: string, count: number): string;

export = plur;
export default function plur(word: string, count: number): string;
export default function plur(word: string, plural: string, count: number): string;
7 changes: 3 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict';
const irregularPlurals = require('irregular-plurals');
import irregularPlurals from 'irregular-plurals';

module.exports = (word, plural, count) => {
export default function plur(word, plural, count) {
if (typeof plural === 'number') {
count = plural;
}
Expand All @@ -28,4 +27,4 @@ module.exports = (word, plural, count) => {
}

return Math.abs(count) === 1 ? word : plural;
};
}
2 changes: 1 addition & 1 deletion index.test-d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {expectType} from 'tsd';
import plur = require('.');
import plur from './index.js';

expectType<string>(plur('chicken', 2));
expectType<string>(plur('chicken', 'chicks', 2));
12 changes: 7 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
"email": "sindresorhus@gmail.com",
"url": "https://sindresorhus.com"
},
"type": "module",
"exports": "./index.js",
"engines": {
"node": ">=10"
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
},
"scripts": {
"test": "xo && ava && tsd"
Expand All @@ -33,11 +35,11 @@
"nouns"
],
"dependencies": {
"irregular-plurals": "^3.2.0"
"irregular-plurals": "^3.3.0"
},
"devDependencies": {
"ava": "^1.4.1",
"tsd": "^0.11.0",
"xo": "^0.26.1"
"ava": "^3.15.0",
"tsd": "^0.18.0",
"xo": "^0.46.4"
}
}
12 changes: 6 additions & 6 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
## Install

```
$ npm install plur
```sh
npm install plur
```

## Usage

```js
const plur = require('plur');
import plur from 'plur';

plur('unicorn', 4);
//=> 'unicorns'
Expand All @@ -34,7 +34,7 @@ plur('cactus', 2);

Type: `string`

Word to pluralize.
The word to pluralize.

#### plural

Expand All @@ -46,7 +46,7 @@ Default:
- Words ending in *y* that are preceded by a consonant will be pluralized by replacing *y* with *-ies* (eg. *puppies*).
- All other words will have "s" added to the end (eg. *days*).

Pluralized word.
Explicitly provide the pluralized word.

The plural suffix will match the case of the last letter in the word.

Expand All @@ -56,4 +56,4 @@ This option is only for extreme edge-cases. You probably won't need it.

Type: `number`

Count to determine whether to use singular or plural.
The count to determine whether to use singular or plural.
2 changes: 1 addition & 1 deletion test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import test from 'ava';
import plur from '.';
import plur from './index.js';

test('main', t => {
t.is(plur('unicorn', 0), 'unicorns');
Expand Down

0 comments on commit 5c1138b

Please sign in to comment.