@noah-libjs/utils 0.0.9 → 0.0.42
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/README.md +1 -1
- package/dist/es.js +17 -1
- package/dist/helper.d.ts +1 -1
- package/dist/lib.js +17 -0
- package/dist/small-fn.d.ts +1 -0
- package/dist/types.d.ts +2 -0
- package/dist/typing.d.ts +5 -2
- package/package.json +2 -2
package/README.md
CHANGED
package/dist/es.js
CHANGED
|
@@ -1904,6 +1904,22 @@ function text_ellipsis(text, max) {
|
|
|
1904
1904
|
if (text.length <= max) return text;
|
|
1905
1905
|
return text.slice(0, max) + '...';
|
|
1906
1906
|
}
|
|
1907
|
+
function calc_number(data) {
|
|
1908
|
+
if (isNil(data)) return 0;
|
|
1909
|
+
var data_to_calc = null;
|
|
1910
|
+
if (isArray(data)) data_to_calc = data.map(calc_number);
|
|
1911
|
+
if (isObject(data)) data_to_calc = Object.values(data).map(calc_number);
|
|
1912
|
+
if (isString(data) || isBoolean(data) || isNumber(data)) {
|
|
1913
|
+
var v = Number(data);
|
|
1914
|
+
if (!isNaN(v)) data_to_calc = [v];
|
|
1915
|
+
}
|
|
1916
|
+
if (data_to_calc) return data_to_calc.filter(function (_) {
|
|
1917
|
+
return isNumber(_) && !isNaN(_);
|
|
1918
|
+
}).reduce(function (sum, a) {
|
|
1919
|
+
return sum + a;
|
|
1920
|
+
}, 0);
|
|
1921
|
+
return 0;
|
|
1922
|
+
}
|
|
1907
1923
|
Object.assign(get_global(), {
|
|
1908
1924
|
safe_async_call: safe_async_call,
|
|
1909
1925
|
simple_decrypt_str: simple_decrypt_str,
|
|
@@ -2674,4 +2690,4 @@ function load_src(items, node) {
|
|
|
2674
2690
|
var load_src_ = create_load_src();
|
|
2675
2691
|
return load_src_(items, node);
|
|
2676
2692
|
}
|
|
2677
|
-
export { ARG_URS1_KEY, ARG_URS2_KEY, EMPTY_PLACEHOLDER, EventEmitter, MyLog, ROMAN_NUMERALS, TOKEN_KEY, all, alphabetical, _assign as assign, base64ToBinary, base64_to_image, boil, cache_fetch, callable, camel, capitalize, chain, charToUTF8, charToUnicode, clone, cloneDeep, cluster, compose, confirm_operation, construct, copyText, counting, create_load_src, crush, dash, dayjs_quarter, debounce, defer, diff, diff_between, downloadFile, draw, dyn_cb, expect_array, filter_obj_to_url_search, first, flat, fork, formatDate, formatDateTime, formatDateTimeNoSecond, formatTime, gen_encoded_char_svg, get, getDictionaries, getDictionariesEnumerations, getDictionaryLabel, getDictionaryValue, getDualModeOptions, getFilledArray, getFuckTimeInterval, getFutureDate, getMomentObj, getMomentRange, getOptionLabel, getOptionValue, getPresetOptions, getSameOptions, getSearchParamsAll, getSearchParamsValue, getSimpleOptions, get_global, group, guard, hasOwn, identity, image_to_base64, inRange, intersects, invert, isArray, isBoolean, isDate, isEmpty, _isEqual as isEqual, isFloat, isFunction, isInt, isMoment, isNil, isNull, isNumber, isObject, isObjectLike, isPrimitive, isPromise, isString, isSymbol, iterate, keys, last, list, listify, load_src, lowerize, map, mapEntries, mapKeys, mapValues, max, memo, merge, merge_dict, merge_preset_options, min, noop, numberLikeCompare, objectify, omit, optionKey不详, optionKey其他, optionKey否, parallel, partial, partob, pascal, pick, presets_date, proxied, random, randomHex, random_word, range, reduce, replace, replaceOrAppend, 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, template, text_ellipsis, throttle, title, toFloat, toInt, toString, toggle, trim, tryit as try, tryit, uid, unicodeToChar, unicode_to_UTF8, unique, upperize, uuid, warpBase64Type, zip, zipToObject };
|
|
2693
|
+
export { ARG_URS1_KEY, ARG_URS2_KEY, EMPTY_PLACEHOLDER, EventEmitter, MyLog, ROMAN_NUMERALS, TOKEN_KEY, all, alphabetical, _assign as assign, base64ToBinary, base64_to_image, boil, cache_fetch, calc_number, callable, camel, capitalize, chain, charToUTF8, charToUnicode, clone, cloneDeep, cluster, compose, confirm_operation, construct, copyText, counting, create_load_src, crush, dash, dayjs_quarter, debounce, defer, diff, diff_between, downloadFile, draw, dyn_cb, expect_array, filter_obj_to_url_search, first, flat, fork, formatDate, formatDateTime, formatDateTimeNoSecond, formatTime, gen_encoded_char_svg, get, getDictionaries, getDictionariesEnumerations, getDictionaryLabel, getDictionaryValue, getDualModeOptions, getFilledArray, getFuckTimeInterval, getFutureDate, getMomentObj, getMomentRange, getOptionLabel, getOptionValue, getPresetOptions, getSameOptions, getSearchParamsAll, getSearchParamsValue, getSimpleOptions, get_global, group, guard, hasOwn, identity, image_to_base64, inRange, intersects, invert, isArray, isBoolean, isDate, isEmpty, _isEqual as isEqual, isFloat, isFunction, isInt, isMoment, isNil, isNull, isNumber, isObject, isObjectLike, isPrimitive, isPromise, isString, isSymbol, iterate, keys, last, list, listify, load_src, lowerize, map, mapEntries, mapKeys, mapValues, max, memo, merge, merge_dict, merge_preset_options, min, noop, numberLikeCompare, objectify, omit, optionKey不详, optionKey其他, optionKey否, parallel, partial, partob, pascal, pick, presets_date, proxied, random, randomHex, random_word, range, reduce, replace, replaceOrAppend, 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, template, text_ellipsis, throttle, title, toFloat, toInt, toString, toggle, trim, tryit as try, tryit, uid, unicodeToChar, unicode_to_UTF8, unique, upperize, uuid, warpBase64Type, zip, zipToObject };
|
package/dist/helper.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AnyObject } from "./type-utils";
|
|
2
2
|
export * from "radash";
|
|
3
|
-
export declare function get<T = any>(value:
|
|
3
|
+
export declare function get<T = any>(value: any, path: string, defaultValue?: T | undefined): T;
|
|
4
4
|
export declare function identity<T>(value: T): T;
|
|
5
5
|
export declare function isBoolean(value: any): value is boolean;
|
|
6
6
|
export declare function isObjectLike(value: any): boolean;
|
package/dist/lib.js
CHANGED
|
@@ -1914,6 +1914,22 @@ function text_ellipsis(text, max) {
|
|
|
1914
1914
|
if (text.length <= max) return text;
|
|
1915
1915
|
return text.slice(0, max) + '...';
|
|
1916
1916
|
}
|
|
1917
|
+
function calc_number(data) {
|
|
1918
|
+
if (isNil(data)) return 0;
|
|
1919
|
+
var data_to_calc = null;
|
|
1920
|
+
if (isArray(data)) data_to_calc = data.map(calc_number);
|
|
1921
|
+
if (isObject(data)) data_to_calc = Object.values(data).map(calc_number);
|
|
1922
|
+
if (isString(data) || isBoolean(data) || isNumber(data)) {
|
|
1923
|
+
var v = Number(data);
|
|
1924
|
+
if (!isNaN(v)) data_to_calc = [v];
|
|
1925
|
+
}
|
|
1926
|
+
if (data_to_calc) return data_to_calc.filter(function (_) {
|
|
1927
|
+
return isNumber(_) && !isNaN(_);
|
|
1928
|
+
}).reduce(function (sum, a) {
|
|
1929
|
+
return sum + a;
|
|
1930
|
+
}, 0);
|
|
1931
|
+
return 0;
|
|
1932
|
+
}
|
|
1917
1933
|
Object.assign(get_global(), {
|
|
1918
1934
|
safe_async_call: safe_async_call,
|
|
1919
1935
|
simple_decrypt_str: simple_decrypt_str,
|
|
@@ -2704,6 +2720,7 @@ exports.base64ToBinary = base64ToBinary;
|
|
|
2704
2720
|
exports.base64_to_image = base64_to_image;
|
|
2705
2721
|
exports.boil = boil;
|
|
2706
2722
|
exports.cache_fetch = cache_fetch;
|
|
2723
|
+
exports.calc_number = calc_number;
|
|
2707
2724
|
exports.callable = callable;
|
|
2708
2725
|
exports.camel = camel;
|
|
2709
2726
|
exports.capitalize = capitalize;
|
package/dist/small-fn.d.ts
CHANGED
|
@@ -42,3 +42,4 @@ export declare function simple_decrypt(code: number[]): AnyObject | null;
|
|
|
42
42
|
export declare function simple_encrypt_str(data: string, sp?: string): string | null;
|
|
43
43
|
export declare function simple_decrypt_str(code: string, sp?: string): string | null;
|
|
44
44
|
export declare function text_ellipsis(text: string, max: number): string;
|
|
45
|
+
export declare function calc_number(data: AnyObject | any[] | number | string | boolean): number;
|
package/dist/types.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export interface ICommonOption {
|
|
2
2
|
value?: any;
|
|
3
3
|
label?: string;
|
|
4
|
+
tip?: string;
|
|
4
5
|
prefix?: string;
|
|
5
6
|
sufix?: string;
|
|
6
7
|
suffix?: string;
|
|
@@ -12,4 +13,5 @@ export interface ICommonOption {
|
|
|
12
13
|
id?: any;
|
|
13
14
|
text?: any;
|
|
14
15
|
code?: any;
|
|
16
|
+
disabled?: boolean;
|
|
15
17
|
}
|
package/dist/typing.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export { default as dayjs } from 'dayjs';
|
|
|
4
4
|
interface ICommonOption {
|
|
5
5
|
value?: any;
|
|
6
6
|
label?: string;
|
|
7
|
+
tip?: string;
|
|
7
8
|
prefix?: string;
|
|
8
9
|
sufix?: string;
|
|
9
10
|
suffix?: string;
|
|
@@ -15,6 +16,7 @@ interface ICommonOption {
|
|
|
15
16
|
id?: any;
|
|
16
17
|
text?: any;
|
|
17
18
|
code?: any;
|
|
19
|
+
disabled?: boolean;
|
|
18
20
|
}
|
|
19
21
|
|
|
20
22
|
type PropertyKey$1 = string | number | symbol;
|
|
@@ -702,7 +704,7 @@ declare const isPromise: (value: any) => value is Promise<any>;
|
|
|
702
704
|
declare const isEmpty: (value: any) => boolean;
|
|
703
705
|
declare const isEqual: <TType>(x: TType, y: TType) => boolean;
|
|
704
706
|
|
|
705
|
-
declare function get<T = any>(value:
|
|
707
|
+
declare function get<T = any>(value: any, path: string, defaultValue?: T | undefined): T;
|
|
706
708
|
declare function identity<T>(value: T): T;
|
|
707
709
|
declare function isBoolean(value: any): value is boolean;
|
|
708
710
|
declare function isObjectLike(value: any): boolean;
|
|
@@ -760,6 +762,7 @@ declare function simple_decrypt(code: number[]): AnyObject | null;
|
|
|
760
762
|
declare function simple_encrypt_str(data: string, sp?: string): string | null;
|
|
761
763
|
declare function simple_decrypt_str(code: string, sp?: string): string | null;
|
|
762
764
|
declare function text_ellipsis(text: string, max: number): string;
|
|
765
|
+
declare function calc_number(data: AnyObject | any[] | number | string | boolean): number;
|
|
763
766
|
|
|
764
767
|
interface ILL {
|
|
765
768
|
log?(...optionalParams: any[]): void;
|
|
@@ -935,5 +938,5 @@ declare function create_load_src(): (items: TMixOpt | TMixOpt[], node?: HTMLHead
|
|
|
935
938
|
declare function load_src(items: TMixOpt, node?: HTMLHeadElement): Promise<Element>;
|
|
936
939
|
declare function load_src(items: TMixOpt[], node?: HTMLHeadElement): Promise<Element[]>;
|
|
937
940
|
|
|
938
|
-
export { ARG_URS1_KEY, ARG_URS2_KEY, AggregateError, EMPTY_PLACEHOLDER, EventEmitter, MyLog, ROMAN_NUMERALS, TOKEN_KEY, all, alphabetical, assign, base64ToBinary, base64_to_image, boil, cache_fetch, callable, camel, capitalize, chain, charToUTF8, charToUnicode, clone, cloneDeep, cluster, compose, confirm_operation, construct, copyText, counting, create_load_src, crush, dash, dayjs_quarter, debounce, defer, diff, diff_between, downloadFile, draw, dyn_cb, expect_array, filter_obj_to_url_search, first, flat, fork, formatDate, formatDateTime, formatDateTimeNoSecond, formatTime, gen_encoded_char_svg, get, getDictionaries, getDictionariesEnumerations, getDictionaryLabel, getDictionaryValue, getDualModeOptions, getFilledArray, getFuckTimeInterval, getFutureDate, getMomentObj, getMomentRange, getOptionLabel, getOptionValue, getPresetOptions, getSameOptions, getSearchParamsAll, getSearchParamsValue, getSimpleOptions, get_global, group, guard, hasOwn, identity, image_to_base64, inRange, intersects, invert, isArray, isBoolean, isDate, isEmpty, isEqual, isFloat, isFunction, isInt, isMoment, isNil, isNull, isNumber, isObject, isObjectLike, isPrimitive, isPromise, isString, isSymbol, iterate, keys, last, list, listify, load_src, lowerize, map, mapEntries, mapKeys, mapValues, max, memo, merge, merge_dict, merge_preset_options, min, noop, numberLikeCompare, objectify, omit, optionKey不详, optionKey其他, optionKey否, parallel, partial, partob, pascal, pick, presets_date, proxied, random, randomHex, random_word, range, reduce, replace, replaceOrAppend, 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, template, text_ellipsis, throttle, title, toFloat, toInt, toString, toggle, trim, tryit as try, tryit, uid, unicodeToChar, unicode_to_UTF8, unique, upperize, uuid, warpBase64Type, zip, zipToObject };
|
|
941
|
+
export { ARG_URS1_KEY, ARG_URS2_KEY, AggregateError, EMPTY_PLACEHOLDER, EventEmitter, MyLog, ROMAN_NUMERALS, TOKEN_KEY, all, alphabetical, assign, base64ToBinary, base64_to_image, boil, cache_fetch, calc_number, callable, camel, capitalize, chain, charToUTF8, charToUnicode, clone, cloneDeep, cluster, compose, confirm_operation, construct, copyText, counting, create_load_src, crush, dash, dayjs_quarter, debounce, defer, diff, diff_between, downloadFile, draw, dyn_cb, expect_array, filter_obj_to_url_search, first, flat, fork, formatDate, formatDateTime, formatDateTimeNoSecond, formatTime, gen_encoded_char_svg, get, getDictionaries, getDictionariesEnumerations, getDictionaryLabel, getDictionaryValue, getDualModeOptions, getFilledArray, getFuckTimeInterval, getFutureDate, getMomentObj, getMomentRange, getOptionLabel, getOptionValue, getPresetOptions, getSameOptions, getSearchParamsAll, getSearchParamsValue, getSimpleOptions, get_global, group, guard, hasOwn, identity, image_to_base64, inRange, intersects, invert, isArray, isBoolean, isDate, isEmpty, isEqual, isFloat, isFunction, isInt, isMoment, isNil, isNull, isNumber, isObject, isObjectLike, isPrimitive, isPromise, isString, isSymbol, iterate, keys, last, list, listify, load_src, lowerize, map, mapEntries, mapKeys, mapValues, max, memo, merge, merge_dict, merge_preset_options, min, noop, numberLikeCompare, objectify, omit, optionKey不详, optionKey其他, optionKey否, parallel, partial, partob, pascal, pick, presets_date, proxied, random, randomHex, random_word, range, reduce, replace, replaceOrAppend, 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, template, text_ellipsis, throttle, title, toFloat, toInt, toString, toggle, trim, tryit as try, tryit, uid, unicodeToChar, unicode_to_UTF8, unique, upperize, uuid, warpBase64Type, zip, zipToObject };
|
|
939
942
|
export type { AnyObject, Dayjs, DayjsConfigType, ICommonOption, PartialAll, PartialSome, PropertyKey$1 as PropertyKey, TCommonFileType };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@noah-libjs/utils",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.42",
|
|
4
4
|
"description": "",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
@@ -34,5 +34,5 @@
|
|
|
34
34
|
"keywords": [],
|
|
35
35
|
"author": "",
|
|
36
36
|
"license": "MIT",
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "6df762563633fc56dae4e1c3891588a96b0305dd"
|
|
38
38
|
}
|