[Pkg-javascript-commits] [node-repeat-string] 01/05: New upstream version 1.6.1
Julien Puydt
julien.puydt at laposte.net
Sat Nov 25 16:20:10 UTC 2017
This is an automated email from the git hooks/post-receive script.
jpuydt-guest pushed a commit to branch master
in repository node-repeat-string.
commit 1d91a5b0076b083d2ada970af2ed1f3dd558fa14
Author: Julien Puydt <julien.puydt at laposte.net>
Date: Sat Nov 25 17:12:32 2017 +0100
New upstream version 1.6.1
---
.editorconfig | 22 -----
.eslintrc.json | 122 ---------------------------
.gitattributes | 10 ---
.gitignore | 54 ------------
.travis.yml | 12 ---
.verb.md | 19 -----
LICENSE | 35 ++++----
README.md | 114 ++++++++++++++-----------
benchmark/check.js | 37 --------
benchmark/code/add.js | 35 --------
benchmark/code/array.js | 7 --
benchmark/code/for-bitwise.js | 17 ----
benchmark/code/for-join.js | 8 --
benchmark/code/for-str-cache-2.js | 36 --------
benchmark/code/for-str-cache.js | 29 -------
benchmark/code/for-str.js | 9 --
benchmark/code/native.js | 5 --
benchmark/code/new-array-for.js | 8 --
benchmark/code/new-array-join.js | 6 --
benchmark/code/repeat-string-1.3.0.js | 29 -------
benchmark/code/repeat-string.js | 3 -
benchmark/code/repeating.js | 3 -
benchmark/code/unshift.js | 11 ---
benchmark/code/while-array-1.js | 9 --
benchmark/code/while-array-2.js | 11 ---
benchmark/code/while-array-3.js | 12 ---
benchmark/code/while-bitwise.js | 17 ----
benchmark/code/while-square-root.js | 16 ----
benchmark/code/while-str-stack.js | 14 ----
benchmark/code/while-str.js | 9 --
benchmark/code/while.js | 15 ----
benchmark/exp.js | 23 -----
benchmark/fixtures/0.js | 3 -
benchmark/fixtures/1.js | 3 -
benchmark/fixtures/100.js | 4 -
benchmark/fixtures/2.js | 3 -
benchmark/fixtures/2000.js | 4 -
benchmark/fixtures/20000.js | 4 -
benchmark/fixtures/25.js | 3 -
benchmark/fixtures/250.js | 4 -
benchmark/fixtures/3.js | 3 -
benchmark/fixtures/4.js | 3 -
benchmark/fixtures/5.js | 3 -
benchmark/fixtures/50.js | 4 -
benchmark/index.js | 12 ---
benchmark/last.md | 24 ------
benchmark/staging/fns.js | 154 ----------------------------------
benchmark/staging/fns2.js | 46 ----------
bower.json | 39 ---------
component.json | 28 -------
index.js | 12 +--
package.json | 37 +++++---
test.js | 62 --------------
53 files changed, 113 insertions(+), 1099 deletions(-)
diff --git a/.editorconfig b/.editorconfig
deleted file mode 100644
index 991900b..0000000
--- a/.editorconfig
+++ /dev/null
@@ -1,22 +0,0 @@
-# http://editorconfig.org
-root = true
-
-[*]
-indent_style = space
-end_of_line = lf
-charset = utf-8
-indent_size = 2
-trim_trailing_whitespace = true
-insert_final_newline = true
-
-[*.md]
-trim_trailing_whitespace = false
-insert_final_newline = false
-
-[test/**]
-trim_trailing_whitespace = false
-insert_final_newline = false
-
-[templates/**]
-trim_trailing_whitespace = false
-insert_final_newline = false
diff --git a/.eslintrc.json b/.eslintrc.json
deleted file mode 100644
index 948dbdb..0000000
--- a/.eslintrc.json
+++ /dev/null
@@ -1,122 +0,0 @@
-{
- "ecmaFeatures": {
- "modules": true,
- "experimentalObjectRestSpread": true
- },
-
- "env": {
- "browser": false,
- "es6": true,
- "node": true,
- "mocha": 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"]
- }
-}
diff --git a/.gitattributes b/.gitattributes
deleted file mode 100644
index 4a3f1d3..0000000
--- a/.gitattributes
+++ /dev/null
@@ -1,10 +0,0 @@
-# Enforce Unix newlines
-* text eol=lf
-
-# binaries
-*.ai binary
-*.psd binary
-*.jpg binary
-*.gif binary
-*.png binary
-*.jpeg binary
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
deleted file mode 100644
index ed2333b..0000000
--- a/.gitignore
+++ /dev/null
@@ -1,54 +0,0 @@
-# Numerous always-ignore extensions
-*.DS_Store
-*.csv
-*.dat
-*.diff
-*.err
-*.gz
-*.log
-*.orig
-*.out
-*.pid
-*.rej
-*.seed
-*.swo
-*.swp
-*.vi
-*.yo-rc.json
-*.zip
-*~
-.ruby-version
-lib-cov
-
-# OS or Editor folders
-*.esproj
-*.sublime-project
-*.sublime-workspace
-._*
-.cache
-.DS_Store
-.idea
-.project
-.settings
-.tmproj
-nbproject
-Thumbs.db
-
-# Komodo
-*.komodoproject
-.komodotools
-
-# grunt-html-validation
-validation-status.json
-validation-report.json
-
-# Vendor packages
-node_modules
-bower_components
-vendor
-
-# General folders and files to ignore
-_gh_pages
-tmp
-temp
-TODO.md
\ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 09768f0..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,12 +0,0 @@
-sudo: false
-language: node_js
-node_js:
- - "stable"
- - "5"
- - "4"
- - "0.12"
- - "0.10"
-matrix:
- fast_finish: true
- allow_failures:
- - node_js: "0.10"
diff --git a/.verb.md b/.verb.md
deleted file mode 100644
index 74f7c7e..0000000
--- a/.verb.md
+++ /dev/null
@@ -1,19 +0,0 @@
-## Usage
-
-{%= apidocs("index.js") %}
-
-## Benchmarks
-
-Repeat string is significantly faster than the native method (which is itself faster than [repeating](https://github.com/sindresorhus/repeating)):
-
-```sh
-{%= docs('benchmark/last.md') %}
-```
-
-**Run the benchmarks**
-
-Install dev dependencies:
-
-```sh
-npm i -d && node benchmark
-```
diff --git a/LICENSE b/LICENSE
index 5a9956a..39245ac 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,24 +1,21 @@
The MIT License (MIT)
-Copyright (c) 2014-2015, Jon Schlinkert.
+Copyright (c) 2014-2016, 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:
+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 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.
+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.
diff --git a/README.md b/README.md
index 975c2be..aaa5e91 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-# repeat-string [![NPM version](https://img.shields.io/npm/v/repeat-string.svg)](https://www.npmjs.com/package/repeat-string) [![Build Status](https://img.shields.io/travis/jonschlinkert/repeat-string.svg)](https://travis-ci.org/jonschlinkert/repeat-string)
+# repeat-string [![NPM version](https://img.shields.io/npm/v/repeat-string.svg?style=flat)](https://www.npmjs.com/package/repeat-string) [![NPM monthly downloads](https://img.shields.io/npm/dm/repeat-string.svg?style=flat)](https://npmjs.org/package/repeat-string) [![NPM total downloads](https://img.shields.io/npm/dt/repeat-string.svg?style=flat)](https://npmjs.org/package/repeat-string) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/repeat-string.svg?style=flat&labe [...]
> Repeat the given string n times. Fastest implementation for repeating a string.
@@ -7,7 +7,7 @@
Install with [npm](https://www.npmjs.com/):
```sh
-$ npm install repeat-string --save
+$ npm install --save repeat-string
```
## Usage
@@ -18,12 +18,6 @@ Repeat the given `string` the specified `number` of times.
**Example:**
-**Params**
-
-* `string` **{String}**: The string to repeat
-* `number` **{Number}**: The number of times to repeat the string
-* `returns` **{String}**: Repeated string
-
**Example**
```js
@@ -32,35 +26,51 @@ repeat('A', 5);
//=> AAAAA
```
+**Params**
+
+* `string` **{String}**: The string to repeat
+* `number` **{Number}**: The number of times to repeat the string
+* `returns` **{String}**: Repeated string
+
## Benchmarks
Repeat string is significantly faster than the native method (which is itself faster than [repeating](https://github.com/sindresorhus/repeating)):
```sh
-#1: 5
- native x 10,484,023 ops/sec ±1.24% (89 runs sampled)
- repeat-string x 16,189,255 ops/sec ±1.05% (91 runs sampled)
- repeating x 9,051,715 ops/sec ±1.18% (90 runs sampled)
-
-#2: 50
- native x 7,975,566 ops/sec ±1.29% (91 runs sampled)
- repeat-string x 15,317,972 ops/sec ±1.16% (87 runs sampled)
- repeating x 6,279,112 ops/sec ±1.29% (89 runs sampled)
-
-#3: 250
- native x 6,212,752 ops/sec ±1.33% (91 runs sampled)
- repeat-string x 14,565,168 ops/sec ±0.83% (93 runs sampled)
- repeating x 5,787,124 ops/sec ±1.25% (92 runs sampled)
-
-#4: 2000
- native x 4,912,163 ops/sec ±1.27% (91 runs sampled)
- repeat-string x 17,129,748 ops/sec ±1.01% (91 runs sampled)
- repeating x 4,613,043 ops/sec ±1.37% (91 runs sampled)
-
-#5: 20000
- native x 4,506,624 ops/sec ±1.33% (90 runs sampled)
- repeat-string x 14,877,672 ops/sec ±1.00% (93 runs sampled)
- repeating x 4,305,756 ops/sec ±1.36% (89 runs sampled)
+# 2x
+repeat-string █████████████████████████ (26,953,977 ops/sec)
+repeating █████████ (9,855,695 ops/sec)
+native ██████████████████ (19,453,895 ops/sec)
+
+# 3x
+repeat-string █████████████████████████ (19,445,252 ops/sec)
+repeating ███████████ (8,661,565 ops/sec)
+native ████████████████████ (16,020,598 ops/sec)
+
+# 10x
+repeat-string █████████████████████████ (23,792,521 ops/sec)
+repeating █████████ (8,571,332 ops/sec)
+native ███████████████ (14,582,955 ops/sec)
+
+# 50x
+repeat-string █████████████████████████ (23,640,179 ops/sec)
+repeating █████ (5,505,509 ops/sec)
+native ██████████ (10,085,557 ops/sec)
+
+# 250x
+repeat-string █████████████████████████ (23,489,618 ops/sec)
+repeating ████ (3,962,937 ops/sec)
+native ████████ (7,724,892 ops/sec)
+
+# 2000x
+repeat-string █████████████████████████ (20,315,172 ops/sec)
+repeating ████ (3,297,079 ops/sec)
+native ███████ (6,203,331 ops/sec)
+
+# 20000x
+repeat-string █████████████████████████ (23,382,915 ops/sec)
+repeating ███ (2,980,058 ops/sec)
+native █████ (5,578,808 ops/sec)
```
**Run the benchmarks**
@@ -71,29 +81,37 @@ Install dev dependencies:
npm i -d && node benchmark
```
-## Related projects
+## About
-[repeat-element](https://www.npmjs.com/package/repeat-element): Create an array by repeating the given value n times. | [homepage](https://github.com/jonschlinkert/repeat-element)
+### Related projects
-## Contributing
+[repeat-element](https://www.npmjs.com/package/repeat-element): Create an array by repeating the given value n times. | [homepage](https://github.com/jonschlinkert/repeat-element "Create an array by repeating the given value n times.")
-Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/repeat-string/issues/new).
+### Contributing
-## Building docs
+Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
-Generate readme and API documentation with [verb](https://github.com/verbose/verb):
+### Contributors
-```sh
-$ npm install verb && npm run docs
-```
+| **Commits** | **Contributor**<br/> |
+| --- | --- |
+| 51 | [jonschlinkert](https://github.com/jonschlinkert) |
+| 2 | [LinusU](https://github.com/LinusU) |
+| 2 | [tbusser](https://github.com/tbusser) |
+| 1 | [doowb](https://github.com/doowb) |
+| 1 | [wooorm](https://github.com/wooorm) |
+
+### Building docs
+
+_(This document was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme) (a [verb](https://github.com/verbose/verb) generator), please don't edit the readme directly. Any changes to the readme must be made in [.verb.md](.verb.md).)_
-Or, if [verb](https://github.com/verbose/verb) is installed globally:
+To generate the readme and API documentation with [verb](https://github.com/verbose/verb):
```sh
-$ verb
+$ npm install -g verb verb-generate-readme && verb
```
-## Running tests
+### Running tests
Install dev dependencies:
@@ -101,18 +119,18 @@ Install dev dependencies:
$ npm install -d && npm test
```
-## Author
+### Author
**Jon Schlinkert**
* [github/jonschlinkert](https://github.com/jonschlinkert)
* [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
-## License
+### License
-Copyright © 2016 [Jon Schlinkert](http://github.com/jonschlinkert)
+Copyright © 2016, [Jon Schlinkert](http://github.com/jonschlinkert).
Released under the [MIT license](https://github.com/jonschlinkert/repeat-string/blob/master/LICENSE).
***
-_This file was generated by [verb](https://github.com/verbose/verb), v0.9.0, on February 29, 2016._
\ No newline at end of file
+_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.2.0, on October 23, 2016._
\ No newline at end of file
diff --git a/benchmark/check.js b/benchmark/check.js
deleted file mode 100755
index 5d6a3af..0000000
--- a/benchmark/check.js
+++ /dev/null
@@ -1,37 +0,0 @@
-'use strict';
-
-var chalk = require('chalk');
-var path = require('path');
-var glob = require('glob');
-
-/**
- * Sanity check. Run to ensure that all fns return the same result.
- */
-
-var fixtures = glob.sync(__dirname + '/fixtures/*.js').map(require);
-var expected = [0, 3, 300, 6, 6000, 60000, 75, 750, 9, 12, 15, 150];
-
-glob.sync(__dirname + '/code/*.js').forEach(function (fp) {
- var fn = require(path.resolve(__dirname, 'code', fp));
- var name = path.basename(fp, path.extname(fp));
- var problems = [];
-
- fixtures.forEach(function (fixture, idx) {
- var 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) {
- var str = item[0] + ' gave ' + item[1] + ', expected ' + item[2];
- console.log((idx === arr.length - 1 ? ' ┗ ' : ' ┣ ') + chalk.red(str));
- });
- }
-});
diff --git a/benchmark/code/add.js b/benchmark/code/add.js
deleted file mode 100644
index 8630c58..0000000
--- a/benchmark/code/add.js
+++ /dev/null
@@ -1,35 +0,0 @@
-module.exports = repeat;
-
-function repeat(str, num) {
- if (typeof str !== 'string') {
- throw new TypeError('repeat-string expects a string.');
- }
-
- var len = str.length;
- var max = len * num;
-
- if (num === 1 || len === max) return str;
- if (num === 2) return str + str;
-
- if (cache !== str || typeof cache === 'undefined') {
- res = cache = str;
- num--;
- }
-
- var rlen = res.length;
- while (max > rlen && num > 0) {
- if (num & 1) {
- res += str;
- }
- num >>= 1;
- str += str;
- }
- return res.substr(0, max);
-}
-
-/**
- * Results cache
- */
-
-var res = '';
-var cache;
diff --git a/benchmark/code/array.js b/benchmark/code/array.js
deleted file mode 100644
index f0627ad..0000000
--- a/benchmark/code/array.js
+++ /dev/null
@@ -1,7 +0,0 @@
-'use strict';
-
-module.exports = function repeat(str, num) {
- var arr = [];
- arr[num] = '';
- return arr.join(str);
-};
\ No newline at end of file
diff --git a/benchmark/code/for-bitwise.js b/benchmark/code/for-bitwise.js
deleted file mode 100644
index a74e3c0..0000000
--- a/benchmark/code/for-bitwise.js
+++ /dev/null
@@ -1,17 +0,0 @@
-'use strict';
-
-module.exports = repeat;
-
-function repeat(str, num) {
- var res = '';
-
- for (;;) {
- if (num & 1) {
- res += str;
- }
- num >>>= 1;
- if (!num) return res;
- str += str;
- }
- return res;
-}
\ No newline at end of file
diff --git a/benchmark/code/for-join.js b/benchmark/code/for-join.js
deleted file mode 100755
index 523b51d..0000000
--- a/benchmark/code/for-join.js
+++ /dev/null
@@ -1,8 +0,0 @@
-'use strict';
-
-module.exports = function repeat(val, num) {
- num += 1;
- var arr;
- for (arr = []; 0 < num; num -= 1, arr[num] = '');
- return arr.join(val);
-};
diff --git a/benchmark/code/for-str-cache-2.js b/benchmark/code/for-str-cache-2.js
deleted file mode 100755
index e66d605..0000000
--- a/benchmark/code/for-str-cache-2.js
+++ /dev/null
@@ -1,36 +0,0 @@
-'use strict';
-
-module.exports = repeat;
-
-var res = '';
-var cache;
-
-function repeat(str, num) {
- cache = cache || str;
- if (cache !== str) {
- res = '';
- cache = str;
- }
-
- var max = (str.length * num);
- var i = 0;
-
- if (res.length >= max) {
- return res.slice(0, max);
- }
-
- for (; num > 0; i++) {
- if (num & 1) {
- res += str;
- }
-
- if (res.length >= max) {
- return res.slice(0, max);
- }
-
- num >>= 1;
- str += str;
- }
-
- return res.slice(0, max);
-}
diff --git a/benchmark/code/for-str-cache.js b/benchmark/code/for-str-cache.js
deleted file mode 100755
index 977883b..0000000
--- a/benchmark/code/for-str-cache.js
+++ /dev/null
@@ -1,29 +0,0 @@
-'use strict';
-
-var res = '';
-var cache;
-
-module.exports = function repeat(str, count) {
- var max = (str.length * count);
- var i = 0;
-
- cache = cache || str;
- if (cache !== str) {
- res = '';
- cache = str;
- }
-
- if (res.length >= max) {
- return res.slice(0, max);
- }
-
- for (; i < count; i++) {
- res += str;
- if (res.length >= max) {
- return res.slice(0, max);
- }
- }
-
- return res.slice(0, max);
-};
-
diff --git a/benchmark/code/for-str.js b/benchmark/code/for-str.js
deleted file mode 100755
index a84cd11..0000000
--- a/benchmark/code/for-str.js
+++ /dev/null
@@ -1,9 +0,0 @@
-'use strict';
-
-module.exports = function repeat(val, amount) {
- var res = '';
- for (var i = 0; i < amount; i++) {
- res += val;
- }
- return res;
-};
diff --git a/benchmark/code/native.js b/benchmark/code/native.js
deleted file mode 100644
index 7629dd8..0000000
--- a/benchmark/code/native.js
+++ /dev/null
@@ -1,5 +0,0 @@
-'use strict';
-
-module.exports = function repeat(str, num) {
- return str.repeat(num);
-};
diff --git a/benchmark/code/new-array-for.js b/benchmark/code/new-array-for.js
deleted file mode 100755
index f0bd1a6..0000000
--- a/benchmark/code/new-array-for.js
+++ /dev/null
@@ -1,8 +0,0 @@
-'use strict';
-
-module.exports = function repeat(val, amount) {
- for (var i = 0, res = new Array(amount); i < amount + 1;) {
- res[i++] = '';
- }
- return res.join(val);
-};
diff --git a/benchmark/code/new-array-join.js b/benchmark/code/new-array-join.js
deleted file mode 100755
index 885dd8e..0000000
--- a/benchmark/code/new-array-join.js
+++ /dev/null
@@ -1,6 +0,0 @@
-'use strict';
-
-module.exports = function repeat(val, num) {
- if (arguments.length === 1) return '';
- return new Array(num + 1).join(val);
-};
diff --git a/benchmark/code/repeat-string-1.3.0.js b/benchmark/code/repeat-string-1.3.0.js
deleted file mode 100755
index e28b72a..0000000
--- a/benchmark/code/repeat-string-1.3.0.js
+++ /dev/null
@@ -1,29 +0,0 @@
-'use strict';
-
-var res = '';
-var cache;
-
-module.exports = function repeat(str, num) {
- var max = str.length * num;
-
- cache = cache || str;
- if (cache !== str) {
- res = '';
- cache = str;
- }
-
- while (num > 0 && max > res.length) {
- if (num & 1) {
- res += str;
- }
-
- if (max <= res.length) {
- return res.substr(0, max);
- }
-
- num >>= 1;
- str += str;
- }
-
- return res.substr(0, max);
-};
diff --git a/benchmark/code/repeat-string.js b/benchmark/code/repeat-string.js
deleted file mode 100755
index 0f85e82..0000000
--- a/benchmark/code/repeat-string.js
+++ /dev/null
@@ -1,3 +0,0 @@
-'use strict';
-
-module.exports = require('../..');
\ No newline at end of file
diff --git a/benchmark/code/repeating.js b/benchmark/code/repeating.js
deleted file mode 100755
index 077d10b..0000000
--- a/benchmark/code/repeating.js
+++ /dev/null
@@ -1,3 +0,0 @@
-'use strict';
-
-module.exports = require('repeating');
diff --git a/benchmark/code/unshift.js b/benchmark/code/unshift.js
deleted file mode 100755
index 8ca5b71..0000000
--- a/benchmark/code/unshift.js
+++ /dev/null
@@ -1,11 +0,0 @@
-'use strict';
-
-module.exports = function repeat(val, amount) {
- var res = [];
-
- while (amount--) {
- res.unshift(val);
- }
-
- return res.join('');
-};
diff --git a/benchmark/code/while-array-1.js b/benchmark/code/while-array-1.js
deleted file mode 100755
index 9f49c77..0000000
--- a/benchmark/code/while-array-1.js
+++ /dev/null
@@ -1,9 +0,0 @@
-'use strict';
-
-module.exports = function repeat(val, num) {
- var arr = [];
- while (num--) {
- arr[num] = val;
- }
- return arr.join('');
-};
\ No newline at end of file
diff --git a/benchmark/code/while-array-2.js b/benchmark/code/while-array-2.js
deleted file mode 100755
index 72e0dcb..0000000
--- a/benchmark/code/while-array-2.js
+++ /dev/null
@@ -1,11 +0,0 @@
-'use strict';
-
-module.exports = function repeat(val, num) {
- var arr = [];
- var i = 0;
-
- while (num--) {
- arr[i++] = val;
- }
- return arr.join('');
-};
\ No newline at end of file
diff --git a/benchmark/code/while-array-3.js b/benchmark/code/while-array-3.js
deleted file mode 100755
index 6a6acff..0000000
--- a/benchmark/code/while-array-3.js
+++ /dev/null
@@ -1,12 +0,0 @@
-'use strict';
-
-module.exports = function(val, num) {
- return repeat(val, num, []).join('');
-};
-
-function repeat(val, num, arr) {
- while (num--) {
- arr[num] = val;
- }
- return arr;
-}
\ No newline at end of file
diff --git a/benchmark/code/while-bitwise.js b/benchmark/code/while-bitwise.js
deleted file mode 100644
index 8f71249..0000000
--- a/benchmark/code/while-bitwise.js
+++ /dev/null
@@ -1,17 +0,0 @@
-'use strict';
-
-module.exports = repeat;
-
-function repeat(str, num) {
- var res = '';
-
- while (num > 0) {
- if (num & 1) {
- res += str;
- }
- num >>>= 1;
- if (!num) return res;
- str += str;
- }
- return res;
-}
\ No newline at end of file
diff --git a/benchmark/code/while-square-root.js b/benchmark/code/while-square-root.js
deleted file mode 100644
index 9f18f44..0000000
--- a/benchmark/code/while-square-root.js
+++ /dev/null
@@ -1,16 +0,0 @@
-'use strict';
-
-module.exports = function repeat(str, num) {
- var max = str.length * num;
- num = Math.ceil(Math.sqrt(num));
-
- while (num--) {
- str += str;
-
- if (str.length > max) {
- break;
- }
- }
-
- return str.slice(0, max);
-};
\ No newline at end of file
diff --git a/benchmark/code/while-str-stack.js b/benchmark/code/while-str-stack.js
deleted file mode 100644
index b7f7d2f..0000000
--- a/benchmark/code/while-str-stack.js
+++ /dev/null
@@ -1,14 +0,0 @@
-'use strict';
-
-module.exports = function repeat(str, num) {
- var max = str.length * num;
-
- while (num--) {
- str += str;
- if (str.length >= max) {
- break;
- }
- }
-
- return str.slice(0, max);
-};
\ No newline at end of file
diff --git a/benchmark/code/while-str.js b/benchmark/code/while-str.js
deleted file mode 100755
index 4138f11..0000000
--- a/benchmark/code/while-str.js
+++ /dev/null
@@ -1,9 +0,0 @@
-'use strict';
-
-module.exports = function repeat(val, amount) {
- var str = '';
- while (amount--) {
- str += val;
- }
- return str;
-};
\ No newline at end of file
diff --git a/benchmark/code/while.js b/benchmark/code/while.js
deleted file mode 100755
index 5a75b27..0000000
--- a/benchmark/code/while.js
+++ /dev/null
@@ -1,15 +0,0 @@
-'use strict';
-
-module.exports = function repeat(str, count) {
- var res = '';
-
- while (count > 0) {
- if (count & 1) {
- res += str;
- }
- count >>= 1;
- str += str;
- }
-
- return res;
-};
diff --git a/benchmark/exp.js b/benchmark/exp.js
deleted file mode 100755
index c9da78d..0000000
--- a/benchmark/exp.js
+++ /dev/null
@@ -1,23 +0,0 @@
-'use resict';
-
-// var chalk = require('chalk');
-// var path = require('path');
-// var glob = require('glob');
-
-// glob.sync(__dirname + '/code/*.js').forEach(function(fp) {
-// var pad = require(path.resolve(__dirname, 'code', fp));
-// console.log(pad('1', 3));
-// });
-
-function repeat(str, num) {
- var max = str.length * num;
- num = Math.ceil(Math.sqrt(num));
-
- while (num--) {
- str += str;
- }
-
- return str.slice(0, max);
-}
-
-console.log(repeat('foo', 6))
\ No newline at end of file
diff --git a/benchmark/fixtures/0.js b/benchmark/fixtures/0.js
deleted file mode 100755
index 53f16e3..0000000
--- a/benchmark/fixtures/0.js
+++ /dev/null
@@ -1,3 +0,0 @@
-'use strict';
-
-module.exports = ['afa', 0];
\ No newline at end of file
diff --git a/benchmark/fixtures/1.js b/benchmark/fixtures/1.js
deleted file mode 100755
index 01a8a3c..0000000
--- a/benchmark/fixtures/1.js
+++ /dev/null
@@ -1,3 +0,0 @@
-'use strict';
-
-module.exports = ['abc', 1];
\ No newline at end of file
diff --git a/benchmark/fixtures/100.js b/benchmark/fixtures/100.js
deleted file mode 100755
index 87ea1f0..0000000
--- a/benchmark/fixtures/100.js
+++ /dev/null
@@ -1,4 +0,0 @@
-'use strict';
-
-module.exports = ['fas', 100];
-
diff --git a/benchmark/fixtures/2.js b/benchmark/fixtures/2.js
deleted file mode 100644
index a0608a3..0000000
--- a/benchmark/fixtures/2.js
+++ /dev/null
@@ -1,3 +0,0 @@
-'use strict';
-
-module.exports = ['def', 2];
\ No newline at end of file
diff --git a/benchmark/fixtures/2000.js b/benchmark/fixtures/2000.js
deleted file mode 100755
index 2769f08..0000000
--- a/benchmark/fixtures/2000.js
+++ /dev/null
@@ -1,4 +0,0 @@
-'use strict';
-
-module.exports = ['lll', 2000];
-
diff --git a/benchmark/fixtures/20000.js b/benchmark/fixtures/20000.js
deleted file mode 100644
index fcc0285..0000000
--- a/benchmark/fixtures/20000.js
+++ /dev/null
@@ -1,4 +0,0 @@
-'use strict';
-
-module.exports = ['lll', 20000];
-
diff --git a/benchmark/fixtures/25.js b/benchmark/fixtures/25.js
deleted file mode 100755
index aad5d68..0000000
--- a/benchmark/fixtures/25.js
+++ /dev/null
@@ -1,3 +0,0 @@
-'use strict';
-
-module.exports = ['iai', 25];
\ No newline at end of file
diff --git a/benchmark/fixtures/250.js b/benchmark/fixtures/250.js
deleted file mode 100755
index 6751c83..0000000
--- a/benchmark/fixtures/250.js
+++ /dev/null
@@ -1,4 +0,0 @@
-'use strict';
-
-module.exports = ['bbb', 250];
-
diff --git a/benchmark/fixtures/3.js b/benchmark/fixtures/3.js
deleted file mode 100644
index 3d143fb..0000000
--- a/benchmark/fixtures/3.js
+++ /dev/null
@@ -1,3 +0,0 @@
-'use strict';
-
-module.exports = ['ghi', 3];
\ No newline at end of file
diff --git a/benchmark/fixtures/4.js b/benchmark/fixtures/4.js
deleted file mode 100644
index ad88e61..0000000
--- a/benchmark/fixtures/4.js
+++ /dev/null
@@ -1,3 +0,0 @@
-'use strict';
-
-module.exports = ['xyz', 4];
\ No newline at end of file
diff --git a/benchmark/fixtures/5.js b/benchmark/fixtures/5.js
deleted file mode 100755
index 6c32928..0000000
--- a/benchmark/fixtures/5.js
+++ /dev/null
@@ -1,3 +0,0 @@
-'use strict';
-
-module.exports = ['fff', 5];
\ No newline at end of file
diff --git a/benchmark/fixtures/50.js b/benchmark/fixtures/50.js
deleted file mode 100755
index 09b9ca2..0000000
--- a/benchmark/fixtures/50.js
+++ /dev/null
@@ -1,4 +0,0 @@
-'use strict';
-
-module.exports = ['xyz', 50];
-
diff --git a/benchmark/index.js b/benchmark/index.js
deleted file mode 100755
index d3c2b84..0000000
--- a/benchmark/index.js
+++ /dev/null
@@ -1,12 +0,0 @@
-'use strict';
-
-var Suite = require('benchmarked');
-
-var suite = new Suite({
- result: false,
- fixtures: 'fixtures/{5,50,250,2000,20000}.js',
- add: 'code/{repeat-string,repeating,native}.js',
- cwd: __dirname
-});
-
-suite.run();
diff --git a/benchmark/last.md b/benchmark/last.md
deleted file mode 100644
index 30f4e4c..0000000
--- a/benchmark/last.md
+++ /dev/null
@@ -1,24 +0,0 @@
-#1: 5
- native x 10,484,023 ops/sec ±1.24% (89 runs sampled)
- repeat-string x 16,189,255 ops/sec ±1.05% (91 runs sampled)
- repeating x 9,051,715 ops/sec ±1.18% (90 runs sampled)
-
-#2: 50
- native x 7,975,566 ops/sec ±1.29% (91 runs sampled)
- repeat-string x 15,317,972 ops/sec ±1.16% (87 runs sampled)
- repeating x 6,279,112 ops/sec ±1.29% (89 runs sampled)
-
-#3: 250
- native x 6,212,752 ops/sec ±1.33% (91 runs sampled)
- repeat-string x 14,565,168 ops/sec ±0.83% (93 runs sampled)
- repeating x 5,787,124 ops/sec ±1.25% (92 runs sampled)
-
-#4: 2000
- native x 4,912,163 ops/sec ±1.27% (91 runs sampled)
- repeat-string x 17,129,748 ops/sec ±1.01% (91 runs sampled)
- repeating x 4,613,043 ops/sec ±1.37% (91 runs sampled)
-
-#5: 20000
- native x 4,506,624 ops/sec ±1.33% (90 runs sampled)
- repeat-string x 14,877,672 ops/sec ±1.00% (93 runs sampled)
- repeating x 4,305,756 ops/sec ±1.36% (89 runs sampled)
\ No newline at end of file
diff --git a/benchmark/staging/fns.js b/benchmark/staging/fns.js
deleted file mode 100755
index bdfd010..0000000
--- a/benchmark/staging/fns.js
+++ /dev/null
@@ -1,154 +0,0 @@
-/**
- * Pad a number with leading zeros to "pad" places:
- *
- * @param number: The number to pad
- * @param pad: The maximum number of leading zeros
- */
-
-
-
-// http://jsperf.com/ways-to-0-pad-a-number/19
-function padNumberLoop(val, amount) {
- var res = '' + val;
-
- while (res.length < amount) {
- res = '0' + res;
- }
- return res;
-}
-
-// padStr is the zero-pad string, e.g.: "0000"
-// http://jsperf.com/ways-to-0-pad-a-number/19
-function padNumberString(number, padStr) {
- var len = padStr.length;
- number = number.toString();
- return number.length >= len ? number : (padStr + number).slice(-len);
-}
-
-
-
-function pad(number, amount) {
- var res = '' + number;
- var len = res.length;
- while (len < amount) {
- res.unshift(0);
- }
- return res.join('');
-}
-
-function pad(number, amount) {
- var res = '' + number;
- var len = res.length;
- var str = '';
-
- while (len < amount) {
- str += '0';
- }
- return str + res;
-}
-
-function pad(number, amount) {
- var res = '' + number;
- var len = res.length;
-
- while (len < amount) {
- res = '0' + res;
- }
-
- return res;
-}
-
-
-// http://jsperf.com/ways-to-0-pad-a-number/19
-function padWhile(num, count) {
- var pad = count - (num + '').length;
- while (--pad > -1) {
- num = '0' + num;
- }
- return num;
-};
-
-// http://jsperf.com/ways-to-0-pad-a-number/19
-String.prototype.padLeft = function(ch, len) {
- return this.length >= len ? this : (ch + this).padLeft(ch, len)
-}
-
-// http://twitter.com/cowboy/status/15344233981
-// http://jsperf.com/pad-number/3
-function pad(n, d) {
- return Array(Math.max(0, d - (n + '').length + 1)).join(0) + n;
-};
-
-
-
-// http://jsperf.com/pad-number/3
-function pad4(n, d) {
- return ('00000000000000' + n).slice(-d);
-}
-
-
-/**
- * http://jsperf.com/string-padding-methods
- */
-
-String.prototype.lpad = function(padString, length) {
- var str = this;
- while (str.length < length) {
- str = padString + str;
- }
- return str;
-};
-
-String.prototype.rpad = function(padString, length) {
- var str = this;
- while (str.length < length) {
- str = str + padString;
- }
- return str;
-};
-
-function padLeft(str, padString, length) {
- while (str.length < length) {
- str = padString + str;
- }
- return str;
-};
-
-// #1 tied for fastest
-function padRight(str, padString, length) {
- while (str.length < length) {
- str = str + padString;
- }
- return str;
-};
-
-// #1 tied for fastest
-function padString(str, padString, length, left) {
- while (str.length < length) {
- str = left ? str + padString : padString + str;
- }
- return str;
-};
-
-function padArray(str, padString, length, left) {
- return (left ? str : '') + (new Array(length - str.length).join(padString)) + (left ? '' : str);
-}
-
-
-function padArrayLeft(str, padString, length) {
- return str + (new Array(length - str.length).join(padString));
-};
-
-function padArrayRight(str, padString, length) {
- return new Array(length - str.length).join(padString) + str;
-};
-
-
-function pad(val, len) {
- var zeros = '0000000000000000000000000000000000000000000000000000000000000000';
- return zeros.substr(0, len) + val;
-}
-
-function pad(val, amount) {
- return ('0000000000000000' + val).slice(-amount);
-}
\ No newline at end of file
diff --git a/benchmark/staging/fns2.js b/benchmark/staging/fns2.js
deleted file mode 100755
index 89c4ce9..0000000
--- a/benchmark/staging/fns2.js
+++ /dev/null
@@ -1,46 +0,0 @@
-var zeros = '0000000000000000';
-
-// ===Method 1===:
-var str = 'test';
-// zerosding length = zeros.length
-zeros.length
-//=> 16
-
-// zeros-left
-str + zeros.substr(str.length);
-//=> 'test000000000000'
-
-// zeros-left
-zeros.substr(str.length) + str;
-//=> '000000000000test'
-
-// ===Method 2 AND 3===:
-
-var str = "test";
-(zeros + str).slice(-16)
-//=> '000000000000test'
-
-// equiv to:
-// speed tests http://jsperf.com/zerosding6000
-var str = "test";
-(zeros + str).substr(-16)
-//=> '000000000000test'
-
-//zerosding right
-var str = "test";
-(str + zeros).substr(0, 16)
-//=> 'test000000000000'
-
-var str = "test";
-(str + zeros).slice(0, 16)
-//=> 'test000000000000'
-
-
-var str = "test";
-(str + zeros).slice(-16)
-//=> '0000000000000000'
-
-var str = "test";
-(str + zeros).substr(-16)
-
-//=> '0000000000000000'
\ No newline at end of file
diff --git a/bower.json b/bower.json
deleted file mode 100644
index a433a35..0000000
--- a/bower.json
+++ /dev/null
@@ -1,39 +0,0 @@
-{
- "name": "repeat-string",
- "description": "Repeat the given string n times. Fastest implementation for repeating a string.",
- "repository": "jonschlinkert/repeat-string",
- "license": "MIT",
- "homepage": "https://github.com/jonschlinkert/repeat-string",
- "authors": [
- "Jon Schlinkert (http://github.com/jonschlinkert)"
- ],
- "main": [
- "index.js"
- ],
- "devDependencies": {
- "benchmarked": "^0.1.5",
- "chalk": "^1.1.1",
- "glob": "^7.0.0",
- "gulp-format-md": "^0.1.7",
- "mocha": "^2.4.5",
- "repeating": "^2.0.0",
- "should": "^8.2.2"
- },
- "keywords": [
- "fast",
- "fastest",
- "fill",
- "left",
- "left-pad",
- "multiple",
- "pad",
- "padding",
- "repeat",
- "repeating",
- "repetition",
- "right",
- "right-pad",
- "string",
- "times"
- ]
-}
\ No newline at end of file
diff --git a/component.json b/component.json
deleted file mode 100644
index 014bdff..0000000
--- a/component.json
+++ /dev/null
@@ -1,28 +0,0 @@
-{
- "name": "repeat-string",
- "description": "Repeat the given string n times. Fastest implementation for repeating a string.",
- "version": "1.5.0",
- "repository": "https://github.com/jonschlinkert/repeat-string",
- "license": "MIT",
- "main": "index.js",
- "scripts": [
- "index.js"
- ],
- "keywords": [
- "fast",
- "fastest",
- "fill",
- "left",
- "left-pad",
- "multiple",
- "pad",
- "padding",
- "repetition",
- "repeat",
- "repeating",
- "right",
- "right-pad",
- "string",
- "times"
- ]
-}
diff --git a/index.js b/index.js
index 496c6db..4459afd 100644
--- a/index.js
+++ b/index.js
@@ -40,7 +40,7 @@ module.exports = repeat;
function repeat(str, num) {
if (typeof str !== 'string') {
- throw new TypeError('repeat-string expects a string.');
+ throw new TypeError('expected a string');
}
// cover common, quick use cases
@@ -51,18 +51,20 @@ function repeat(str, num) {
if (cache !== str || typeof cache === 'undefined') {
cache = str;
res = '';
+ } else if (res.length >= max) {
+ return res.substr(0, max);
}
- while (max > res.length && num > 0) {
+ while (max > res.length && num > 1) {
if (num & 1) {
res += str;
}
num >>= 1;
- if (!num) break;
str += str;
}
- return res.substr(0, max);
+ res += str;
+ res = res.substr(0, max);
+ return res;
}
-
diff --git a/package.json b/package.json
index 5024292..09f8892 100644
--- a/package.json
+++ b/package.json
@@ -1,9 +1,16 @@
{
"name": "repeat-string",
"description": "Repeat the given string n times. Fastest implementation for repeating a string.",
- "version": "1.5.4",
+ "version": "1.6.1",
"homepage": "https://github.com/jonschlinkert/repeat-string",
"author": "Jon Schlinkert (http://github.com/jonschlinkert)",
+ "contributors": [
+ "Brian Woodward <brian.woodward at gmail.com> (https://github.com/doowb)",
+ "Jon Schlinkert <jon.schlinkert at sellside.com> (http://twitter.com/jonschlinkert)",
+ "Linus Unnebäck <linus at folkdatorn.se> (http://linus.unnebäck.se)",
+ "Thijs Busser <tbusser at gmail.com> (http://tbusser.net)",
+ "Titus <tituswormer at gmail.com> (wooorm.com)"
+ ],
"repository": "jonschlinkert/repeat-string",
"bugs": {
"url": "https://github.com/jonschlinkert/repeat-string/issues"
@@ -20,13 +27,14 @@
"test": "mocha"
},
"devDependencies": {
- "benchmarked": "^0.1.5",
- "chalk": "^1.1.1",
- "glob": "^7.0.0",
- "gulp-format-md": "^0.1.7",
- "mocha": "*",
- "repeating": "^2.0.0",
- "should": "*"
+ "ansi-cyan": "^0.1.1",
+ "benchmarked": "^0.2.5",
+ "gulp-format-md": "^0.1.11",
+ "isobject": "^2.1.0",
+ "mocha": "^3.1.2",
+ "repeating": "^3.0.0",
+ "text-table": "^0.2.0",
+ "yargs-parser": "^4.0.2"
},
"keywords": [
"fast",
@@ -46,11 +54,6 @@
"times"
],
"verb": {
- "related": {
- "list": [
- "repeat-element"
- ]
- },
"toc": false,
"layout": "default",
"tasks": [
@@ -59,6 +62,14 @@
"plugins": [
"gulp-format-md"
],
+ "related": {
+ "list": [
+ "repeat-element"
+ ]
+ },
+ "helpers": [
+ "./benchmark/helper.js"
+ ],
"reflinks": [
"verb"
]
diff --git a/test.js b/test.js
deleted file mode 100644
index 001bf6e..0000000
--- a/test.js
+++ /dev/null
@@ -1,62 +0,0 @@
-/*!
- * repeat-string <https://github.com/jonschlinkert/repeat-string>
- *
- * Copyright (c) 2014-2015, Jon Schlinkert.
- * Licensed under the MIT License.
- */
-
-'use strict';
-
-require('mocha');
-require('should');
-var repeat = require('./');
-
-describe('repeat', function() {
- it('should return an empty string when a number is not given:', function() {
- repeat('a').should.equal('');
- });
-
- it('should return an empty string when zero or null is given as the number:', function() {
- repeat('', 0).should.equal('');
- repeat('a', 0).should.equal('');
- repeat('', null).should.equal('');
- repeat('a', null).should.equal('');
- });
-
- it('should repeat the given string n times', function() {
- repeat(' ', 0).should.equal('');
- repeat('a', 0).should.equal('');
- repeat('a', 1).should.equal('a');
- repeat('a', 2).should.equal('aa');
- repeat('a', 3).should.equal('aaa');
- repeat(' ', 3).should.equal(' ');
- repeat('a ', 3).should.equal('a a a ');
- repeat('a', 10).should.equal('aaaaaaaaaa');
- repeat('b ', 10).should.equal('b b b b b b b b b b ');
- repeat('a ', 10).should.equal('a a a a a a a a a a ');
- repeat('abc ', 25).should.equal('abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc ');
- });
-
- it('should allow the multiplier to be a string:', function() {
- repeat('a', '0').should.equal('');
- repeat('a', '1').should.equal('a');
- repeat('a', '2').should.equal('aa');
- repeat('a', '10').should.equal('aaaaaaaaaa');
- repeat('b ', '10').should.equal('b b b b b b b b b b ');
- repeat('a ', '10').should.equal('a a a a a a a a a a ');
- });
-
- it('should cache strings until the string changes:', function() {
- repeat('a', '5').should.equal('aaaaa');
- repeat('b ', '5').should.equal('b b b b b ');
- repeat('a ', '5').should.equal('a a a a a ');
- repeat('c ', '5').should.equal('c c c c c ');
- repeat('a ', '5').should.equal('a a a a a ');
- repeat('b ', '5').should.equal('b b b b b ');
- });
-
- it('should throw an error when no string is given:', function() {
- (function() {repeat(10); }).should.throw('repeat-string expects a string.');
- (function() {repeat(null); }).should.throw('repeat-string expects a string.');
- });
-});
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-repeat-string.git
More information about the Pkg-javascript-commits
mailing list