This commit is contained in:
Stephen Franceschelli 2019-07-30 13:41:05 -04:00
parent 596a6da241
commit c1a589c5b6
7078 changed files with 1882834 additions and 319 deletions

17
node_modules/left-pad/perf/O(n).js generated vendored Normal file
View file

@ -0,0 +1,17 @@
'use strict';
module.exports = function (str, len, ch) {
str = str + '';
len = len - str.length;
if (len <= 0) return str;
if (!ch && ch !== 0) ch = ' ';
ch = ch + '';
while (len--) {
str = ch + str;
}
return str;
}

13
node_modules/left-pad/perf/es6Repeat.js generated vendored Normal file
View file

@ -0,0 +1,13 @@
'use strict';
module.exports = function (str, len, ch) {
str = str + '';
len = len - str.length;
if (len <= 0) return str;
if (!ch && ch !== 0) ch = ' ';
ch = ch + '';
return ch.repeat(len) + str;
};

40
node_modules/left-pad/perf/perf.js generated vendored Normal file
View file

@ -0,0 +1,40 @@
'use strict';
var oN = require('./O(n)');
var es6Repeat = require('./es6Repeat');
var current = require('../');
var Benchmark = require('benchmark');
var str = "abcd"
var len = 100;
function buildSuite (note, fns, args) {
console.log(note);
var suite = new Benchmark.Suite;
Object.keys(fns).forEach(function (name) {
suite.add(name, function () {
fns[name].apply(null, args);
});
});
suite.on('cycle', function (event) {
console.log(String(event.target));
}).on('complete', function () {
console.log('Fastest is ' + this.filter('fastest').map('name'));
});
return suite;
}
var fns = {
'O(n)': oN,
'ES6 Repeat': es6Repeat,
'Current': current
};
buildSuite('-> pad 100 spaces to str of len 4', fns, ['abcd', 104, ' ']).run();
buildSuite('-> pad 10 spaces to str of len 4', fns, ['abcd', 14, ' ']).run();
buildSuite('-> pad 9 spaces to str of len 4', fns, ['abcd', 13, ' ']).run();
buildSuite('-> pad 100 to str of len 100', fns, ['0012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789123456789', 200, ' ']).run();
buildSuite('-> pad 10 to str of len 100', fns, ['0012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789123456789', 110, ' ']).run();
buildSuite('-> pad 9 to str of len 100', fns, ['0012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789123456789', 109, ' ']).run();