UNPKG

2.32 kBTypeScriptView Raw
1import { WeekdayStr } from './weekday';
2export declare const isPresent: <T>(value?: T | null | undefined) => value is T;
3export declare const isNumber: (value?: any) => value is number;
4export declare const isWeekdayStr: (value?: any) => value is WeekdayStr;
5export declare const isArray: (arg: any) => arg is any[];
6/**
7 * Simplified version of python's range()
8 */
9export declare const range: (start: number, end?: number) => number[];
10export declare const clone: <T>(array: T[]) => T[];
11export declare const repeat: <T>(value: T | T[], times: number) => (T | T[])[];
12export declare const toArray: <T>(item: T | T[]) => T[];
13export declare function padStart(item: string | number, targetLength: number, padString?: string): string;
14/**
15 * Python like split
16 */
17export declare const split: (str: string, sep: string, num: number) => string[];
18/**
19 * closure/goog/math/math.js:modulo
20 * Copyright 2006 The Closure Library Authors.
21 * The % operator in JavaScript returns the remainder of a / b, but differs from
22 * some other languages in that the result will have the same sign as the
23 * dividend. For example, -1 % 8 == -1, whereas in some other languages
24 * (such as Python) the result would be 7. This function emulates the more
25 * correct modulo behavior, which is useful for certain applications such as
26 * calculating an offset index in a circular list.
27 *
28 * @param {number} a The dividend.
29 * @param {number} b The divisor.
30 * @return {number} a % b where the result is between 0 and b (either 0 <= x < b
31 * or b < x <= 0, depending on the sign of b).
32 */
33export declare const pymod: (a: number, b: number) => number;
34/**
35 * @see: <http://docs.python.org/library/functions.html#divmod>
36 */
37export declare const divmod: (a: number, b: number) => {
38 div: number;
39 mod: number;
40};
41export declare const empty: <T>(obj: T[] | null | undefined) => boolean;
42/**
43 * Python-like boolean
44 * @return {Boolean} value of an object/primitive, taking into account
45 * the fact that in Python an empty list's/tuple's
46 * boolean value is False, whereas in JS it's true
47 */
48export declare const notEmpty: <T>(obj: T[] | null | undefined) => obj is T[];
49/**
50 * Return true if a value is in an array
51 */
52export declare const includes: <T>(arr: T[] | null | undefined, val: T) => boolean;
53//# sourceMappingURL=helpers.d.ts.map
\No newline at end of file