Sha256: fc9ed6f3665b53b9b258ae7eda6394d8387e17fab6d85f48f4603d19633b006b
Contents?: true
Size: 947 Bytes
Versions: 28
Compression:
Stored size: 947 Bytes
Contents
import type {IsNegative} from './numeric'; import type {Subtract} from './subtract'; /** Returns a new string which contains the specified number of copies of a given string, just like `String#repeat()`. @example ``` import {StringRepeat} from 'type-fest'; declare function stringRepeat< Input extends string, Count extends number >(input: Input, count: Count): StringRepeat<Input, Count>; // The return type is the exact string literal, not just `string`. stringRepeat('foo', 2); //=> 'foofoo' stringRepeat('=', 3); //=> '===' ``` @category String @category Template literal */ export type StringRepeat< Input extends string, Count extends number, > = number extends Count ? Input extends '' ? '' : string : IsNegative<Count> extends true ? never : Count extends 0 ? '' : string extends Input ? string : StringRepeat<Input, Subtract<Count, 1>> extends infer R extends string ? `${Input}${R}` : never;
Version data entries
28 entries across 28 versions & 2 rubygems