Skip to content

Commit

Permalink
Merge branch 'benchmarks'
Browse files Browse the repository at this point in the history
  • Loading branch information
jonschlinkert committed Sep 4, 2017
2 parents 72d2f2b + af64cb8 commit f2483e0
Show file tree
Hide file tree
Showing 12 changed files with 44 additions and 10 deletions.
3 changes: 2 additions & 1 deletion benchmark/check.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ glob.sync(__dirname + '/code/*.js').forEach(function (fp) {
var name = path.basename(fp, path.extname(fp));

fixtures.forEach(function (fixture) {
console.log(bold(name) + ':', fn.apply(null, require(fixture)));
var stem = path.basename(fixture, path.extname(fixture));
console.log(bold(name) + `: ${stem}`, fn.apply(null, require(fixture)));
});
});
1 change: 0 additions & 1 deletion benchmark/code/current.js

This file was deleted.

10 changes: 10 additions & 0 deletions benchmark/code/kind-of.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
var typeOf = require('../..');

module.exports = function(args) {
var arg = args[0];
// if the word "arguments" is passed from fixtures, just check args
if (arg === 'arguments') {
return typeOf(arguments);
}
return typeOf(args[0]);
};
11 changes: 10 additions & 1 deletion benchmark/code/lib-type-of.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
/**
* https://github.com/ForbesLindesay/type-of
*/
module.exports = require('type-of');
var typeOf = require('type-of');

module.exports = function(args) {
var arg = args[0];
// if the word "arguments" is passed from fixtures, just check args
if (arg === 'arguments') {
return typeOf(arguments);
}
return typeOf(args[0]);
};
11 changes: 10 additions & 1 deletion benchmark/code/lib-typeof.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
/**
* http://github.com/CodingFu/typeof
*/
module.exports = require('typeof');
var typeOf = require('typeof');

module.exports = function(args) {
var arg = args[0];
// if the word "arguments" is passed from fixtures, just check args
if (arg === 'arguments') {
return typeOf(arguments);
}
return typeOf(args[0]);
};
3 changes: 2 additions & 1 deletion benchmark/code/regex-exec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
var re = /^\[object (\w+)\]$/;

module.exports = function typeOf(val) {
module.exports = function typeOf(arr) {
var val = arr[0];
if (val === null) {
return 'null';
}
Expand Down
3 changes: 2 additions & 1 deletion benchmark/code/regex-replace.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
var re = /^\[object (\w+)\]$/;

module.exports = function typeOf(val) {
module.exports = function typeOf(arr) {
var val = arr[0];
if (val === null) {
return 'null';
}
Expand Down
3 changes: 2 additions & 1 deletion benchmark/code/slice-switch.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module.exports = function typeOf(val) {
module.exports = function typeOf(arr) {
var val = arr[0];
if (val === null) return 'null';

if (val === undefined) {
Expand Down
3 changes: 2 additions & 1 deletion benchmark/code/slice.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
module.exports = function typeOf(val) {
module.exports = function typeOf(arr) {
var val = arr[0];
return {}.toString.call(val).slice(8, -1).toLowerCase();
};
2 changes: 1 addition & 1 deletion benchmark/fixtures/arguments.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = [arguments];
module.exports = ['arguments'];
2 changes: 2 additions & 0 deletions benchmark/fixtures/custom.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
function Test() {}
module.exports = [new Test()];
2 changes: 1 addition & 1 deletion browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,4 @@ function isBuffer(val) {
}

},{}]},{},[1])(1)
});
});

0 comments on commit f2483e0

Please sign in to comment.