Strings.take()
Syntax
function take(string: string, count: number): string
Returns the first count characters in the string.
| Parameters | |
string
|
The string to take characters from. |
count
|
The number of characters to take from the beginning of the string. |
Example
import { Strings } from 'potence';
const string = '123456789';
Strings.take(string, 5); // -> "12345"
Remarks
If string is shorter than count, this function returns the entire string.
If count is negative, this function takes from the end of the string instead
(see Strings.takeLast(),
which provides the same functionality).
Contrast Strings.skip().
Compare Strings.takeUntil().