perlica
Version:
<h1 align="center">Perlica</h1>
131 lines (130 loc) • 3.78 kB
TypeScript
import * as P from ".";
/**
* Returns a new `Predicate<T>`.
* Returns `true` if `searchString` appears as a substring of `self`, otherwise returns `false`.
*
*
* @category Predicate
* @example
* import { includes } from "perlica/Predicate/String"
*
* const predicate = includes("test");
*
* expect(predicate("Hello test world")).toBeTrue();
* expect(predicate("Hello world")).toBeFalse();
*/
export declare const includes: (searchString: string, position?: number) => P.Predicate<string>;
/**
* Returns a new `Predicate<T>`.
* Returns `true` if `searchString` starts with a `self`, otherwise returns `false`.
*
*
* @category Predicate
* @example
* import { startsWith } from "perlica/Predicate/String"
*
* const predicate = startsWith("test");
*
* expect(predicate("test world")).toBeTrue();
* expect(predicate("world")).toBeFalse();
*/
export declare const startsWith: (searchString: string, position?: number) => P.Predicate<string>;
/**
* Returns a new `Predicate<T>`.
* Returns `true` if `searchString` ends with a `self`, otherwise returns `false`.
*
*
* @category Predicate
* @example
* import { endsWith } from "perlica/Predicate/String"
*
* const predicate = endsWith("test");
*
* expect(predicate("world test")).toBeTrue();
* expect(predicate("world")).toBeFalse();
*/
export declare const endsWith: (searchString: string, position?: number) => P.Predicate<string>;
/**
* Returns a new `Predicate<T>`.
* Returns `true` if a regular expression (`regexp`) to match `self`, otherwise returns `false`.
*
*
* @category Predicate
* @example
* import { isMatch } from "perlica/Predicate/String"
*
* const predicate = isMatch(/Hello.*\/);
*
* expect(predicate("Hello world")).toBeTrue();
* expect(predicate("Fello world")).toBeFalse();
*/
export declare const isMatch: (regexp: RegExp) => P.Predicate<string>;
/**
* Returns a new `Predicate<T>`.
* Returns `true` if `value` is length less or equal to a pre-defined `count`.
*
* @category Predicate
* @example
* import { max } from "perlica/Predicate/String"
*
* const predicate = max(5);
*
* expect(predicate("Hello")).toBeTrue();
* expect(predicate("Hello world")).toBeFalse();
*/
export declare const maxLen: (count: number) => P.Predicate<string>;
/**
* Returns a new `Predicate<T>`.
* Returns `true` if `value` is length greater or equal to a pre-defined `count`.
*
* @category Predicate
* @example
* import { min } from "perlica/Predicate/String"
*
* const predicate = min(5);
*
* expect(predicate("Hello")).toBeTrue();
* expect(predicate("Hello world")).toBeFalse();
*/
export declare const minLen: (count: number) => P.Predicate<string>;
/**
* Returns a new `Predicate<T>`.
* Returns `true` if `value` is length equal to a pre-defined `count`.
*
* @category Predicate
* @example
* import { len } from "perlica/Predicate/String"
*
* const predicate = len(5);
*
* expect(predicate("Hello")).toBeTrue();
* expect(predicate("Hi")).toBeFalse();
* expect(predicate("Hello world")).toBeFalse();
*/
export declare const len: (count: number) => P.Predicate<string>;
/**
* Returns `true` if `value` is `string`, otherwise returns `false`.
*
*
* @category Guard
* @example
* import { isString } from "perlica/Predicate/String"
*
* expect(isString("hello")).toBeTrue();
* expect(isString(4)).toBeFalse();
* expect(isString(null)).toBeFalse();
* expect(isString(true)).toBeFalse();
*/
export declare const isString: P.Guard<unknown, string>;
/**
* Returns `true` if `self` is empty, otherwise returns `false`.
*
*
* @category Guard
* @example
* import { isEmpty } from "perlica/Predicate/String"
*
* expect(isEmpty("hello")).toBeFalse();
* expect(isEmpty("")).toBeTrue();
*/
export declare const isEmpty: P.Guard<string, "">;