What is repeating?
The 'repeating' npm package is a simple utility that allows you to create a new string by repeating a given string a specified number of times. It is useful for generating repeated patterns, filling spaces, or creating specific string-based designs programmatically.
What are repeating's main functionalities?
String repetition
This feature allows you to repeat a string a specified number of times. The first argument is the number of times to repeat, and the second argument is the string to repeat.
const repeating = require('repeating');
console.log(repeating(3, 'abc')); // 'abcabcabc'
Other packages similar to repeating
repeat-string
Similar to 'repeating', 'repeat-string' allows you to repeat a string multiple times. It offers a straightforward API similar to 'repeating' but differs slightly in implementation, which might affect performance in edge cases.
pad
While primarily used for padding strings, 'pad' can also repeat strings to achieve the desired length. This package provides more general string manipulation capabilities compared to the singular focus of 'repeating'.
repeating
Repeat a string - fast
This module is moot now. Just use String#repeat()
.
Install
$ npm install repeating
Usage
import repeating from 'repeating';
repeating(5);
repeating(100, 'unicorn ');
API
repeating(count, string?)
count
Type: number
Times the string
should be repeated.
string
Type: string
Default: ' '
String to repeat.
Related