From b1a0cfc8912956b2c32abfbb95893bbde7184d2c Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Sat, 6 Oct 2018 00:08:14 +0330 Subject: [PATCH 1/2] feat(bench): add oneTypeof, oneLiner and twoLiner tests --- bench.js | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/bench.js b/bench.js index b89d9bf..d4bf3b7 100644 --- a/bench.js +++ b/bench.js @@ -21,7 +21,10 @@ const values = [ ]; suite - .add('current', () => values.forEach(v => current(v))) + .add('twoTypeof (current)', () => values.forEach(v => twoTypeof(v))) + .add('oneTypeof', () => values.forEach(v => oneTypeof(v))) + .add('oneLiner', () => values.forEach(v => oneLiner(v))) + .add('twoLiner', () => values.forEach(v => twoLiner(v))) .add('if', () => values.forEach(v => isPrimitiveIf(v))) .add('negation', () => values.forEach(v => negation(v))) .add('equals', () => values.forEach(v => isPrimitiveEquals(v))) @@ -38,13 +41,30 @@ suite }) .run(); -function current(val) { +function oneTypeof(val) { + const type = typeof val + if (type === 'object') { + return val === null; + } + return type !== 'function'; +} + +function twoTypeof(val) { if (typeof val === 'object') { return val === null; } return typeof val !== 'function'; } +function oneLiner(val) { + return typeof val === 'object' ? val === null : typeof val !== 'function' +} + +function twoLiner(val) { + const type = typeof val + return type === 'object' ? val === null : type !== 'function' +} + function negation(val) { if (val === null) { return true; From 0999068989a7b114835c98276de676576189b41f Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Sat, 6 Oct 2018 00:37:57 +0330 Subject: [PATCH 2/2] fix(travis): drop legacy versions of node --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index f9f3c0b..863636e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,5 +12,3 @@ node_js: - '6' - '5' - '4' - - '0.12' - - '0.10'