@rosinfo.tech/utils
TypeScript icon, indicating that this package has built-in type declarations

0.2.5 • Public • Published

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;

Readme

Keywords

none

Package Sidebar

Install

npm i @rosinfo.tech/utils

Weekly Downloads

14

Version

0.2.5

License

none

Unpacked Size

91.8 kB

Total Files

208

Last publish

Collaborators

  • roskoshinsky