0.2.5 • Published 9 months ago

@rosinfo.tech/utils v0.2.5

Weekly downloads
-
License
-
Repository
-
Last release
9 months ago

rosinfo.tech

@rosinfo.tech/utils

Installation

npm i @rosinfo.tech/utils

Usage

ES6:

import { arrayPushDistinct } from "@rosinfo.tech/utils/arrayPushDistinct";

// or
// import { arrayPushDistinct } from "@rosinfo.tech/utils";

// ...
arrayPushDistinct( [1, 2, 3], 1, 2, 3, 4, 5 ); // [1, 2, 3, 4, 5]
// ...

CommonJS:

const { arrayPushDistinct } = require( "@rosinfo.tech/utils/arrayPushDistinct" );

// or
// const { arrayPushDistinct } = require( "@rosinfo.tech/arrayPushDistinct" );

// ...
arrayPushDistinct( [1, 2, 3], 1, 2, 3, 4, 5 ); // [1, 2, 3, 4, 5]
// ...

Functions

export type TFunctionAnyParametersAnyReturn = (...args: Array<any>) => any;

export type TArguments<F extends TFunctionAnyParametersAnyReturn> = F extends (...args: infer A) => any ? A : never;

export interface IRGBA {
    a?: number;
    b: number;
    g: number;
    r: number;
}

export interface IHSL {
    h: number;
    l: number;
    s: number;
}

export interface IHSV {
    h: number;
    s: number;
    v: number;
}

export type TFLog = (...args: Array<unknown>) => TFLog;

export declare const ARRAY_INDEX_OF_NOT_FOUND = -1;

export declare const ARRAY_SORT_RETURN_CODE_EQUAL = 0;

export declare const ARRAY_SORT_RETURN_CODE_GREATER_THAN = 1;

export declare const ARRAY_SORT_RETURN_CODE_LESS_THAN = -1;

export declare const LOG_NEXT_AS_IS = "LOG_NEXT_AS_IS";

export declare const LOG_COLOR_BLACK_WHITE = "_blackWhite_";

export declare const LOG_COLOR_RED = "_red_";

export declare const LOG_COLOR_WHITE_RED = "_whiteRed_";

export declare const LOG_COLOR_YELLOW = "_yellow_";

export declare const LOG_COLOR_BLACK_YELLOW = "_blackYellow_";

export declare const LOG_COLOR_BLUE = "_blue_";

export declare const LOG_COLOR_WHITE_BLUE = "_whiteBlue_";

export declare const LOG_COLOR_GREEN = "_green_";

export declare const LOG_COLOR_BLACK_GREEN = "_blackGreen_";

export declare const CACHE_TIME_UNLIMITED = 0;

export declare const PARSE_INT_RADIX_10 = 10;

export declare const PARSE_INT_RADIX_16 = 16;

export declare const SCRIPT_PARSER_PAIRED_SYMBOLS_KEY_ALL = "0";

export declare const SCRIPT_PARSER_QUOTES_KEY_FLAT = "flat";

export declare const SCRIPT_PARSER_QUOTES_KEY_ALL = "0";

export declare const STRING_INDEX_OF_NOT_FOUND = -1;

export interface IErrorCode extends Error {
    details?: string;
}

export declare class ErrorCode extends Error {
    constructor(code: string, ...args: Array<any>);
    tryCatchLog(codeTryCatch: string): ErrorCode;
}

export declare const arrayDuplicatesExclude: <T extends any[]>(a: T) => T[];

export declare const arrayPushDistinct: <T extends any[]>(a: T, ...args: T) => T[];

export declare const arraySortNumberByValue: <T extends number>(a: T[]) => T[];

export declare const arraySortNumberByValueReverse: <T extends number>(a: T[]) => T[];

export declare const arraySortStringsByABC: <T extends string>(a: T[]) => T[];

export declare const arraySortStringsByABCReverse: <T extends string>(a: T[]) => T[];

export declare const arraySortStringsByLength: <T extends string>(a: T[]) => T[];

export declare const arraySortStringsByLengthReverse: <T extends string>(a: T[]) => T[];

export declare function cache<F extends TFunctionAnyParametersAnyReturn>(f: F, ...args: TArguments<F>): any;

export declare const RATIO_MICROSECONDS_TO_MILLISECONDS = 1000;

export declare const cacheStorage: Map<any, any>;

export declare function cacheTime<F extends TFunctionAnyParametersAnyReturn>(f: F, time?: number, ...args: TArguments<F>): any;

export declare function colorDarker(color: string, level: number): string;

export declare function colorDarkerToRGBA(color: string, level: number): IRGBA;

export declare function colorHEXAToRGBA(color: string): IRGBA;

export interface IColorHEXAStringToRGBAStringOptions {
    alpha?: number;
    color: string;
}

export declare function colorHEXAToRGBAString(options: IColorHEXAStringToRGBAStringOptions | string): string;

export declare function colorHSLToRGBA(options: IHSL): IRGBA;

export declare function colorHSVToRGBA(options: IHSV): IRGBA;

export declare function colorLighter(color: string, level: number): string;

export declare function colorLighterToRGBA(color: string, level: number): IRGBA;

export declare const REGEXP_RGBA: RegExp;

export declare function colorRGBAStringToRGBA(rgba: string): IRGBA;

export declare function colorRGBAToHEXA(options: IRGBA | string): string;

export declare function colorRGBAToHSL(options: IRGBA): IHSL;

export declare function colorRGBAToHSV(options: IRGBA): IHSV;

export interface IColorizeOptions {
    borders?: boolean;
    node?: HTMLElement | ChildNode;
    withNodesNested?: boolean;
}

export declare function colorize({ borders, node, withNodesNested }: IColorizeOptions): void;

export declare function debugLabelHas(label: string): boolean;

export declare function debugLevelGet(): number;

export declare const isArray: <T extends any[]>(value: unknown) => value is T;

export declare const isBoolean: (value: unknown) => value is boolean;

export declare const isError: (value: unknown) => value is Error;

export declare const isErrorCode: (value: unknown) => value is IErrorCode;

export declare const isFunction: (value: unknown) => value is Function;

export declare const isHTMLElement: (value: unknown) => value is HTMLElement;

export declare const isNode: (value: unknown) => value is Node;

export declare const isNull: (value: unknown) => value is null;

export declare const isNullOrUndefined: (value: unknown) => value is null | undefined;

export declare const isNumber: (value: unknown) => value is number;

export declare const isObjectType: (value: unknown) => boolean;

export declare const isObject: <T extends object>(value: unknown) => value is T;

export declare const isRegExp: (value: unknown) => value is RegExp;

export declare const isString: (value: unknown) => value is string;

export declare const isUndefined: (val: unknown) => val is undefined;

interface ILogState {
    nextAsIs?: boolean;
}

export declare const logState: ILogState;

export declare const colors: {
    _blackGreen_: import("cli-color/bare").Format;
    _blackWhite_: import("cli-color/bare").Format;
    _blackYellow_: import("cli-color/bare").Format;
    _blue_: import("cli-color/bare").Format;
    _default_: (_: string) => string;
    _green_: import("cli-color/bare").Format;
    _red_: import("cli-color/bare").Format;
    _whiteBlue_: import("cli-color/bare").Format;
    _yellow_: import("cli-color/bare").Format;
};

export declare const log: TFLog;

export declare const logBlue: TFLog;

export declare const logClear: () => Console;

export declare const logColorCheckLogNextAsIs: (color: any, arg: any) => boolean;

export declare const logError: TFLog;

export declare const logErrorBlue: TFLog;

export declare const logErrorColorCheckLogNextAsIs: (color: any, arg: any) => boolean;

export declare const logErrorGreen: TFLog;

export declare const logErrorRed: TFLog;

export declare const logErrorYellow: TFLog;

export declare const logGreen: TFLog;

export declare const logInfo: TFLog;

export declare const logRed: TFLog;

export declare const logSuccess: TFLog;

export declare const logWarning: TFLog;

export declare const logYellow: TFLog;

export declare function md5(...args: any[]): string;

export declare function memoize<F extends TFunctionAnyParametersAnyReturn>(fn: F, cacheTime?: number): F;

export declare function memoizeInvalidate<F extends TFunctionAnyParametersAnyReturn>(fn: F, cacheTime?: number): [F, (...args: TArguments<F>) => void, () => void];

export declare function numberOfValuesEqualTo<T>(values: Array<any>, equalTo: T): number;

export declare function numberRandom(min: number, max?: number): number;

export declare const objectClone: <T = any>(object: T) => T;

