Socket
Socket
Sign inDemoInstall

repeat-string

Package Overview
Dependencies
0
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    repeat-string

Repeat the given string n times. Fastest implementation for repeating a string.


Version published
Weekly downloads
13M
decreased by-21.87%
Maintainers
1
Install size
6.38 kB
Created
Weekly downloads
 

Package description

What is repeat-string?

The repeat-string npm package is a minimalistic library that allows users to repeat a given string a specified number of times. It is useful for creating padding, indentation, or repeating patterns in strings.

What are repeat-string's main functionalities?

String repetition

Repeats the '*' character 3 times to produce the string '***'.

"*".repeat(3)

Other packages similar to repeat-string

Readme

Source

repeat-string NPM version

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

Repeat the given string the specified number of times.

  • string {String}: The string to repeat
  • number {Number}: The number of times to repeat the string
  • returns {String}: Repeated string

Example:

var repeat = require('repeat-string');
repeat('A', 5);
//=> AAAAA

Benchmarks

Repeat string is significantly faster than repeating.

# 20,000x
  repeat-string.js x 16,634,213 ops/sec ±0.92% (93 runs sampled)
  repeating.js x 5,883,928 ops/sec ±0.95% (93 runs sampled)

# 2,000x
  repeat-string.js x 17,438,654 ops/sec ±0.76% (97 runs sampled)
  repeating.js x 6,639,978 ops/sec ±0.84% (97 runs sampled)

# 250x
  repeat-string.js x 16,246,885 ops/sec ±0.81% (92 runs sampled)
  repeating.js x 7,659,342 ops/sec ±0.67% (99 runs sampled)

# 50x
  repeat-string.js x 15,803,340 ops/sec ±0.74% (92 runs sampled)
  repeating.js x 9,668,300 ops/sec ±0.89% (98 runs sampled)

# 5x
  repeat-string.js x 16,926,291 ops/sec ±0.78% (97 runs sampled)
  repeating.js x 12,215,384 ops/sec ±1.01% (96 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 26, 2015.

Keywords

FAQs

Last updated on 26 Jan 2015

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc