pax_global_header 0000666 0000000 0000000 00000000064 14033436213 0014511 g ustar 00root root 0000000 0000000 52 comment=f2314f3fcf642c7c1c30cdefbd087a1da775e0d7
jonschlinkert-repeat-element-f2314f3/ 0000775 0000000 0000000 00000000000 14033436213 0017625 5 ustar 00root root 0000000 0000000 jonschlinkert-repeat-element-f2314f3/.editorconfig 0000664 0000000 0000000 00000000441 14033436213 0022301 0 ustar 00root root 0000000 0000000 # http://editorconfig.org/
root = true
[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
[{**/{actual,fixtures,expected,templates}/**,*.md}]
trim_trailing_whitespace = false
insert_final_newline = false
jonschlinkert-repeat-element-f2314f3/.eslintrc.json 0000664 0000000 0000000 00000007325 14033436213 0022430 0 ustar 00root root 0000000 0000000 {
"extends": [
"eslint:recommended"
],
"env": {
"browser": false,
"es6": true,
"node": true,
"mocha": true
},
"parserOptions":{
"ecmaVersion": 9,
"sourceType": "module",
"ecmaFeatures": {
"modules": true,
"experimentalObjectRestSpread": true
}
},
"globals": {
"document": false,
"navigator": false,
"window": false
},
"rules": {
"accessor-pairs": 2,
"arrow-spacing": [2, { "before": true, "after": true }],
"block-spacing": [2, "always"],
"brace-style": [2, "1tbs", { "allowSingleLine": true }],
"comma-dangle": [2, "never"],
"comma-spacing": [2, { "before": false, "after": true }],
"comma-style": [2, "last"],
"constructor-super": 2,
"curly": [2, "multi-line"],
"dot-location": [2, "property"],
"eol-last": 2,
"eqeqeq": [2, "allow-null"],
"generator-star-spacing": [2, { "before": true, "after": true }],
"handle-callback-err": [2, "^(err|error)$" ],
"indent": [2, 2, { "SwitchCase": 1 }],
"key-spacing": [2, { "beforeColon": false, "afterColon": true }],
"keyword-spacing": [2, { "before": true, "after": true }],
"new-cap": [2, { "newIsCap": true, "capIsNew": false }],
"new-parens": 2,
"no-array-constructor": 2,
"no-caller": 2,
"no-class-assign": 2,
"no-cond-assign": 2,
"no-const-assign": 2,
"no-control-regex": 2,
"no-debugger": 2,
"no-delete-var": 2,
"no-dupe-args": 2,
"no-dupe-class-members": 2,
"no-dupe-keys": 2,
"no-duplicate-case": 2,
"no-empty-character-class": 2,
"no-eval": 2,
"no-ex-assign": 2,
"no-extend-native": 2,
"no-extra-bind": 2,
"no-extra-boolean-cast": 2,
"no-extra-parens": [2, "functions"],
"no-fallthrough": 2,
"no-floating-decimal": 2,
"no-func-assign": 2,
"no-implied-eval": 2,
"no-inner-declarations": [2, "functions"],
"no-invalid-regexp": 2,
"no-irregular-whitespace": 2,
"no-iterator": 2,
"no-label-var": 2,
"no-labels": 2,
"no-lone-blocks": 2,
"no-mixed-spaces-and-tabs": 2,
"no-multi-spaces": 2,
"no-multi-str": 2,
"no-multiple-empty-lines": [2, { "max": 1 }],
"no-native-reassign": 0,
"no-negated-in-lhs": 2,
"no-new": 2,
"no-new-func": 2,
"no-new-object": 2,
"no-new-require": 2,
"no-new-wrappers": 2,
"no-obj-calls": 2,
"no-octal": 2,
"no-octal-escape": 2,
"no-proto": 0,
"no-redeclare": 2,
"no-regex-spaces": 2,
"no-return-assign": 2,
"no-self-compare": 2,
"no-sequences": 2,
"no-shadow-restricted-names": 2,
"no-spaced-func": 2,
"no-sparse-arrays": 2,
"no-this-before-super": 2,
"no-throw-literal": 2,
"no-trailing-spaces": 0,
"no-undef": 2,
"no-undef-init": 2,
"no-unexpected-multiline": 2,
"no-unneeded-ternary": [2, { "defaultAssignment": false }],
"no-unreachable": 2,
"no-unused-vars": [2, { "vars": "all", "args": "none" }],
"no-useless-call": 0,
"no-with": 2,
"one-var": [0, { "initialized": "never" }],
"operator-linebreak": [0, "after", { "overrides": { "?": "before", ":": "before" } }],
"padded-blocks": [0, "never"],
"quotes": [2, "single", "avoid-escape"],
"radix": 2,
"semi": [2, "always"],
"semi-spacing": [2, { "before": false, "after": true }],
"space-before-blocks": [2, "always"],
"space-before-function-paren": [2, "never"],
"space-in-parens": [2, "never"],
"space-infix-ops": 2,
"space-unary-ops": [2, { "words": true, "nonwords": false }],
"spaced-comment": [0, "always", { "markers": ["global", "globals", "eslint", "eslint-disable", "*package", "!", ","] }],
"use-isnan": 2,
"valid-typeof": 2,
"wrap-iife": [2, "any"],
"yoda": [2, "never"]
}
}
jonschlinkert-repeat-element-f2314f3/.gitattributes 0000664 0000000 0000000 00000000355 14033436213 0022523 0 ustar 00root root 0000000 0000000 # Enforce Unix newlines
*.* text eol=lf
*.css text eol=lf
*.html text eol=lf
*.js text eol=lf
*.json text eol=lf
*.less text eol=lf
*.md text eol=lf
*.yml text eol=lf
*.jpg binary
*.gif binary
*.png binary
*.jpeg binary jonschlinkert-repeat-element-f2314f3/.gitignore 0000664 0000000 0000000 00000000456 14033436213 0021622 0 ustar 00root root 0000000 0000000 # always ignore files
*.DS_Store
.idea
.vscode
*.sublime-*
# test related, or directories generated by tests
test/actual
actual
coverage
.nyc*
# npm
node_modules
npm-debug.log
# yarn
yarn.lock
yarn-error.log
# misc
_gh_pages
_draft
_drafts
bower_components
vendor
temp
tmp
TODO.md
package-lock.json jonschlinkert-repeat-element-f2314f3/.travis.yml 0000664 0000000 0000000 00000000112 14033436213 0021730 0 ustar 00root root 0000000 0000000 sudo: false
language: node_js
node_js:
- 'node'
- '6'
- '5'
- '4'
jonschlinkert-repeat-element-f2314f3/.verb.md 0000664 0000000 0000000 00000000635 14033436213 0021167 0 ustar 00root root 0000000 0000000 ## Usage
```js
const repeat = require('{%= name %}');
repeat('a', 5);
//=> ['a', 'a', 'a', 'a', 'a']
repeat('a', 1);
//=> ['a']
repeat('a', 0);
//=> []
repeat(null, 5)
//» [ null, null, null, null, null ]
repeat({some: 'object'}, 5)
//» [ { some: 'object' },
// { some: 'object' },
// { some: 'object' },
// { some: 'object' },
// { some: 'object' } ]
repeat(5, 5)
//» [ 5, 5, 5, 5, 5 ]
```
jonschlinkert-repeat-element-f2314f3/LICENSE 0000664 0000000 0000000 00000002103 14033436213 0020626 0 ustar 00root root 0000000 0000000 The MIT License (MIT)
Copyright (c) 2015-present, Jon Schlinkert.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
jonschlinkert-repeat-element-f2314f3/README.md 0000664 0000000 0000000 00000005536 14033436213 0021115 0 ustar 00root root 0000000 0000000 # repeat-element [](https://www.npmjs.com/package/repeat-element) [](https://npmjs.org/package/repeat-element) [](https://npmjs.org/package/repeat-element) [](https://travis-ci.org/jonschlinkert/repeat-element)
> Create an array by repeating the given value n times.
Please consider following this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support.
## Install
Install with [npm](https://www.npmjs.com/):
```sh
$ npm install --save repeat-element
```
## Usage
```js
const repeat = require('repeat-element');
repeat('a', 5);
//=> ['a', 'a', 'a', 'a', 'a']
repeat('a', 1);
//=> ['a']
repeat('a', 0);
//=> []
repeat(null, 5)
//» [ null, null, null, null, null ]
repeat({some: 'object'}, 5)
//» [ { some: 'object' },
// { some: 'object' },
// { some: 'object' },
// { some: 'object' },
// { some: 'object' } ]
repeat(5, 5)
//» [ 5, 5, 5, 5, 5 ]
```
## About
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
Running Tests
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
```sh
$ npm install && npm test
```
Building docs
_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_
To generate the readme, run the following command:
```sh
$ npm install -g verbose/verb#dev verb-generate-readme && verb
```
### Contributors
| **Commits** | **Contributor** |
| --- | --- |
| 17 | [jonschlinkert](https://github.com/jonschlinkert) |
| 3 | [LinusU](https://github.com/LinusU) |
| 1 | [architectcodes](https://github.com/architectcodes) |
### Author
**Jon Schlinkert**
* [GitHub Profile](https://github.com/jonschlinkert)
* [Twitter Profile](https://twitter.com/jonschlinkert)
* [LinkedIn Profile](https://linkedin.com/in/jonschlinkert)
### License
Copyright © 2018, [Jon Schlinkert](https://github.com/jonschlinkert).
Released under the [MIT License](LICENSE).
***
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on August 19, 2018._ jonschlinkert-repeat-element-f2314f3/benchmark/ 0000775 0000000 0000000 00000000000 14033436213 0021557 5 ustar 00root root 0000000 0000000 jonschlinkert-repeat-element-f2314f3/benchmark/check.js 0000775 0000000 0000000 00000002250 14033436213 0023174 0 ustar 00root root 0000000 0000000 'use strict';
const chalk = require('chalk');
const path = require('path');
const glob = require('glob');
const repeat = require('../');
/**
* Sanity check. Run to ensure that all fns return the same result.
*/
let fixtures = glob.sync(__dirname + '/fixtures/*.js').map(require);
let expected = fixtures.map(fixture => repeat.apply(repeat, fixture).length);
glob.sync(__dirname + '/code/*.js').forEach(function (fp) {
let fn = require(path.resolve(__dirname, 'code', fp));
let name = path.basename(fp, path.extname(fp));
let problems = [];
fixtures.forEach(function (fixture, idx) {
let answer = fn.apply(fn, fixture).length;
if (answer !== expected[idx]) {
problems.push(['repeat(' + fixture.join(', ') + ').length', answer, expected[idx]]);
}
});
if (problems.length === 0) {
console.log(' ' + chalk.bold.green('✔') + ' ' + chalk.bold(name));
} else {
console.log(' ' + chalk.bold.red('✖') + ' ' + chalk.bold(name));
problems.forEach(function (item, idx, arr) {
let str = item[0] + ' gave ' + item[1] + ', expected ' + item[2];
console.log((idx === arr.length - 1 ? ' ┗ ' : ' ┣ ') + chalk.red(str));
});
}
});
jonschlinkert-repeat-element-f2314f3/benchmark/code/ 0000775 0000000 0000000 00000000000 14033436213 0022471 5 ustar 00root root 0000000 0000000 jonschlinkert-repeat-element-f2314f3/benchmark/code/array-from.js 0000664 0000000 0000000 00000000230 14033436213 0025101 0 ustar 00root root 0000000 0000000 'use strict';
function getThis() {
return this;
}
module.exports = function repeat(ele, num) {
return Array.from({length: num}, getThis, ele);
};
jonschlinkert-repeat-element-f2314f3/benchmark/code/array-map-call.js 0000664 0000000 0000000 00000000232 14033436213 0025626 0 ustar 00root root 0000000 0000000 'use strict';
module.exports = function repeat(ele, num) {
return Array.prototype.map.call([] + Array(num + 1), function () {
return ele;
});
};
jonschlinkert-repeat-element-f2314f3/benchmark/code/array-map-valueOf.js 0000664 0000000 0000000 00000000212 14033436213 0026312 0 ustar 00root root 0000000 0000000 'use strict';
module.exports = function repeat(ele, num) {
return Array.apply(null, Array(num)).map(String.prototype.valueOf, ele);
};
jonschlinkert-repeat-element-f2314f3/benchmark/code/current.js 0000664 0000000 0000000 00000000043 14033436213 0024506 0 ustar 00root root 0000000 0000000 module.exports = require('../..');
jonschlinkert-repeat-element-f2314f3/benchmark/code/for-concat.js 0000664 0000000 0000000 00000000240 14033436213 0025056 0 ustar 00root root 0000000 0000000 'use strict';
module.exports = function repeat(ele, num) {
var arr = [];
for (var i = 0; i < num; i++) {
arr = arr.concat(ele);
}
return arr;
};
jonschlinkert-repeat-element-f2314f3/benchmark/code/for-join-1.js 0000775 0000000 0000000 00000000225 14033436213 0024712 0 ustar 00root root 0000000 0000000 'use strict';
module.exports = function repeat(ele, num) {
var arr = [];
for (; 0 < num; num -= 1, arr[num] = ele);
num++;
return arr;
};
jonschlinkert-repeat-element-f2314f3/benchmark/code/for-join-2.js 0000664 0000000 0000000 00000000204 14033436213 0024705 0 ustar 00root root 0000000 0000000 'use strict';
module.exports = function repeat(ele, num) {
var arr = [];
for (; 0 < num; arr[--num] = ele);
return arr;
};
jonschlinkert-repeat-element-f2314f3/benchmark/code/for-length.js 0000664 0000000 0000000 00000000415 14033436213 0025074 0 ustar 00root root 0000000 0000000 'use strict';
module.exports = repeat;
function repeat(ele, num) {
if (num === 0) return [];
var res = [ele];
var len = res.length;
if (len < num) {
for (var i = num - 1 - len; i >= 0; i--) {
res[i + len] = res[i % len];
}
}
return res;
}
jonschlinkert-repeat-element-f2314f3/benchmark/code/for-new-array-1.js 0000775 0000000 0000000 00000000234 14033436213 0025660 0 ustar 00root root 0000000 0000000 module.exports = repeat;
function repeat(ele, num) {
var arr = new Array(num);
for (var i = 0; i < num; i++) {
arr[i] = ele;
}
return arr;
}
jonschlinkert-repeat-element-f2314f3/benchmark/code/for-new-array-2.js 0000664 0000000 0000000 00000000241 14033436213 0025654 0 ustar 00root root 0000000 0000000 module.exports = repeat;
function repeat(ele, num) {
var arr = new Array(num);
for (var i = num - 1; i >= 0; i--) {
arr[i] = ele;
}
return arr;
}
jonschlinkert-repeat-element-f2314f3/benchmark/code/for-push.js 0000664 0000000 0000000 00000000230 14033436213 0024565 0 ustar 00root root 0000000 0000000 'use strict';
module.exports = function repeat(ele, num) {
var arr = [];
for (var i = num; i > 0; i--) {
arr.push(ele);
}
return arr;
};
jonschlinkert-repeat-element-f2314f3/benchmark/code/new-array-map-1.js 0000664 0000000 0000000 00000000223 14033436213 0025642 0 ustar 00root root 0000000 0000000 'use strict';
module.exports = function repeat(ele, num) {
return Array.apply([], new Array(num)).map(function (nil) {
return ele;
});
};
jonschlinkert-repeat-element-f2314f3/benchmark/code/new-array-map-2.js 0000664 0000000 0000000 00000000225 14033436213 0025645 0 ustar 00root root 0000000 0000000 'use strict';
module.exports = function repeat(ele, num) {
return Array(num + 1).join(1).split('').map(function (nil) {
return ele;
});
};
jonschlinkert-repeat-element-f2314f3/benchmark/code/repeat-element.js 0000775 0000000 0000000 00000000061 14033436213 0025736 0 ustar 00root root 0000000 0000000 'use strict';
module.exports = require('../..'); jonschlinkert-repeat-element-f2314f3/benchmark/code/while-array-1.js 0000775 0000000 0000000 00000000211 14033436213 0025406 0 ustar 00root root 0000000 0000000 'use strict';
module.exports = function repeat(val, num) {
var arr = [];
while (num--) {
arr[num] = val;
}
return arr;
};
jonschlinkert-repeat-element-f2314f3/benchmark/code/while-array-2.js 0000775 0000000 0000000 00000000226 14033436213 0025415 0 ustar 00root root 0000000 0000000 'use strict';
module.exports = function repeat(val, num) {
var arr = [];
var i = 0;
while (num--) {
arr[i++] = val;
}
return arr;
};
jonschlinkert-repeat-element-f2314f3/benchmark/code/while-array-3.js 0000775 0000000 0000000 00000000263 14033436213 0025417 0 ustar 00root root 0000000 0000000 'use strict';
module.exports = function(val, num) {
return repeat(val, num, []);
};
function repeat(val, num, arr) {
while (num--) {
arr[num] = val;
}
return arr;
}
jonschlinkert-repeat-element-f2314f3/benchmark/code/while-bitwise.js 0000664 0000000 0000000 00000000351 14033436213 0025602 0 ustar 00root root 0000000 0000000
module.exports = repeat;
function repeat(ele, num) {
var arr = [ele];
var res = [];
while (num > 0) {
if (num & 1) {
res.push.apply(res, arr);
}
num >>= 1;
arr.push.apply(arr, arr);
}
return res;
}
jonschlinkert-repeat-element-f2314f3/benchmark/code/while-concat.js 0000775 0000000 0000000 00000000220 14033436213 0025401 0 ustar 00root root 0000000 0000000 'use strict';
module.exports = function repeat(ele, num) {
var res = [];
while (num--) {
res = res.concat(ele);
}
return res;
};
jonschlinkert-repeat-element-f2314f3/benchmark/code/while-exp.js 0000664 0000000 0000000 00000000254 14033436213 0024732 0 ustar 00root root 0000000 0000000 'use strict';
module.exports = function repeat(ele, num) {
var res = [ele];
while (res.length < num) {
res = res.concat(res);
}
return res.slice(0, num);
};
jonschlinkert-repeat-element-f2314f3/benchmark/code/while-new-array-1.js 0000664 0000000 0000000 00000000216 14033436213 0026177 0 ustar 00root root 0000000 0000000 module.exports = repeat;
function repeat(ele, num) {
var arr = new Array(num);
while (num--) {
arr[num] = ele;
}
return arr;
}
jonschlinkert-repeat-element-f2314f3/benchmark/code/while-new-array-2.js 0000664 0000000 0000000 00000000233 14033436213 0026177 0 ustar 00root root 0000000 0000000 module.exports = repeat;
function repeat(ele, num) {
var arr = new Array(num);
var i = 0;
while (num--) {
arr[i++] = ele;
}
return arr;
}
jonschlinkert-repeat-element-f2314f3/benchmark/code/while-push.js 0000664 0000000 0000000 00000000210 14033436213 0025105 0 ustar 00root root 0000000 0000000 'use strict';
module.exports = function repeat(ele, num) {
var arr = [];
while (num--) {
arr.push(ele);
}
return arr;
};
jonschlinkert-repeat-element-f2314f3/benchmark/code/while-stack.js 0000664 0000000 0000000 00000000345 14033436213 0025244 0 ustar 00root root 0000000 0000000 'use strict';
module.exports = function repeat(ele, num) {
var res = [ele];
var max = num;
while (num--) {
res.push.apply(res, res);
if (res.length >= max) {
break;
}
}
return res.slice(0, max);
};
jonschlinkert-repeat-element-f2314f3/benchmark/code/while-unshift.js 0000775 0000000 0000000 00000000221 14033436213 0025613 0 ustar 00root root 0000000 0000000 'use strict';
module.exports = function repeat(val, amount) {
var res = [];
while (amount--) {
res.unshift(val);
}
return res;
};
jonschlinkert-repeat-element-f2314f3/benchmark/fixtures/ 0000775 0000000 0000000 00000000000 14033436213 0023430 5 ustar 00root root 0000000 0000000 jonschlinkert-repeat-element-f2314f3/benchmark/fixtures/0.js 0000775 0000000 0000000 00000000053 14033436213 0024126 0 ustar 00root root 0000000 0000000 'use strict';
module.exports = ['afa', 0]; jonschlinkert-repeat-element-f2314f3/benchmark/fixtures/1.js 0000775 0000000 0000000 00000000053 14033436213 0024127 0 ustar 00root root 0000000 0000000 'use strict';
module.exports = ['abc', 1]; jonschlinkert-repeat-element-f2314f3/benchmark/fixtures/100.js 0000775 0000000 0000000 00000000057 14033436213 0024273 0 ustar 00root root 0000000 0000000 'use strict';
module.exports = ['fas', 100];
jonschlinkert-repeat-element-f2314f3/benchmark/fixtures/2.js 0000664 0000000 0000000 00000000053 14033436213 0024125 0 ustar 00root root 0000000 0000000 'use strict';
module.exports = ['def', 2]; jonschlinkert-repeat-element-f2314f3/benchmark/fixtures/2000.js 0000775 0000000 0000000 00000000060 14033436213 0024346 0 ustar 00root root 0000000 0000000 'use strict';
module.exports = ['lll', 2000];
jonschlinkert-repeat-element-f2314f3/benchmark/fixtures/20000.js 0000664 0000000 0000000 00000000061 14033436213 0024424 0 ustar 00root root 0000000 0000000 'use strict';
module.exports = ['lll', 20000];
jonschlinkert-repeat-element-f2314f3/benchmark/fixtures/25.js 0000775 0000000 0000000 00000000054 14033436213 0024216 0 ustar 00root root 0000000 0000000 'use strict';
module.exports = ['iai', 25]; jonschlinkert-repeat-element-f2314f3/benchmark/fixtures/250.js 0000775 0000000 0000000 00000000057 14033436213 0024301 0 ustar 00root root 0000000 0000000 'use strict';
module.exports = ['bbb', 250];
jonschlinkert-repeat-element-f2314f3/benchmark/fixtures/3.js 0000664 0000000 0000000 00000000053 14033436213 0024126 0 ustar 00root root 0000000 0000000 'use strict';
module.exports = ['ghi', 3]; jonschlinkert-repeat-element-f2314f3/benchmark/fixtures/4.js 0000664 0000000 0000000 00000000053 14033436213 0024127 0 ustar 00root root 0000000 0000000 'use strict';
module.exports = ['xyz', 4]; jonschlinkert-repeat-element-f2314f3/benchmark/fixtures/5.js 0000775 0000000 0000000 00000000053 14033436213 0024133 0 ustar 00root root 0000000 0000000 'use strict';
module.exports = ['fff', 5]; jonschlinkert-repeat-element-f2314f3/benchmark/fixtures/50.js 0000775 0000000 0000000 00000000056 14033436213 0024216 0 ustar 00root root 0000000 0000000 'use strict';
module.exports = ['xyz', 50];
jonschlinkert-repeat-element-f2314f3/benchmark/index.js 0000775 0000000 0000000 00000000336 14033436213 0023231 0 ustar 00root root 0000000 0000000 'use strict';
const Suite = require('benchmarked');
const suite = new Suite({
result: false,
fixtures: 'fixtures/{3,5,25,2000}.js',
code: 'code/{current,while-push-new-array}.js',
cwd: __dirname
});
suite.run();
jonschlinkert-repeat-element-f2314f3/benchmark/last.md 0000664 0000000 0000000 00000000427 14033436213 0023047 0 ustar 00root root 0000000 0000000 #1: 2000.js
current.js x 291,925 ops/sec ±0.66% (97 runs sampled)
#2: 25.js
current.js x 9,940,492 ops/sec ±0.72% (93 runs sampled)
#3: 3.js
current.js x 18,709,467 ops/sec ±0.97% (95 runs sampled)
#4: 5.js
current.js x 17,771,539 ops/sec ±0.77% (95 runs sampled)
jonschlinkert-repeat-element-f2314f3/index.js 0000664 0000000 0000000 00000000615 14033436213 0021274 0 ustar 00root root 0000000 0000000 /*!
* repeat-element
*
* Copyright (c) 2015-present, Jon Schlinkert.
* Licensed under the MIT license.
*/
'use strict';
module.exports = function repeat(ele, num) {
if (Array.prototype.fill) {
return new Array(num).fill(ele);
}
var arr = new Array(num);
for (var i = 0; i < num; i++) {
arr[i] = ele;
}
return arr;
};
jonschlinkert-repeat-element-f2314f3/package.json 0000664 0000000 0000000 00000001741 14033436213 0022116 0 ustar 00root root 0000000 0000000 {
"name": "repeat-element",
"description": "Create an array by repeating the given value n times.",
"version": "1.1.4",
"homepage": "https://github.com/jonschlinkert/repeat-element",
"author": "Jon Schlinkert (https://github.com/jonschlinkert)",
"repository": "jonschlinkert/repeat-element",
"bugs": {
"url": "https://github.com/jonschlinkert/repeat-element/issues"
},
"license": "MIT",
"files": [
"index.js"
],
"main": "index.js",
"engines": {
"node": ">=0.10.0"
},
"scripts": {
"test": "mocha"
},
"devDependencies": {
"benchmarked": "^2.0.0",
"chalk": "^2.4.1",
"glob": "^7.1.2",
"gulp-format-md": "^1.0.0",
"minimist": "^1.2.0",
"mocha": "^3.5.3"
},
"keywords": [
"array",
"element",
"repeat",
"string"
],
"verb": {
"toc": false,
"layout": "default",
"tasks": [
"readme"
],
"plugins": [
"gulp-format-md"
],
"lint": {
"reflinks": true
}
}
}
jonschlinkert-repeat-element-f2314f3/test.js 0000664 0000000 0000000 00000002551 14033436213 0021145 0 ustar 00root root 0000000 0000000 /*!
* repeat-element
*
* Copyright (c) 2014 Jon Schlinkert, contributors.
* Licensed under the MIT License
*/
'use strict';
require('mocha');
var fs = require('fs');
var path = require('path');
var assert = require('assert');
var argv = require('minimist')(process.argv.slice(2));
var files = fs.readdirSync('./benchmark/code');
var repeat = require('./');
var keys = Object.keys(argv);
if (keys && keys[1]) {
var lib = files.filter(function(fp) {
return keys[1] === path.basename(fp, path.extname(fp));
});
repeat = require(path.resolve('./benchmark/code/' + lib[0]));
}
it('should repeat the given string:', function() {
assert.deepEqual(repeat('a', 5), ['a', 'a', 'a', 'a', 'a']);
assert.deepEqual(repeat('a', 50), ['a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a','a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a','a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a','a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a','a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a']);
assert.deepEqual(repeat('a', 1), ['a']);
assert.deepEqual(repeat('a', 0), []);
});
it('should repeat the given object:', function() {
assert.deepEqual(repeat({a: 'b'}, 5), [{a: 'b'},{a: 'b'},{a: 'b'},{a: 'b'},{a: 'b'}]);
});
it('should repeat null:', function() {
assert.deepEqual(repeat(null, 5), [null, null, null, null, null]);
});