Repeat the given string n times. Fastest implementation for repeating a string (2x faster than the native method)
Installations
npm install repeat-string
Releases
Unable to fetch releases
Developer
Developer Guide
Module System
CommonJS
Min. Node Version
>=0.10
Typescript Support
No
Node Version
6.7.0
NPM Version
3.10.3
Statistics
49 Stars
70 Commits
17 Forks
6 Watching
1 Branches
5 Contributors
Updated on 06 Feb 2024
Bundle Size
454.00 B
Minified
299.00 B
Minified + Gzipped
Languages
JavaScript (100%)
Total Downloads
Cumulative downloads
Total Downloads
5,284,152,596
Last day
-4.6%
4,093,956
Compared to previous day
Last week
5.2%
23,586,054
Compared to previous week
Last month
31.8%
87,973,922
Compared to previous month
Last year
-7.7%
853,388,156
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
repeat-string
Repeat the given string n times. Fastest implementation for repeating a string.
Install
Install with npm:
1$ npm install --save repeat-string
Usage
repeat
Repeat the given string
the specified number
of times.
Example:
Example
1var repeat = require('repeat-string'); 2repeat('A', 5); 3//=> AAAAA
Params
string
{String}: The string to repeatnumber
{Number}: The number of times to repeat the stringreturns
{String}: Repeated string
Benchmarks
Repeat string is significantly faster than the native method (which is itself faster than repeating):
1# 2x 2repeat-string █████████████████████████ (26,953,977 ops/sec) 3repeating █████████ (9,855,695 ops/sec) 4native ██████████████████ (19,453,895 ops/sec) 5 6# 3x 7repeat-string █████████████████████████ (19,445,252 ops/sec) 8repeating ███████████ (8,661,565 ops/sec) 9native ████████████████████ (16,020,598 ops/sec) 10 11# 10x 12repeat-string █████████████████████████ (23,792,521 ops/sec) 13repeating █████████ (8,571,332 ops/sec) 14native ███████████████ (14,582,955 ops/sec) 15 16# 50x 17repeat-string █████████████████████████ (23,640,179 ops/sec) 18repeating █████ (5,505,509 ops/sec) 19native ██████████ (10,085,557 ops/sec) 20 21# 250x 22repeat-string █████████████████████████ (23,489,618 ops/sec) 23repeating ████ (3,962,937 ops/sec) 24native ████████ (7,724,892 ops/sec) 25 26# 2000x 27repeat-string █████████████████████████ (20,315,172 ops/sec) 28repeating ████ (3,297,079 ops/sec) 29native ███████ (6,203,331 ops/sec) 30 31# 20000x 32repeat-string █████████████████████████ (23,382,915 ops/sec) 33repeating ███ (2,980,058 ops/sec) 34native █████ (5,578,808 ops/sec)
Run the benchmarks
Install dev dependencies:
1npm i -d && node benchmark
About
Related projects
repeat-element: Create an array by repeating the given value n times. | homepage
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Please read the contributing guide for avice on opening issues, pull requests, and coding standards.
Contributors
Commits | Contributor |
---|---|
61 | jonschlinkert |
2 | LinusU |
2 | tbusser |
1 | doowb |
1 | wooorm |
Building docs
(This document was generated by verb-generate-readme (a verb generator), please don't edit the readme directly. Any changes to the readme must be made in .verb.md.)
To generate the readme and API documentation with verb:
1$ npm install -g verb verb-generate-readme && verb
Running tests
Install dev dependencies:
1$ npm install -d && npm test
Author
Jon Schlinkert
License
Copyright © 2016, Jon Schlinkert. Released under the MIT license.
This file was generated by verb-generate-readme, v0.2.0, on November 03, 2016.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 2/27 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 5 are checked with a SAST tool
Score
3
/10
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More