main
Last change
on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
1.0 KB
|
Line | |
---|
1 | import { curry, invoker, flip } from 'ramda';
|
---|
2 |
|
---|
3 | import ponyfill from './internal/ponyfills/String.repeat';
|
---|
4 | import isFunction from './isFunction';
|
---|
5 |
|
---|
6 | export const repeatStrPonyfill = curry(ponyfill);
|
---|
7 |
|
---|
8 | export const repeatStrInvoker = flip(invoker(1, 'repeat'));
|
---|
9 |
|
---|
10 | /**
|
---|
11 | * Constructs and returns a new string which contains the specified
|
---|
12 | * number of copies of the string on which it was called, concatenated together.
|
---|
13 | *
|
---|
14 | * @func repeatStr
|
---|
15 | * @memberOf RA
|
---|
16 | * @since {@link https://char0n.github.io/ramda-adjunct/2.11.0|v2.11.0}
|
---|
17 | * @category List
|
---|
18 | * @sig String -> Number -> String
|
---|
19 | * @param {string} value String value to be repeated
|
---|
20 | * @param {number} count An integer between 0 and +∞: [0, +∞), indicating the number of times to repeat the string in the newly-created string that is to be returned
|
---|
21 | * @return {string} A new string containing the specified number of copies of the given string
|
---|
22 | * @example
|
---|
23 | *
|
---|
24 | * RA.repeatStr('a', 3); //=> 'aaa'
|
---|
25 | */
|
---|
26 | const repeatStr = isFunction(String.prototype.repeat)
|
---|
27 | ? repeatStrInvoker
|
---|
28 | : repeatStrPonyfill;
|
---|
29 |
|
---|
30 | export default repeatStr;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.