Skip to main content
Module

x/scaffold/src/deps/types.ts>Split

scaffold your next project with style and 💗
Latest
type alias Split
import { type Split } from "https://deno.land/x/scaffold@0.3.0/src/deps/types.ts";

Represents an array of strings split using a given character or character set.

Use-case: Defining the return type of a method like String.prototype.split.

Examples

Example 1

import type {Split} from 'type-fest';

declare function split<S extends string, D extends string>(string: S, separator: D): Split<S, D>;

type Item = 'foo' | 'bar' | 'baz' | 'waldo';
const items = 'foo,bar,baz,waldo';
let array: Item[];

array = split(items, ',');

Type Parameters

S extends string
Delimiter extends string
definition: S extends `${infer Head}${Delimiter}${infer Tail}` ? [Head, ...Split<Tail, Delimiter>] : S extends Delimiter ? [] : [S]