Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Require Node.js 12 and move to ESM #31

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
2 changes: 1 addition & 1 deletion benchmark/fixtures.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
export default {
string: 'foo',
stringNumber: '1000',
number: 1000,
Expand Down
14 changes: 8 additions & 6 deletions benchmark/index.js
Original file line number Diff line number Diff line change
@@ -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)
jimmywarting marked this conversation as resolved.
Show resolved Hide resolved

const cycle = (e, nl) => {
cursor.eraseLine();
Expand Down Expand Up @@ -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;
}
Expand All @@ -80,7 +83,7 @@ function isNumber60(val) {
return false;
}

function isNumber61(val) {
function isNumber61(num) {
if (typeof num === 'number') {
return num - num === 0;
}
Expand All @@ -89,4 +92,3 @@ function isNumber61(val) {
}
return false;
}

20 changes: 17 additions & 3 deletions benchmark/last.md
Original file line number Diff line number Diff line change
@@ -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'
4 changes: 1 addition & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
"index.js"
],
"main": "index.js",
"type": "module",
"engines": {
"node": ">=0.12.0"
"node": ">=12.20.0"
},
"scripts": {
"test": "mocha"
Expand Down
8 changes: 3 additions & 5 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down