export declare const objectEmptyValuesDelete: (object: Record<string, unknown>) => Record<string, unknown>;

export declare const objectKeysSort: (object: Record<string, unknown>) => Record<string, unknown>;

interface IObjectMergeOptions {
    arrayClone?: boolean;
    arrayPushAll?: boolean;
    objectClone?: boolean;
}

export declare const objectMerge: <T = any>(objectA: T, objectB: Partial<T>, options?: IObjectMergeOptions) => T;

export declare function randomEnumValue<T extends object>(anEnum: T): T[keyof T];

type TScriptParserPairedSymbolsReturn = Map<number | string, Map<string, string>> | null;

export declare function scriptParserPairedSymbols(stack: string | Array<string>): TScriptParserPairedSymbolsReturn;

interface IScriptParserPositionDelimiterOptions {
    brackets: any;
    lines?: Array<string>;
    pathFile: string;
    startColumn: number;
    startLine: number;
    string?: string;
}

export declare function scriptParserPositionDelimiter({ brackets, lines: linesProperty, pathFile, startColumn, startLine, string, }: IScriptParserPositionDelimiterOptions): [number, number] | null;

type TScriptParserQuotesReturn = Map<number | string, Map<string, string>> | null;

export declare function scriptParserQuotes(stack: string | Array<string>): TScriptParserQuotesReturn;

export declare function scriptParserSingleSymbols(stack: string | Array<string>): Map<string | number, any> | null;

export declare function sleep(timeoutMs: number): Promise<void>;

export declare function sleepSync(ms: number): void;

interface IStringReplacePositionOptions {
    endColumn: number;
    endLine?: number;
    replaceTo?: string;
    startColumn?: number;
    startLine?: number;
    string: string;
}

export declare function stringReplacePositions({ endColumn, endLine, replaceTo, startColumn, startLine, string, }: IStringReplacePositionOptions): string;

export declare const stringReplaceWithKeyValue: (string: string, map: Record<string, unknown>, keysRegExp?: boolean) => string;

interface IStringSelectOptions {
    endColumn: number;
    endLine?: number;
    startColumn?: number;
    startLine?: number;
    string: string;
}

export declare function stringSelect({ endColumn, endLine, startColumn, startLine, string, }: IStringSelectOptions): string | null;

export declare const stringSingleLine: (string: string) => string;

export declare const stringTrimChars: (string: string, chars?: string) => string;

export declare const stringTrimLeftChars: (string: string, chars?: string) => string;

export declare const stringTrimRightChars: (string: string, chars?: string) => string;

export declare function svgToCssUrl(svg: string): string;

export declare function tryCatchLog(tryCatchCode: string, e: unknown): unknown;
0.1.10

10 months ago

0.1.11

10 months ago

0.1.12

10 months ago

0.1.13

10 months ago

0.1.14

10 months ago

0.1.15

10 months ago

0.1.8

11 months ago

0.1.7

11 months ago

0.1.20

10 months ago

0.2.1

9 months ago

0.1.17

10 months ago

0.1.18

10 months ago

0.1.19

10 months ago

0.2.2

9 months ago

0.2.5

9 months ago

0.1.6

1 year ago

0.1.0

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.4

1 year ago

0.1.3

1 year ago

0.1.5

1 year ago

0.0.63

2 years ago

0.0.64

2 years ago

0.0.62

2 years ago

0.0.61

2 years ago

0.0.60

3 years ago

0.0.59

3 years ago

0.0.54

3 years ago

0.0.55

3 years ago

0.0.51

3 years ago

0.0.52

3 years ago

0.0.53

3 years ago

0.0.50

3 years ago

0.0.48

3 years ago

0.0.47

3 years ago

0.0.46

3 years ago

0.0.45

3 years ago

0.0.43

3 years ago

0.0.42

3 years ago

0.0.41

3 years ago

0.0.40

3 years ago

0.0.39

3 years ago

0.0.37

3 years ago

0.0.35

3 years ago

0.0.36

3 years ago

0.0.33

3 years ago

0.0.32

3 years ago

0.0.28

3 years ago

0.0.29

3 years ago

0.0.25

3 years ago

0.0.26

3 years ago

0.0.27

3 years ago

0.0.10

3 years ago

0.0.11

3 years ago

0.0.12

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.5

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago