complex-utils-next
Advanced tools
+1
-4
| const config = { | ||
| local: { | ||
| prop: 'simple-utils-' | ||
| prop: 'complex-utils-' | ||
| }, | ||
| type: { | ||
| emptyCheckList: ['object', 'array'] | ||
| }, | ||
| object: { | ||
@@ -10,0 +7,0 @@ existList: [false, 0], |
+1
-1
| ### 0.1.0 | ||
| ### 2.0.1 | ||
| - 基于complex-utils简化逻辑,实现基本的工具函数功能 |
+1
-1
| { | ||
| "name": "complex-utils-next", | ||
| "version": "2.0.1", | ||
| "version": "2.0.2", | ||
| "description": "a complex utils-next", | ||
@@ -5,0 +5,0 @@ "main": "index.ts", |
@@ -1,2 +0,2 @@ | ||
| import exportMsg, { consoleType, exportOption } from '../utils/exportMsg' | ||
| import exportMsg, { consoleType } from '../utils/exportMsg' | ||
@@ -10,2 +10,3 @@ class Data { | ||
| $getConstructorName(): string { | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| return (this.constructor as any).$name | ||
@@ -30,4 +31,4 @@ } | ||
| */ | ||
| $exportMsg(content: string, type: consoleType = 'error', option?: exportOption) { | ||
| exportMsg(this.$createMsg(content), type, option) | ||
| $exportMsg(content: string, type: consoleType = 'error') { | ||
| exportMsg(this.$createMsg(content), type) | ||
| } | ||
@@ -34,0 +35,0 @@ /** |
+27
-18
@@ -0,6 +1,6 @@ | ||
| /* eslint-disable @typescript-eslint/no-explicit-any */ | ||
| import Data from './Data' | ||
| import isArray from '../type/isArray' | ||
| import Data from './Data' | ||
| let lifeId = 1 | ||
| function getLifeId () { | ||
@@ -11,3 +11,3 @@ lifeId++ | ||
| export interface LifeDataType { | ||
| export interface LifeDataInitType { | ||
| id?: PropertyKey | ||
@@ -21,6 +21,15 @@ data: (...args: any[]) => any | ||
| export interface LifeDataType { | ||
| id: PropertyKey | ||
| data: (...args: any[]) => any | ||
| index?: number | ||
| replace?: boolean | ||
| immediate?: boolean | ||
| once?: boolean | ||
| } | ||
| export class LifeData extends Data { | ||
| name: string | ||
| data: Map<PropertyKey, LifeDataType> | ||
| constructor(name: string, data?: LifeDataType | LifeDataType[]) { | ||
| constructor(name: string, data?: LifeDataInitType | LifeDataInitType[]) { | ||
| super() | ||
@@ -38,3 +47,3 @@ this.name = name | ||
| */ | ||
| push(data?: LifeDataType | LifeDataType[]) { | ||
| push(data?: LifeDataInitType | LifeDataInitType[]) { | ||
| let resId: undefined | PropertyKey | (undefined | PropertyKey)[] | ||
@@ -53,3 +62,3 @@ if (data) { | ||
| } | ||
| protected $push(data: LifeDataType) { | ||
| protected $push(data: LifeDataInitType) { | ||
| if (!data.id) { | ||
@@ -62,3 +71,3 @@ data.id = getLifeId() | ||
| if (data.index === undefined) { | ||
| this.data.set(data.id, data) | ||
| this.data.set(data.id, data as LifeDataType) | ||
| } else { | ||
@@ -75,12 +84,12 @@ const size = this.data.size | ||
| if (data.index === n) { | ||
| this.data.set(data.id, data) | ||
| this.data.set(data.id, data as LifeDataType) | ||
| } | ||
| this.data.set(item.id!, item) | ||
| this.data.set(item.id, item) | ||
| } | ||
| } else { | ||
| this.data.set(data.id, data) | ||
| this.data.set(data.id, data as LifeDataType) | ||
| } | ||
| } | ||
| if (data.immediate) { | ||
| this.emit(data.id!) | ||
| this.emit(data.id) | ||
| } | ||
@@ -147,3 +156,3 @@ return data.id | ||
| export interface LifeInitOption { | ||
| [prop: string]: LifeDataType | LifeDataType[] | ||
| [prop: string]: LifeDataInitType | LifeDataInitType[] | ||
| } | ||
@@ -189,4 +198,4 @@ | ||
| on(name: string, ...args: Parameters<LifeData['push']>) { | ||
| const lifeItem = this.get(name, true)! | ||
| return lifeItem.push(...args) | ||
| const lifeItem = this.get(name, true) | ||
| return lifeItem?.push(...args) | ||
| } | ||
@@ -200,4 +209,4 @@ /** | ||
| emit(name: string, ...args: Parameters<LifeData['emit']>) { | ||
| const lifeItem = this.get(name, true)! | ||
| lifeItem.emit(...args) | ||
| const lifeItem = this.get(name, true) | ||
| lifeItem?.emit(...args) | ||
| } | ||
@@ -210,4 +219,4 @@ /** | ||
| trigger(name: string, ...args: Parameters<LifeData['trigger']>) { | ||
| const lifeItem = this.get(name, true)! | ||
| lifeItem.trigger(...args) | ||
| const lifeItem = this.get(name, true) | ||
| lifeItem?.trigger(...args) | ||
| } | ||
@@ -214,0 +223,0 @@ /** |
@@ -0,1 +1,2 @@ | ||
| /* eslint-disable @typescript-eslint/no-explicit-any */ | ||
| import Data from './Data' | ||
@@ -2,0 +3,0 @@ |
+7
-10
@@ -18,3 +18,3 @@ import { LifeData } from "../class/Life" | ||
| real: '' | ||
| } as Record<PropertyKey, any>, | ||
| } as Record<PropertyKey, unknown>, | ||
| change: new LifeData('change') | ||
@@ -53,3 +53,3 @@ } | ||
| */ | ||
| export function setEnvMode(data: any, prop = 'data', unTriggerChange?: boolean) { | ||
| export function setEnvMode(data: unknown, prop = 'data', unTriggerChange?: boolean) { | ||
| option.mode[prop] = data | ||
@@ -72,3 +72,3 @@ if (!unTriggerChange) { | ||
| */ | ||
| export function resetEnvData(fn: (...args:any[]) => any, { env, info, args }: { env?: string, info?: string, args?: any[] } = {}) { | ||
| export function resetEnvData(fn: () => void, { env, info }: { env?: string, info?: string } = {}) { | ||
| // 真实环境为目标环境时触发操作 | ||
@@ -79,12 +79,9 @@ if (!env) { | ||
| if (getEnv('real') === env) { | ||
| $exportMsg(`resetEnvData:当前真实环境为${getEnv('real')},触发目标环境为${env}的函数!`) | ||
| let msg = `[resetEnvData:触发目标真实环境为${env}的数据变更!]` | ||
| if (info) { | ||
| $exportMsg(info) | ||
| msg += info | ||
| } | ||
| $exportMsg(msg) | ||
| if (fn) { | ||
| if (args) { | ||
| return fn(...args) | ||
| } else { | ||
| return fn() | ||
| } | ||
| return fn() | ||
| } | ||
@@ -91,0 +88,0 @@ } |
@@ -0,1 +1,2 @@ | ||
| /* eslint-disable @typescript-eslint/no-explicit-any */ | ||
| /** | ||
@@ -8,3 +9,3 @@ * @desc 函数防抖,触发事件N秒后执行函数,如果在 n 秒内又触发了事件,则会重新计算函数执行时间。 | ||
| function debounce(func: (...args: any[]) => any, wait: number, immediate?: boolean) { | ||
| let timeout: undefined | number | ||
| let timeout: any | ||
| return function(this: any, ...args: any[]) { | ||
@@ -11,0 +12,0 @@ const context = this |
@@ -0,1 +1,2 @@ | ||
| /* eslint-disable @typescript-eslint/no-explicit-any */ | ||
@@ -20,3 +21,3 @@ /** | ||
| } else { | ||
| let timeout: undefined | number | ||
| let timeout: any | ||
| return function(this: any, ...args: any[]) { | ||
@@ -23,0 +24,0 @@ const context = this |
@@ -0,1 +1,2 @@ | ||
| /* eslint-disable @typescript-eslint/no-explicit-any */ | ||
| /** | ||
@@ -2,0 +3,0 @@ * 触发可能存在的函数 |
@@ -0,1 +1,2 @@ | ||
| /* eslint-disable @typescript-eslint/no-explicit-any */ | ||
| import $exportMsg from '../utils/$exportMsg' | ||
@@ -34,3 +35,3 @@ import isPromise from './../type/isPromise' | ||
| triggerFunction(start) | ||
| promise!.then(res => { | ||
| promise?.then(res => { | ||
| triggerFunction(success, res) | ||
@@ -37,0 +38,0 @@ triggerFunction(finish, res) |
@@ -8,2 +8,3 @@ import config from '../../config' | ||
| function $buildSetLocalData(storage: Storage) { | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| return function(name: string, value?: any) { | ||
@@ -10,0 +11,0 @@ name = $getLocalProp(name) |
@@ -8,3 +8,3 @@ import parseNum from './parseNum' | ||
| */ | ||
| function getDecimal(value: any): number { | ||
| function getDecimal(value: unknown): number { | ||
| return parseNum(value)[1] | ||
@@ -11,0 +11,0 @@ } |
@@ -8,3 +8,3 @@ import parseNum from './parseNum' | ||
| */ | ||
| function getInteger(value: any): number { | ||
| function getInteger(value: unknown): number { | ||
| return parseNum(value)[0] | ||
@@ -11,0 +11,0 @@ } |
@@ -14,3 +14,3 @@ import formatNum from './formatNum' | ||
| function getNum(originNum: any, type: 'origin' | mathType = 'round', radix = 2, NANZERO = false) { | ||
| function getNum(originNum: unknown, type: 'origin' | mathType = 'round', radix = 2, NANZERO = false) { | ||
| let value = formatNum(originNum) | ||
@@ -17,0 +17,0 @@ if (isNaN(value) && NANZERO) { |
@@ -12,3 +12,4 @@ import { mathType } from './getNum' | ||
| */ | ||
| function getPreciseNum(originNum: any, type: mathType = 'round', radix = 2, NANZERO = false) { | ||
| function getPreciseNum(originNum: unknown, type: mathType = 'round', radix = 2, NANZERO = false) { | ||
| // eslint-disable-next-line prefer-const | ||
| let [integer, decimal] = parseNum(originNum) | ||
@@ -15,0 +16,0 @@ if (isNaN(integer) || isNaN(decimal)) { |
@@ -7,3 +7,3 @@ | ||
| */ | ||
| function parseNum(value: any): [number, number] { | ||
| function parseNum(value: unknown): [number, number] { | ||
| if (value) { | ||
@@ -10,0 +10,0 @@ const valueStr = typeof value === 'string' ? value : value.toString() |
@@ -0,1 +1,2 @@ | ||
| /* eslint-disable @typescript-eslint/no-explicit-any */ | ||
| /** | ||
@@ -10,5 +11,5 @@ * 指定对象/FormData添加属性 | ||
| if (type === 'json') { | ||
| (<Record<string, any>>data)[propName] = propData | ||
| (data as Record<string, any>)[propName] = propData | ||
| } else if (type === 'form') { | ||
| (<FormData>data).set(propName, propData) | ||
| (data as FormData).set(propName, propData) | ||
| } | ||
@@ -15,0 +16,0 @@ } |
@@ -8,3 +8,3 @@ | ||
| */ | ||
| function arrayClearOther(list: any[], index: number, startIndex = 0) { | ||
| function arrayClearOther(list: unknown[], index: number, startIndex = 0) { | ||
| if (list.length - 1 >= index) { | ||
@@ -11,0 +11,0 @@ // 删除index + 1到结束 |
@@ -0,1 +1,2 @@ | ||
| /* eslint-disable @typescript-eslint/no-explicit-any */ | ||
@@ -2,0 +3,0 @@ /** |
@@ -6,3 +6,3 @@ | ||
| */ | ||
| function clearArray(list: any[]) { | ||
| function clearArray(list: unknown[]) { | ||
| list.splice(0, list.length) | ||
@@ -9,0 +9,0 @@ } |
@@ -10,9 +10,9 @@ import { ComplexType } from '../type/getComplexType' | ||
| */ | ||
| function formatDataByType(value: any, type: 'boolean'): boolean | ||
| function formatDataByType(value: any, type: 'number'): number | ||
| function formatDataByType<T>(value: T, type?: Exclude<ComplexType, 'boolean' | 'number'>): T | ||
| function formatDataByType<T>(value: T, type?: ComplexType) { | ||
| if (type == 'boolean') { | ||
| function formatDataByType(value: unknown, type: 'boolean'): boolean | ||
| function formatDataByType(value: unknown, type: 'number'): number | ||
| function formatDataByType(value: unknown, type?: Exclude<ComplexType, 'boolean' | 'number'>): unknown | ||
| function formatDataByType(value: unknown, type?: ComplexType) { | ||
| if (type === 'boolean') { | ||
| return !!value | ||
| } else if (type == 'number') { | ||
| } else if (type === 'number') { | ||
| return getNum(value, 'origin') | ||
@@ -19,0 +19,0 @@ } else { |
@@ -0,1 +1,2 @@ | ||
| /* eslint-disable @typescript-eslint/no-explicit-any */ | ||
@@ -59,3 +60,3 @@ type formatType = (originItem: Record<PropertyKey, any>) => Record<PropertyKey, any> | ||
| } | ||
| assignItem(id: PropertyKey, parentId: any, originData: Record<PropertyKey, any>) { | ||
| assignItem(id: PropertyKey, parentId: PropertyKey, originData: Record<PropertyKey, any>) { | ||
| const targetItem = this.$assignItem(id, originData) | ||
@@ -62,0 +63,0 @@ this.$appendItem(targetItem, parentId) |
@@ -0,1 +1,2 @@ | ||
| /* eslint-disable @typescript-eslint/no-explicit-any */ | ||
| import isExist from './../type/isExist' | ||
@@ -12,3 +13,3 @@ | ||
| */ | ||
| function getDefaultData(value: any, prop: string, defaultData?: any, existList?: any[], unExistList?: any[]) { | ||
| function getDefaultData(value: undefined | null | Record<PropertyKey, any>, prop: PropertyKey, defaultData?: any, existList?: any[], unExistList?: any[]) { | ||
| if (value && isExist(value[prop], existList, unExistList)) { | ||
@@ -15,0 +16,0 @@ return value[prop] |
@@ -11,2 +11,3 @@ import getPropByList from './getPropByList' | ||
| */ | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| function getProp(value: undefined | Record<PropertyKey, any>, prop: string, intervalRepeat = false, showError?: boolean) { | ||
@@ -13,0 +14,0 @@ if (!value || !prop) { |
@@ -0,1 +1,2 @@ | ||
| /* eslint-disable @typescript-eslint/no-explicit-any */ | ||
| /** | ||
@@ -2,0 +3,0 @@ * 根据属性列表获取对象属性 |
@@ -9,3 +9,3 @@ const hasOwnProperty = Object.prototype.hasOwnProperty | ||
| */ | ||
| function hasProp(value: Record<PropertyKey, any>, prop: string): boolean { | ||
| function hasProp(value: Record<PropertyKey, unknown>, prop: string): boolean { | ||
| if (value[prop] === undefined) { | ||
@@ -12,0 +12,0 @@ if (!hasOwnProperty.call(value, prop)) { |
@@ -8,2 +8,3 @@ import getComplexType from './../type/getComplexType' | ||
| */ | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| function jsonToForm(jsonData: Record<PropertyKey, any>): FormData { | ||
@@ -10,0 +11,0 @@ const formData = new FormData() |
@@ -9,3 +9,3 @@ import getProp from './getProp' | ||
| */ | ||
| function orderArrayByProp(list: Record<PropertyKey, any>[], prop: string, ruleList: any[]) { | ||
| function orderArrayByProp(list: Record<PropertyKey, unknown>[], prop: string, ruleList: unknown[]) { | ||
| for (let i = 0; i < ruleList.length; i++) { | ||
@@ -12,0 +12,0 @@ const ruleData = ruleList[i] |
@@ -0,1 +1,2 @@ | ||
| /* eslint-disable @typescript-eslint/no-explicit-any */ | ||
| import getType from '../type/getType' | ||
@@ -2,0 +3,0 @@ import $exportMsg from '../utils/$exportMsg' |
@@ -0,1 +1,2 @@ | ||
| /* eslint-disable @typescript-eslint/no-explicit-any */ | ||
| import getType from '../type/getType' | ||
@@ -2,0 +3,0 @@ import isExist from '../type/isExist' |
@@ -0,1 +1,2 @@ | ||
| /* eslint-disable @typescript-eslint/no-explicit-any */ | ||
| import setPropByList from './setPropByList' | ||
@@ -2,0 +3,0 @@ |
@@ -0,1 +1,2 @@ | ||
| /* eslint-disable @typescript-eslint/no-explicit-any */ | ||
| import config from '../../config' | ||
@@ -2,0 +3,0 @@ |
@@ -0,1 +1,2 @@ | ||
| /* eslint-disable @typescript-eslint/no-explicit-any */ | ||
| import { ComplexType } from '../type/getComplexType' | ||
@@ -2,0 +3,0 @@ import formatDataByType from './formatDataByType' |
@@ -8,11 +8,11 @@ import getProp from './getProp' | ||
| */ | ||
| function showArrayProp(list: Record<PropertyKey, any>, prop: string) { | ||
| const proplist = [] | ||
| function showArrayProp(list: Record<PropertyKey, unknown>[], prop: string) { | ||
| const propList = [] | ||
| for (let i = 0; i < list.length; i++) { | ||
| const item = list[i] | ||
| proplist.push(getProp(item, prop)) | ||
| propList.push(getProp(item, prop)) | ||
| } | ||
| console.log(JSON.stringify(proplist)) | ||
| console.log(JSON.stringify(propList)) | ||
| } | ||
| export default showArrayProp |
@@ -9,3 +9,3 @@ import getType from './getType' | ||
| */ | ||
| function checkComplex(value: any): value is object | Array<any> { | ||
| function checkComplex(value: unknown): value is object | Array<unknown> { | ||
| const type = getType(value) | ||
@@ -12,0 +12,0 @@ return isComplex(type) |
@@ -11,3 +11,3 @@ import getType, { SimpleType } from './getType' | ||
| */ | ||
| function getComplexType(value: any): ComplexType { | ||
| function getComplexType(value: unknown): ComplexType { | ||
| const type = getType (value) | ||
@@ -14,0 +14,0 @@ if (type === 'object') { |
@@ -10,3 +10,3 @@ const toString = Object.prototype.toString | ||
| */ | ||
| function getTag(value: any) { | ||
| function getTag(value: unknown) { | ||
| return toString.call(value) | ||
@@ -13,0 +13,0 @@ } |
@@ -10,3 +10,3 @@ import isArray from './isArray' | ||
| */ | ||
| function getType(value: any): SimpleType { | ||
| function getType(value: unknown): SimpleType { | ||
| const type = typeof (value) | ||
@@ -13,0 +13,0 @@ if (type === 'object') { |
@@ -8,5 +8,4 @@ import getTag from './getTag' | ||
| */ | ||
| const isArray = Array.isArray ? function(value: any): value is Array<any> { return Array.isArray(value) } : function(value: any): value is Array<any> { return getTag(value) === '[object Array]' } | ||
| const isArray = Array.isArray ? function(value: unknown): value is Array<unknown> { return Array.isArray(value) } : function(value: unknown): value is Array<unknown> { return getTag(value) === '[object Array]' } | ||
| export default isArray |
@@ -8,3 +8,3 @@ import getTag from './getTag' | ||
| */ | ||
| function isBlob(value: any): value is Blob { | ||
| function isBlob(value: unknown): value is Blob { | ||
| return getTag(value) === '[object Blob]' | ||
@@ -11,0 +11,0 @@ } |
@@ -8,3 +8,3 @@ import getTag from './getTag' | ||
| */ | ||
| function isDate(value: any): value is Date { | ||
| function isDate(value: unknown): value is Date { | ||
| return getTag(value) === '[object Date]' | ||
@@ -11,0 +11,0 @@ } |
@@ -1,2 +0,1 @@ | ||
| import config from '../../config' | ||
| import getType from './getType' | ||
@@ -6,2 +5,4 @@ import isEmptyArray from './isEmptyArray' | ||
| type emptyCheckList = 'object' | 'array' | ||
| const dict = { | ||
@@ -18,3 +19,3 @@ object: isEmptyObject, | ||
| */ | ||
| function isEmpty(value: any, checkList?: string[]) { | ||
| function isEmpty(value: unknown, checkList?: emptyCheckList[]) { | ||
| if (!value) { | ||
@@ -25,7 +26,7 @@ // undefined null '' 0 false | ||
| if (!checkList) { | ||
| checkList = config.type.emptyCheckList | ||
| checkList = ['object', 'array'] | ||
| } | ||
| const type = getType(value) | ||
| if (checkList.indexOf(type) > -1 && (dict as any)[type]) { | ||
| return (dict as any)[type](value, type) | ||
| if (checkList.indexOf(type as emptyCheckList) > -1 && dict[type as emptyCheckList]) { | ||
| return dict[type as emptyCheckList](value, type) | ||
| } else { | ||
@@ -32,0 +33,0 @@ return false |
@@ -1,2 +0,2 @@ | ||
| import getType from './getType' | ||
| import isArray from './isArray' | ||
@@ -9,8 +9,5 @@ /** | ||
| */ | ||
| function isEmptyArray(value: any, type?: string): value is [] { | ||
| if (!type) { | ||
| type = getType(value) | ||
| } | ||
| if (type === 'array') { | ||
| return value.length === 0 | ||
| function isEmptyArray(value: unknown, type?: string): value is [] { | ||
| if (type === 'array' || isArray(value)) { | ||
| return (value as unknown[]).length === 0 | ||
| } else { | ||
@@ -17,0 +14,0 @@ return false |
@@ -9,3 +9,3 @@ import getType from './getType' | ||
| */ | ||
| function isEmptyObject(value: any, type?: string): value is Record<string, never> { | ||
| function isEmptyObject(value: unknown, type?: string): value is Record<string, never> { | ||
| if (!type) { | ||
@@ -15,3 +15,3 @@ type = getType(value) | ||
| if (type === 'object') { | ||
| for (const n in value) { | ||
| for (const n in value as Record<PropertyKey, unknown>) { | ||
| return false | ||
@@ -18,0 +18,0 @@ } |
@@ -8,3 +8,3 @@ import getTag from './getTag' | ||
| */ | ||
| function isError(value: any): value is Error { | ||
| function isError(value: unknown): value is Error { | ||
| const tag = getTag(value) | ||
@@ -11,0 +11,0 @@ return tag === '[object Error]' || tag === '[object DOMException]' |
@@ -0,1 +1,2 @@ | ||
| /* eslint-disable @typescript-eslint/no-explicit-any */ | ||
| import config from '../../config'; | ||
@@ -11,3 +12,3 @@ import isSame from './isSame'; | ||
| */ | ||
| function isExist(value: any, existList?: any[], unExistList?: any[]) { | ||
| function isExist(value: unknown, existList?: any[], unExistList?: any[]) { | ||
| if (value) { | ||
@@ -14,0 +15,0 @@ if (unExistList) { |
@@ -8,3 +8,3 @@ import getTag from './getTag' | ||
| */ | ||
| function isFile(value: any): value is File { | ||
| function isFile(value: unknown): value is File { | ||
| return getTag(value) === '[object File]' | ||
@@ -11,0 +11,0 @@ } |
@@ -9,3 +9,3 @@ import getTag from './getTag' | ||
| */ | ||
| function isPromise(value: any): value is Promise<any> { | ||
| function isPromise(value: unknown): value is Promise<unknown> { | ||
| if (getTag(value) === '[object Promise]') { | ||
@@ -16,3 +16,4 @@ return true | ||
| if (type === 'object' || type === 'function') { | ||
| return typeof value.then === 'function' | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| return typeof (value as any).then === 'function' | ||
| } | ||
@@ -19,0 +20,0 @@ return false |
@@ -8,3 +8,3 @@ import getTag from './getTag' | ||
| */ | ||
| function isRegExp(value: any): value is RegExp { | ||
| function isRegExp(value: unknown): value is RegExp { | ||
| return getTag(value) === '[object RegExp]' | ||
@@ -11,0 +11,0 @@ } |
@@ -0,1 +1,2 @@ | ||
| /* eslint-disable @typescript-eslint/no-explicit-any */ | ||
| import getType from './getType' | ||
@@ -2,0 +3,0 @@ |
@@ -8,3 +8,3 @@ import getTag from './getTag' | ||
| */ | ||
| function isSymbol(value: any): value is symbol { | ||
| function isSymbol(value: unknown): value is symbol { | ||
| return getTag(value) === '[object Symbol]' || typeof value === 'symbol' | ||
@@ -11,0 +11,0 @@ } |
@@ -1,2 +0,2 @@ | ||
| import exportMsg, { consoleType, exportOption } from './exportMsg' | ||
| import exportMsg, { consoleType } from './exportMsg' | ||
| /** | ||
@@ -6,11 +6,8 @@ * complex-plugin错误信息输出函数 | ||
| * @param {'error' | 'warn' | 'log'} [type = error] 信息提示类型 | ||
| * @param {object} [option = {}] 额外信息设置项 | ||
| * @param {string} [option.data] 额外信息内容 | ||
| * @param {'error' | 'warn' | 'log'} [option.type] 额外信息提示类型 | ||
| */ | ||
| function $exportMsg(msg: string, type?: consoleType, option?: exportOption) { | ||
| function $exportMsg(msg: string, type?: consoleType) { | ||
| const preMsg = '[complex-plugin]' | ||
| exportMsg(preMsg + msg, type, option) | ||
| exportMsg(preMsg + msg, type) | ||
| } | ||
| export default $exportMsg |
@@ -12,12 +12,4 @@ import downloadFile from './downloadFile' | ||
| */ | ||
| function downloadBlob(blobValue: any, type: string, name?: string) { | ||
| let blob | ||
| if (typeof window.Blob == 'function') { | ||
| blob = new Blob([blobValue], { type: type }) | ||
| } else { | ||
| const BlobBuilder = (window as any).MSBlobBuilder | ||
| const blobData = new BlobBuilder() | ||
| blobData.append(blobValue) | ||
| blob = blobData.getBlob(type) | ||
| } | ||
| function downloadBlob(blobValue: BlobPart, type: string, name?: string) { | ||
| const blob = new Blob([blobValue], { type: type }) | ||
| const url = URL.createObjectURL(blob) | ||
@@ -24,0 +16,0 @@ downloadFile(url, name) |
@@ -5,7 +5,2 @@ import isError from '../type/isError' | ||
| export type exportOption = { | ||
| data: string | Record<PropertyKey, any> | Error, | ||
| type?: consoleType | ||
| } | ||
| /** | ||
@@ -19,8 +14,6 @@ * 错误信息输出函数 | ||
| */ | ||
| function exportMsg(msg: string | Error | Record<PropertyKey, any>, type: consoleType = 'error', option?: exportOption) { | ||
| function exportMsg(msg: string | Error | Record<PropertyKey, unknown>, type: consoleType = 'error') { | ||
| if (type == 'error') { | ||
| if (isError(msg)) { | ||
| if (isError(msg) || typeof msg === 'object') { | ||
| console[type](msg) | ||
| } else if (typeof(msg) === 'object') { | ||
| console[type](msg) | ||
| } else { | ||
@@ -32,10 +25,4 @@ console[type](new Error(msg)) | ||
| } | ||
| if (option && option.data) { | ||
| if (!option.type) { | ||
| option.type = type | ||
| } | ||
| console[option.type](option.data) | ||
| } | ||
| } | ||
| export default exportMsg |
@@ -10,8 +10,3 @@ import localEncodeURIComponent from './localEncodeURIComponent' | ||
| function formatQueryUrl(url: string, data: Record<PropertyKey, string>) { | ||
| const type = url.indexOf('?') > -1 ? 'extra' : 'init' | ||
| if (type == 'init') { | ||
| url += '?' | ||
| } else if (type == 'extra') { | ||
| url += '&' | ||
| } | ||
| url = url.indexOf('?') > -1 ? url += '&' : url += '?' | ||
| for (const n in data) { | ||
@@ -18,0 +13,0 @@ url = url + n + '=' + localEncodeURIComponent(data[n]) |
| import triggerFunc from '../function/triggerFunction' | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| type fnType = (mod: any, path:string, index: number) => void | ||
@@ -4,0 +5,0 @@ |
@@ -19,2 +19,3 @@ | ||
| if (download === true) { | ||
| // eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
| download = url.split('/').pop()! | ||
@@ -21,0 +22,0 @@ } |
@@ -6,3 +6,3 @@ | ||
| */ | ||
| function showJson(value: Record<PropertyKey, any>) { | ||
| function showJson(value: Record<PropertyKey, unknown>) { | ||
| console.log(JSON.stringify(value)) | ||
@@ -9,0 +9,0 @@ } |
@@ -8,6 +8,6 @@ import getType from './../type/getType' | ||
| */ | ||
| function trimData(data: any) { | ||
| function trimData(data: unknown) { | ||
| const type = getType(data) | ||
| if (type == 'string') { | ||
| data = data.trim() | ||
| if (type === 'string') { | ||
| data = (data as string).trim() | ||
| } | ||
@@ -14,0 +14,0 @@ return data |
85679
1.17%2466
-0.12%