repeat-string
Repeat the given string n times. Fastest implementation for repeating a string.
Install with npm
npm i repeat-string --save
Install with bower
bower install repeat-string --save
Usage
Repeat the given string
the specified number
of times.
string
{String}: The string to repeatnumber
{Number}: The number of times to repeat the stringreturns
{String}: Repeated string
Example:
var repeat = require('repeat-string');
repeat('A', 5);
Benchmarks
Repeat string is significantly faster than repeating.
repeat-string.js x 16,619,408 ops/sec ±1.05% (92 runs sampled)
repeating.js x 5,991,724 ops/sec ±0.62% (98 runs sampled)
repeat-string.js x 17,284,768 ops/sec ±0.71% (94 runs sampled)
repeating.js x 6,828,993 ops/sec ±0.87% (96 runs sampled)
repeat-string.js x 16,241,986 ops/sec ±0.78% (93 runs sampled)
repeating.js x 7,281,492 ops/sec ±0.76% (95 runs sampled)
repeat-string.js x 16,447,301 ops/sec ±1.12% (96 runs sampled)
repeating.js x 8,933,633 ops/sec ±0.64% (98 runs sampled)
repeat-string.js x 16,363,515 ops/sec ±1.09% (98 runs sampled)
repeating.js x 12,164,964 ops/sec ±0.74% (98 runs sampled)
Run the benchmarks
Install dev dependencies:
npm i -d && node benchmark
Author
Jon Schlinkert
Other javascript/node.js utils
Other projects that I maintain:
License
Copyright (c) 2015 Jon Schlinkert
Released under the MIT license
This file was generated by verb on January 24, 2015.