https://github.com/sindresorhus/repeating
Repeat a string - fast
https://github.com/sindresorhus/repeating
Last synced: 7 months ago
JSON representation
Repeat a string - fast
- Host: GitHub
- URL: https://github.com/sindresorhus/repeating
- Owner: sindresorhus
- License: mit
- Created: 2014-10-12T14:45:50.000Z (about 11 years ago)
- Default Branch: main
- Last Pushed: 2021-05-03T19:06:49.000Z (over 4 years ago)
- Last Synced: 2025-03-27T19:25:57.827Z (8 months ago)
- Language: JavaScript
- Size: 18.6 KB
- Stars: 34
- Watchers: 6
- Forks: 11
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- Funding: .github/funding.yml
- License: license
- Security: .github/security.md
Awesome Lists containing this project
- awesome-nodejs-precise - repeating - square)]() | Repeat a string. | (Packages / Text)
- awesome-nodejs-cn - repeating - Repeat a string. (包 / Text)
README
# repeating
> Repeat a string - fast
**This module is moot now. Just use [`String#repeat()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/repeat).**
## Install
```
$ npm install repeating
```
## Usage
```js
import repeating from 'repeating';
repeating(5);
//=> ' '
repeating(100, 'unicorn ');
//=> 'unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn '
```
## API
### repeating(count, string?)
#### count
Type: `number`
Times the `string` should be repeated.
#### string
Type: `string`\
Default: `' '`
String to repeat.
## Related
- [repeating-cli](https://github.com/sindresorhus/repeating-cli) - CLI for this module
- [indent-string](https://github.com/sindresorhus/indent-string) - Indent each line in a string
---
Get professional support for this package with a Tidelift subscription
Tidelift helps make open source sustainable for maintainers while giving companies
assurances about security, maintenance, and licensing for their dependencies.