@lm_fe/utils 0.1.206 → 0.1.207

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/types.d.ts CHANGED
@@ -7,6 +7,7 @@ import { FC } from 'react';
7
7
  interface ICommonOption {
8
8
  value?: any;
9
9
  label?: string;
10
+ tip?: string;
10
11
  prefix?: string;
11
12
  sufix?: string;
12
13
  suffix?: string;
@@ -18,8 +19,20 @@ interface ICommonOption {
18
19
  id?: any;
19
20
  text?: any;
20
21
  code?: any;
22
+ disabled?: boolean;
21
23
  }
22
24
 
25
+ type PropertyKey$1 = string | number | symbol;
26
+ type PartialAll<T> = {
27
+ [P in keyof T]?: T[P] extends Array<any> ? Partial<T[P][number]>[] : Partial<T[P]>;
28
+ };
29
+ type PartialSome<T, K extends keyof T> = {
30
+ [P in K]?: T[P];
31
+ } & Pick<T, Exclude<keyof T, K>>;
32
+ type AnyObject<T = any> = {
33
+ [x: string]: T;
34
+ };
35
+
23
36
  /**
24
37
  * Sorts an array of items into groups. The return value is a map where the keys are
25
38
  * the group ids the given getGroupId function produced and the value is an array of
@@ -694,7 +707,7 @@ declare const isPromise: (value: any) => value is Promise<any>;
694
707
  declare const isEmpty: (value: any) => boolean;
695
708
  declare const isEqual: <TType>(x: TType, y: TType) => boolean;
696
709
 
697
- declare function get<T = any>(value: T, path: string, defaultValue?: T | undefined): T;
710
+ declare function get<T = any>(value: any, path: string, defaultValue?: T | undefined): T;
698
711
  declare function identity<T>(value: T): T;
699
712
  declare function isBoolean(value: any): value is boolean;
700
713
  declare function isObjectLike(value: any): boolean;
@@ -703,21 +716,12 @@ declare function size(value: any): number;
703
716
  declare function isNil(value: any): value is null | undefined;
704
717
  declare function toString(value: any): string;
705
718
  declare function cloneDeep<T>(value: T): T | null;
719
+ declare function hasOwn(obj: AnyObject, key: PropertyKey): boolean;
706
720
 
707
721
  declare function safe_json_parse<T = any>(str?: any, retOnErr?: T | null): T | null;
708
722
  declare function safe_json_stringify(obj?: any): string;
709
723
  declare function safe_json_parse_arr<T = any>(str?: any, retOnErr?: T[]): T[];
710
724
 
711
- type PartialAll<T> = {
712
- [P in keyof T]?: T[P] extends Array<any> ? Partial<T[P][number]>[] : Partial<T[P]>;
713
- };
714
- type PartialSome<T, K extends keyof T> = {
715
- [P in K]?: T[P];
716
- } & Pick<T, Exclude<keyof T, K>>;
717
- type AnyObject<T = any> = {
718
- [x: string]: T;
719
- };
720
-
721
725
  type TCommonFileType = 'application/vnd.ms-excel' | 'text/csv;charset=utf-8' | 'application/msword';
722
726
  declare function get_global(): typeof globalThis;
723
727
  declare function getSearchParamsValue(key: string): string | null;
@@ -735,9 +739,10 @@ declare function unicodeToChar(u: number): string | null;
735
739
  declare function unicode_to_UTF8(u: number): number[] | null;
736
740
  declare function getFilledArray(n: number): any[];
737
741
  declare function copyText(text: string): boolean;
742
+ declare function dyn_cb<T>(cb: (ctx: T) => void, g_ctx: () => T): boolean;
738
743
  declare function safeExec<T extends (...args: any) => any>(fn?: T, ...args: Parameters<T>): any;
739
- declare function safeGetFromFuncOrData(fn: any): any;
740
- declare function numberLikeCompare(a: number | string | boolean, b: number | string | boolean): boolean;
744
+ declare function safeGetFromFuncOrData(fn: any, default_v?: any): any;
745
+ declare function numberLikeCompare(a: number | string | boolean | null, b: number | string | boolean | null): boolean;
741
746
  declare function warpBase64Type(str: string, type: 'img' | 'pdf'): string;
742
747
  declare function safe_number_parse(value: any, defaultValue?: number): number;
743
748
  declare function expect_array<T>(value?: T[] | null, default_v?: T[]): T[];
@@ -749,16 +754,18 @@ declare function gen_encoded_char_svg(props: {
749
754
  declare function base64_to_image(base64img: string): Promise<HTMLImageElement | null>;
750
755
  declare function image_to_base64(img_el: HTMLImageElement): string | null;
751
756
  declare function filter_obj_to_url_search(obj: Object | any[]): any;
752
- declare function safe_async_call<T extends (...args: any) => any>(cb: T, ...args: Parameters<T>): Promise<ReturnType<T> | null>;
753
- declare function cache_fetch<T = any>(key: string, cb: () => Promise<T>): Promise<T>;
757
+ declare function safe_async_call<T extends (...args: any) => any>(cb?: T, ...args: Parameters<T>): Promise<ReturnType<T> | null>;
758
+ declare function cache_fetch<T = any>(key: string, cb: () => Promise<T>, deep?: boolean): Promise<T>;
754
759
  declare function speculate_on_display(value?: any): string;
755
760
  declare function getFuckTimeInterval(star_hour?: number, end_hour?: number, min_interval?: 1 | 2 | 3 | 4 | 5 | 6 | 10 | 15 | 20 | 30): string[];
756
761
  declare function random_word(): string[];
757
762
  declare function confirm_operation(): boolean;
758
763
  declare function simple_encrypt(data: AnyObject | any[]): number[] | null;
759
764
  declare function simple_decrypt(code: number[]): AnyObject | null;
760
- declare function simple_encrypt_str(data: string): string | null;
761
- declare function simple_decrypt_str(code: string): string | null;
765
+ declare function simple_encrypt_str(data: string, sp?: string): string | null;
766
+ declare function simple_decrypt_str(code: string, sp?: string): string | null;
767
+ declare function text_ellipsis(text: string, max: number): string;
768
+ declare function calc_number(data: AnyObject | any[] | number | string | boolean): number;
762
769
 
763
770
  interface ILL {
764
771
  log?(...optionalParams: any[]): void;
@@ -848,6 +855,7 @@ declare function getMomentRange(m?: any): {
848
855
  近一月: [dayjs.Dayjs, dayjs.Dayjs];
849
856
  下月: [dayjs.Dayjs, dayjs.Dayjs];
850
857
  近一年: [dayjs.Dayjs, dayjs.Dayjs];
858
+ 年初至今: [dayjs.Dayjs, dayjs.Dayjs];
851
859
  };
852
860
  declare function presets_date(): {
853
861
  label: string;
@@ -859,7 +867,7 @@ declare function isMoment(m: any): boolean;
859
867
  */
860
868
  declare function getFutureDate(num: number): any;
861
869
  declare function dayjs_quarter(input: Dayjs, which_quarter?: number): [Dayjs, number];
862
- declare function diff_between(a: ConfigType, b: ConfigType, unit: QUnitType | OpUnitType, float?: boolean): any;
870
+ declare function diff_between(a: ConfigType, b: ConfigType, unit: QUnitType | OpUnitType, float?: boolean): number;
863
871
 
864
872
  interface ISpectialOption {
865
873
  sp?: ICommonOption[];
@@ -876,8 +884,6 @@ type TOptions<T extends TOptionKey | TGetOptionKey> = T extends TOptionKey ? ICo
876
884
  declare function getSimpleOptions<T extends TOptionKey | TGetOptionKey>(_arr: T, options?: ISpectialOption): TOptions<T>;
877
885
  declare function getSameOptions<T extends TOptionKey | TGetOptionKey>(_arr: T): TOptions<T>;
878
886
  declare function getDualModeOptions<T extends TOptionKey | TGetOptionKey>(arr: T, options?: ISpectialOption): readonly [TOptions<T>, TOptions<T>];
879
- type T_FETCH_OPTIONS = () => (Promise<ICommonOption[]> | ICommonOption[]);
880
- declare function safe_fetch_options(cb: T_FETCH_OPTIONS): Promise<ICommonOption[]>;
881
887
  declare function getPresetOptions(key: string, pure?: boolean): ICommonOption[];
882
888
  declare function getOptionLabel(k: string, value: any, defaultLabel?: string): string;
883
889
  declare function getOptionValue(k: string, label: any): any;
@@ -919,6 +925,22 @@ declare function getDictionaryLabel(type: string, value: string | number): strin
919
925
  declare function getDictionaryValue(type: string, label: string): number | null | undefined;
920
926
  declare function merge_dict(ops: AnyObject<IDictionary>): void;
921
927
 
928
+ interface IOpt {
929
+ id?: string;
930
+ text?: string;
931
+ url?: string;
932
+ debug?: boolean;
933
+ allowExternal?: boolean;
934
+ cache?: boolean;
935
+ async?: boolean;
936
+ type?: 'text/css' | 'text/javascript';
937
+ charset?: string;
938
+ }
939
+ type TMixOpt = IOpt | string;
940
+ declare function create_load_src(): (items: TMixOpt | TMixOpt[], node?: HTMLHeadElement) => Promise<Element> | Promise<Element[]>;
941
+ declare function load_src(items: TMixOpt, node?: HTMLHeadElement): Promise<Element>;
942
+ declare function load_src(items: TMixOpt[], node?: HTMLHeadElement): Promise<Element[]>;
943
+
922
944
  type EventCallback_Old = (data: any) => void;
923
945
  declare class EventEmitter_Old {
924
946
  /**
@@ -1281,5 +1303,5 @@ declare function temp_reander(config: {
1281
1303
  exclusive?: boolean;
1282
1304
  }): () => void;
1283
1305
 
1284
- export { ARG_URS1_KEY, ARG_URS2_KEY, AggregateError, AppEnv, BaseWsService, Browser, EMPTY_PLACEHOLDER, EnumItem, EventBus, EventEmitter, EventEmitter_Old, GetAgeByBirthDay, MyLog, ROMAN_NUMERALS, Request, TOKEN_KEY, all, alphabetical, appEnv, asRequest, assign, base64ToBinary, base64_to_image, boil, cache_fetch, calEddByLmp, calGestationalWeekByLmp, calGestationalWeekBySureEdd, callable, camel, capitalize, chain, charToUTF8, charToUnicode, clone, cloneDeep, cluster, codeMessage, compose, confirm_operation, construct, copyText, counting, crush, dash, dayjs_quarter, debounce, defer, diff, diff_between, downloadFile, draw, event, expect_array, filter_obj_to_url_search, first, flat, fork, formatDate, formatDateTime, formatDateTimeNoSecond, formatRangeDate, formatRangeDateTime, formatTime, format_gp, fubaoRequest, genEnum, genHappyPath, gen_encoded_char_svg, gen_id_form_item_config, get, getBMI, getChromeVersion, getDataSource, getDays, getDictionaries, getDictionariesEnumerations, getDictionaryLabel, getDictionaryValue, getDiffYears, getDualModeOptions, getExpected, getFilledArray, getFuckTimeInterval, getFutureDate, getGesWeek, getGestationalDays, getGestationalWeekBySureEdd, getHappyConfig, getMomentObj, getMomentRange, getOptionLabel, getOptionValue, getOrderTime, getPresetOptions, getSameOptions, getSearchParamsAll, getSearchParamsValue, getSimpleOptions, getTimeSlice, get_global, get_global_happy_arg, group, guard, identity, image_to_base64, inRange, intersects, invert, isArray, isBoolean, isDate, isEmpty, isEqual, isFloat, isFunction, isIE, isInt, isMoment, isNil, isNull, isNumber, isObject, isObjectLike, isPrimitive, isPromise, isString, isSymbol, iterate, keys, last, list, listify, lowerize, makeEventStore, map, mapEntries, mapKeys, mapValues, marshalGestationWeek, max, memo, menopauseWeek, merge, merge_dict, merge_preset_options, min, noop, numberLikeCompare, objectify, omit, optionKey不详, optionKey其他, optionKey否, parallel, partial, partob, pascal, pick, presets_date, protocolCheck, proxied, random, randomHex, random_word, range, rawRequest, reduce, replace, replaceOrAppend, request, retry, safeExec, safeGetFromFuncOrData, safe_async_call, safe_fetch_options, safe_json_parse, safe_json_parse_arr, safe_json_stringify, safe_number_parse, scrollIntoView, select, series, set, setSearchParamsAll, setSearchParamsValue, shake, shift, shuffle, sift, simple_decrypt, simple_decrypt_str, simple_encrypt, simple_encrypt_str, size, sleep, snake, sort, speculate_on_display, sum, temp_reander, template, throttle, title, toFloat, toInt, toString, toggle, transmit_happy, transmit_happy_pre, trim, tryit as try, tryit, uid, unicodeToChar, unicode_to_UTF8, unique, unmarshalGestationWeek, upperize, uuid, warpBase64Type, zip, zipToObject };
1285
- export type { AnyObject, Dayjs, DayjsConfigType, EventCallback_Old, ICommonOption, IGlobalEnumItem, IRequest_AxiosRequestConfig, IRequest_ResponseError, IRequest_SpawnConfig, PartialAll, PartialSome, TCommonFileType, TEventBus, TEventStore, TRequest_PreReq, TRequest_SimpleReq, T_FETCH_OPTIONS };
1306
+ export { ARG_URS1_KEY, ARG_URS2_KEY, AggregateError, AppEnv, BaseWsService, Browser, EMPTY_PLACEHOLDER, EnumItem, EventBus, EventEmitter, EventEmitter_Old, GetAgeByBirthDay, MyLog, ROMAN_NUMERALS, Request, TOKEN_KEY, all, alphabetical, appEnv, asRequest, assign, base64ToBinary, base64_to_image, boil, cache_fetch, calEddByLmp, calGestationalWeekByLmp, calGestationalWeekBySureEdd, calc_number, callable, camel, capitalize, chain, charToUTF8, charToUnicode, clone, cloneDeep, cluster, codeMessage, compose, confirm_operation, construct, copyText, counting, create_load_src, crush, dash, dayjs_quarter, debounce, defer, diff, diff_between, downloadFile, draw, dyn_cb, event, expect_array, filter_obj_to_url_search, first, flat, fork, formatDate, formatDateTime, formatDateTimeNoSecond, formatRangeDate, formatRangeDateTime, formatTime, format_gp, fubaoRequest, genEnum, genHappyPath, gen_encoded_char_svg, gen_id_form_item_config, get, getBMI, getChromeVersion, getDataSource, getDays, getDictionaries, getDictionariesEnumerations, getDictionaryLabel, getDictionaryValue, getDiffYears, getDualModeOptions, getExpected, getFilledArray, getFuckTimeInterval, getFutureDate, getGesWeek, getGestationalDays, getGestationalWeekBySureEdd, getHappyConfig, getMomentObj, getMomentRange, getOptionLabel, getOptionValue, getOrderTime, getPresetOptions, getSameOptions, getSearchParamsAll, getSearchParamsValue, getSimpleOptions, getTimeSlice, get_global, get_global_happy_arg, group, guard, hasOwn, identity, image_to_base64, inRange, intersects, invert, isArray, isBoolean, isDate, isEmpty, isEqual, isFloat, isFunction, isIE, isInt, isMoment, isNil, isNull, isNumber, isObject, isObjectLike, isPrimitive, isPromise, isString, isSymbol, iterate, keys, last, list, listify, load_src, lowerize, makeEventStore, map, mapEntries, mapKeys, mapValues, marshalGestationWeek, max, memo, menopauseWeek, merge, merge_dict, merge_preset_options, min, noop, numberLikeCompare, objectify, omit, optionKey不详, optionKey其他, optionKey否, parallel, partial, partob, pascal, pick, presets_date, protocolCheck, proxied, random, randomHex, random_word, range, rawRequest, reduce, replace, replaceOrAppend, request, retry, safeExec, safeGetFromFuncOrData, safe_async_call, safe_json_parse, safe_json_parse_arr, safe_json_stringify, safe_number_parse, scrollIntoView, select, series, set, setSearchParamsAll, setSearchParamsValue, shake, shift, shuffle, sift, simple_decrypt, simple_decrypt_str, simple_encrypt, simple_encrypt_str, size, sleep, snake, sort, speculate_on_display, sum, temp_reander, template, text_ellipsis, throttle, title, toFloat, toInt, toString, toggle, transmit_happy, transmit_happy_pre, trim, tryit as try, tryit, uid, unicodeToChar, unicode_to_UTF8, unique, unmarshalGestationWeek, upperize, uuid, warpBase64Type, zip, zipToObject };
1307
+ export type { AnyObject, Dayjs, DayjsConfigType, EventCallback_Old, ICommonOption, IGlobalEnumItem, IRequest_AxiosRequestConfig, IRequest_ResponseError, IRequest_SpawnConfig, PartialAll, PartialSome, PropertyKey$1 as PropertyKey, TCommonFileType, TEventBus, TEventStore, TRequest_PreReq, TRequest_SimpleReq };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lm_fe/utils",
3
- "version": "0.1.206",
3
+ "version": "0.1.207",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",
@@ -21,7 +21,7 @@
21
21
  "access": "public"
22
22
  },
23
23
  "devDependencies": {
24
- "@noah-libjs/utils": "^0.0.7",
24
+ "@noah-libjs/utils": "^0.0.48",
25
25
  "rollup": "^2.70.2"
26
26
  },
27
27
  "dependencies": {
@@ -35,5 +35,5 @@
35
35
  "keywords": [],
36
36
  "author": "",
37
37
  "license": "MIT",
38
- "gitHead": "36b944bef26adebcfaa512d6aec57446507c6ec4"
38
+ "gitHead": "0f8111460819257fcfbf7197ac2aec143d446478"
39
39
  }