diff --git a/.travis.yml b/.travis.yml index f9f3c0b..cddcdbc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,12 +5,6 @@ os: language: node_js node_js: - node - - '10' - - '9' - - '8' - - '7' - - '6' - - '5' - - '4' - - '0.12' - - '0.10' + - '16' + - '14' + - '12' diff --git a/benchmark/fixtures.js b/benchmark/fixtures.js index 6dd62f0..89d4609 100644 --- a/benchmark/fixtures.js +++ b/benchmark/fixtures.js @@ -1,4 +1,4 @@ -module.exports = { +export default { string: 'foo', stringNumber: '1000', number: 1000, diff --git a/benchmark/index.js b/benchmark/index.js index a2f4b9e..22cc300 100644 --- a/benchmark/index.js +++ b/benchmark/index.js @@ -1,6 +1,9 @@ -const { Suite } = require('benchmark'); -const cursor = require('ansi')(process.stdout); -const fixtures = require('./fixtures'); +import benchmark from 'benchmark' +import ansi from 'ansi' +import fixtures from './fixtures.js' + +const { Suite } = benchmark +const cursor = ansi(process.stdout) const cycle = (e, nl) => { cursor.eraseLine(); @@ -54,7 +57,7 @@ bench('number') .add('parseFloat', () => run(isNumberParseFloat, 'number')) .run() -function isNumberParseFloat(n) { +function isNumberParseFloat(num) { if (typeof num === 'number') { return num - num === 0; } @@ -80,7 +83,7 @@ function isNumber60(val) { return false; } -function isNumber61(val) { +function isNumber61(num) { if (typeof num === 'number') { return num - num === 0; } @@ -89,4 +92,3 @@ function isNumber61(val) { } return false; } - diff --git a/benchmark/last.md b/benchmark/last.md index 714f248..cb91c30 100644 --- a/benchmark/last.md +++ b/benchmark/last.md @@ -1,3 +1,17 @@ -current.js x 100,502 ops/sec ±0.80% (94 runs sampled) -isFinite.js x 91,315 ops/sec ±0.92% (89 runs sampled) -parseFloat.js x 72,464 ops/sec ±1.17% (91 runs sampled) +# all +v6.1 x 521,002 ops/sec ±0.94% (91 runs sampled) +v6.0 x 133,018 ops/sec ±1.26% (94 runs sampled) +parseFloat x 281,881 ops/sec ±0.32% (93 runs sampled) +fastest is 'v6.1' + +# string +v6.1 x 3,691,902 ops/sec ±0.43% (97 runs sampled) +v6.0 x 3,922,010 ops/sec ±0.40% (97 runs sampled) +parseFloat x 3,171,613 ops/sec ±0.57% (96 runs sampled) +fastest is 'v6.0' + +# number +v6.1 x 4,354,093 ops/sec ±0.89% (93 runs sampled) +v6.0 x 4,317,080 ops/sec ±0.31% (97 runs sampled) +parseFloat x 4,374,071 ops/sec ±0.37% (94 runs sampled) +fastest is 'parseFloat,v6.1' diff --git a/index.js b/index.js index 27f19b7..8433b3f 100644 --- a/index.js +++ b/index.js @@ -5,9 +5,7 @@ * Released under the MIT License. */ -'use strict'; - -module.exports = function(num) { +export default function(num) { if (typeof num === 'number') { return num - num === 0; } diff --git a/package.json b/package.json index 3715072..1c68d8e 100644 --- a/package.json +++ b/package.json @@ -18,8 +18,9 @@ "index.js" ], "main": "index.js", + "type": "module", "engines": { - "node": ">=0.12.0" + "node": ">=12.20.0" }, "scripts": { "test": "mocha" diff --git a/test.js b/test.js index 0f02427..16d4134 100644 --- a/test.js +++ b/test.js @@ -5,11 +5,9 @@ * Licensed under the MIT License. */ -'use strict'; - -require('mocha'); -var assert = require('assert'); -var isNumber = require('./'); +import assert from 'node:assert' +import 'mocha' +import isNumber from './index.js' describe('is a number', function() { var fixtures = [