@huameow/utils
v0.0.3
Published
utils
Downloads
2
Readme
utils
how to use
1. install it
yarn add @huameow/utils
2. import it
import {formatDate} from '@huameow/utils';
formatDate("2020-01", 'YY-MM-DD') => 2020-01-01
api
| method | description | | --- | --- | | checkHasProperty | <T, K extends Extract<keyof T, string | string[]>>(value: T[K], key: K, items: T[]): boolean | | sort | {binarySearch, heapSort, insertSort, mergeSort, quickSort} | | formatDate | ( value?: string | number | Date, formatStr = "YY-MM-DD hh:mm:ss"): string | | isDate | (value: string | number | Date): boolean | | toDate | (value: string | number | Date): number | | getDuration | ( start: number | string | Date, end: number | string | Date = new Date(), formatStr = "hh:mm:ss"): string | | copy | (text, id): Promise | | downloadedImage | (id: string): Promise | | drawImage | ({ url, width, height }, id: string, hasRadius = false): void | | hasFlash | (): boolean | | isRetina | (): boolean | | loadScript | (src: string): Promise | | validImage | (url: string, successFn: Function, failFn: Function): void | | b64toBlob | (b64Data: string, contentType: string = "", sliceSize = 512): Blob | | createObjectURL | (blob: Blob): string | | crypto | (data: unknown, needJoin = false): string | | getSuffix | (fileName: string): string | | floatFix | ( value: string | number, decimal: number = 2, isRounding: boolean = true): string | | formatLargeNumber | (value: number | string): string | | isNumber | (value: string | number | unknown): boolean | | nonRounding | (value: number, decimal: number): number | | priceFormat | ( value: string | number, local = Languages.ZH): string | | rounding | (value: number, decimal: number): string | | switchCentAndYuanProps | ( value: string, stage: Stage = PriceStage.YUAN): number | | toPrice | (value: string | number): number | | decodeHTMLEntities | (str: string): string | | escape | (text: string | number): string | | unescape | (text: string): string | | getStrLength | (str: string, charset = "gbk"): number | | randomString | (length: number): string | | setSpaces | (num: number): string | | toCamelCase | (str: string): string | | toSnakeCase | (str: string): string | | hasChinese | (value: string): boolean | | isChinaMobile | (value: number | string): boolean | | isEmail | (value: string): boolean | | isID | (value: string): boolean | | isMobile | (value: number | string): boolean | | isPhone | (value: number | string): boolean | | isPostalCode | (value: number | string): boolean | | isQQ | (value: number | string): boolean | | isURL | (value: string): boolean |