Skip to content

fundamentool


split ​

Type Aliases ​

TSplitter ​

ts
type TSplitter = (src) => string[];

Defined in: src/split/splitProvider.ts:6

A function that splits a string into an array of strings.

Parameters ​

ParameterType
srcstring

Returns ​

string[]

Variables ​

NATIVE_SPLIT ​

ts
const NATIVE_SPLIT: {
  (separator, limit?): string[];
  (splitter, limit?): string[];
};

Defined in: src/split/splitProvider.ts:1

Call Signature ​

ts
(separator, limit?): string[];

Split a string into substrings using the specified separator and return them as an array.

Parameters ​
ParameterTypeDescription
separatorstring | RegExpA string that identifies character or characters to use in separating the string. If omitted, a single-element array containing the entire string is returned.
limit?numberA value used to limit the number of elements returned in the array.
Returns ​

string[]

Call Signature ​

ts
(splitter, limit?): string[];

Split a string into substrings using the specified separator and return them as an array.

Parameters ​
ParameterTypeDescription
splitter{ [split]: string[]; }An object that can split a string.
splitter.[split]-
limit?numberA value used to limit the number of elements returned in the array.
Returns ​

string[]


splitAmp ​

ts
const splitAmp: TSplitter;

Defined in: src/split/splitAmp.ts:12

Splits string by ampersand.

Param ​

The string to split.

Returns ​

The split strings.

Example ​

ts
splitAmp('a&b&c') // => ['a', 'b', 'c']
splitAmp('hello') // => ['hello']

splitDot ​

ts
const splitDot: TSplitter;

Defined in: src/split/splitDot.ts:12

Splits string by dot.

Param ​

The string to split.

Returns ​

The split strings.

Example ​

ts
splitDot('a.b.c') // => ['a', 'b', 'c']
splitDot('hello') // => ['hello']

splitSpace ​

ts
const splitSpace: TSplitter;

Defined in: src/split/splitSpace.ts:12

Splits string by whitespace.

Param ​

The string to split.

Returns ​

The split strings.

Example ​

ts
splitSpace('a b  c') // => ['a', 'b', 'c']
splitSpace('hello') // => ['hello']

Functions ​

splitProvider() ​

ts
function splitProvider(delimiter): TSplitter;

Defined in: src/split/splitProvider.ts:17

Creates a splitter function for the given delimiter.

Parameters ​

ParameterTypeDescription
delimiterstring | RegExpThe delimiter to split the string by.

Returns ​

TSplitter

The splitter function.

Example ​

ts
const splitDash = splitProvider('-');
splitDash('a-b-c'); // => ['a', 'b', 'c']

MIT License