Skip to content

Commit bc775dd

Browse files
committed
Require Node.js 12 and move to ESM
1 parent 6ce6b23 commit bc775dd

File tree

7 files changed

+20
-22
lines changed

7 files changed

+20
-22
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@ jobs:
1212
node-version:
1313
- 14
1414
- 12
15-
- 10
16-
- 8
1715
steps:
1816
- uses: actions/checkout@v2
19-
- uses: actions/setup-node@v1
17+
- uses: actions/setup-node@v2
2018
with:
2119
node-version: ${{ matrix.node-version }}
2220
- run: npm install

index.d.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* eslint-disable import/export */
2+
13
/**
24
Generate a random [float](https://en.wikipedia.org/wiki/Floating_point).
35
@@ -7,7 +9,7 @@ Generate a random [float](https://en.wikipedia.org/wiki/Floating_point).
79
810
@example
911
```
10-
import randomFloat = require('random-float');
12+
import randomFloat from 'random-float';
1113
1214
randomFloat(5);
1315
//=> 4.401887938147411
@@ -16,7 +18,5 @@ randomFloat(10, 100);
1618
//=> 72.34217455144972
1719
```
1820
*/
19-
declare function randomFloat(maximum?: number): number;
20-
declare function randomFloat(minimum: number, maximum: number): number;
21-
22-
export = randomFloat;
21+
export default function randomFloat(maximum?: number): number;
22+
export default function randomFloat(minimum: number, maximum: number): number; // eslint-disable-line @typescript-eslint/unified-signatures

index.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
'use strict';
2-
3-
module.exports = (minimum, maximum) => {
1+
export default function randomFloat(minimum, maximum) {
42
if (maximum === undefined) {
53
maximum = minimum;
64
minimum = 0;
@@ -11,4 +9,4 @@ module.exports = (minimum, maximum) => {
119
}
1210

1311
return (Math.random() * (maximum - minimum)) + minimum;
14-
};
12+
}

index.test-d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {expectType} from 'tsd';
2-
import randomFloat = require('.');
2+
import randomFloat from './index.js';
33

44
expectType<number>(randomFloat());
55
expectType<number>(randomFloat(5));

package.json

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@
1010
"email": "[email protected]",
1111
"url": "https://sindresorhus.com"
1212
},
13+
"type": "module",
14+
"exports": "./index.js",
1315
"engines": {
14-
"node": ">=8"
16+
"node": ">=12"
1517
},
1618
"scripts": {
1719
"test": "xo && ava && tsd"
@@ -35,11 +37,11 @@
3537
"generator"
3638
],
3739
"devDependencies": {
38-
"ava": "^1.4.1",
39-
"in-range": "^2.0.0",
40-
"number-is-float": "^1.0.0",
41-
"stable-fn": "^2.0.0",
42-
"tsd": "^0.7.2",
43-
"xo": "^0.24.0"
40+
"ava": "^3.15.0",
41+
"in-range": "^3.0.0",
42+
"number-is-float": "^2.0.0",
43+
"stable-fn": "^3.0.0",
44+
"tsd": "^0.14.0",
45+
"xo": "^0.38.2"
4446
}
4547
}

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ $ npm install random-float
1111
## Usage
1212

1313
```js
14-
const randomFloat = require('random-float');
14+
import randomFloat from 'random-float';
1515

1616
randomFloat(5);
1717
//=> 4.401887938147411

test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import test from 'ava';
22
import numberIsFloat from 'number-is-float';
33
import inRange from 'in-range';
44
import stableFn from 'stable-fn';
5-
import randomFloat from '.';
5+
import randomFloat from './index.js';
66

77
const inRangeCheck = ({start, end}) => stableFn(() => inRange(randomFloat(start, end), {start, end}));
88

0 commit comments

Comments
 (0)