UNPKG

3.38 kBMarkdownView Raw
1# repeat-string [![NPM version](https://badge.fury.io/js/repeat-string.svg)](http://badge.fury.io/js/repeat-string)
2
3> Repeat the given string n times. Fastest implementation for repeating a string.
4
5## Install with [npm](npmjs.org)
6
7```bash
8npm i repeat-string --save
9```
10### Install with [bower](https://github.com/bower/bower)
11
12```bash
13bower install repeat-string --save
14```
15
16## Usage
17
18### [repeat](index.js#L34)
19
20Repeat the given `string` the specified `number` of times.
21
22* `string` **{String}**: The string to repeat
23* `number` **{Number}**: The number of times to repeat the string
24* `returns` **{String}**: Repeated string
25
26**Example:**
27
28```js
29var repeat = require('repeat-string');
30repeat('A', 5);
31//=> AAAAA
32```
33
34
35
36## Benchmarks
37
38Repeat string is significantly faster than [repeating](https://github.com/sindresorhus/repeating).
39
40```bash
41#1: 2000x
42 repeating.js x 6,547,013 ops/sec ±0.55% (97 runs sampled)
43 repeat-string.js x 17,295,983 ops/sec ±0.86% (90 runs sampled)
44
45#2: 250x
46 repeating.js x 7,043,588 ops/sec ±0.84% (97 runs sampled)
47 repeat-string.js x 16,247,722 ops/sec ±0.63% (94 runs sampled)
48
49#3: 5x
50 repeating.js x 11,895,182 ops/sec ±0.63% (99 runs sampled)
51 repeat-string.js x 16,097,331 ops/sec ±0.67% (93 runs sampled)
52
53#4: 50x
54 repeating.js x 9,572,600 ops/sec ±0.57% (99 runs sampled)
55 repeat-string.js x 16,681,594 ops/sec ±0.78% (94 runs sampled)
56```
57
58**Run the benchmarks**
59
60Install dev dependencies:
61
62```bash
63npm i -d && node benchmark
64```
65
66## Author
67
68**Jon Schlinkert**
69
70+ [github/jonschlinkert](https://github.com/jonschlinkert)
71+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
72
73### Other javascript/node.js utils
74
75Other projects that I maintain:
76
77 - [assemble](https://github.com/jonschlinkert/assemble)
78 - [remarkable](https://github.com/jonschlinkert/remarkable)
79 - [less.js](https://github.com/jonschlinkert/less.js)
80 - [handlebars-helpers](https://github.com/jonschlinkert/handlebars-helpers)
81 - [verb](https://github.com/jonschlinkert/verb)
82 - [arr](https://github.com/jonschlinkert/arr)
83 - [arr-diff](https://github.com/jonschlinkert/arr-diff)
84 - [array-last](https://github.com/jonschlinkert/array-last)
85 - [array-slice](https://github.com/jonschlinkert/array-slice)
86 - [array-sum](https://github.com/jonschlinkert/array-sum)
87 - [arrayify-compact](https://github.com/jonschlinkert/arrayify-compact)
88 - [compact-object](https://github.com/jonschlinkert/compact-object)
89 - [delete](https://github.com/jonschlinkert/delete)
90 - [for-in](https://github.com/jonschlinkert/for-in)
91 - [for-own](https://github.com/jonschlinkert/for-own)
92 - [has-any](https://github.com/jonschlinkert/has-any)
93 - [has-value](https://github.com/jonschlinkert/has-value)
94 - [is-number](https://github.com/jonschlinkert/is-number)
95 - [is-plain-object](https://github.com/jonschlinkert/is-plain-object)
96 - [mixin-deep](https://github.com/jonschlinkert/mixin-deep)
97 - [mixin-object](https://github.com/jonschlinkert/mixin-object)
98 - [object-length](https://github.com/jonschlinkert/object-length)
99 - [omit-empty](https://github.com/jonschlinkert/omit-empty)
100 - [reduce-object](https://github.com/jonschlinkert/reduce-object)
101
102## License
103Copyright (c) 2015 Jon Schlinkert
104Released under the MIT license
105
106***
107
108_This file was generated by [verb](https://github.com/assemble/verb) on January 18, 2015._
\No newline at end of file