@univerjs/core v0.4.2 • Docs
Class: Tools
Universal tool library
Constructors
new Tools()
new Tools(): Tools
Returns
Methods
ABCatNum()
static ABCatNum(a): number
Column subscript letter to number
Parameters
Parameter | Type | Description |
---|---|---|
a | string | Column subscript letter,e.g.,"A1" |
Returns
number
Column subscript number,e.g.,0
Defined in
submodules/univer/packages/core/src/shared/tools.ts:563 (opens in a new tab)
arrayToObject()
static arrayToObject(array): IKeyValue
Parameters
Parameter | Type |
---|---|
array | IKeyValue [][] |
Returns
IKeyValue
Defined in
submodules/univer/packages/core/src/shared/tools.ts:651 (opens in a new tab)
camelCase()
static camelCase(str): string
Parameters
Parameter | Type |
---|---|
str | string |
Returns
string
Defined in
submodules/univer/packages/core/src/shared/tools.ts:489 (opens in a new tab)
capitalize()
static capitalize(str): string
Parameters
Parameter | Type |
---|---|
str | string |
Returns
string
Defined in
submodules/univer/packages/core/src/shared/tools.ts:477 (opens in a new tab)
chatAtABC()
static chatAtABC(n): string
en: Column subscript number to letter
zh: 列下标 数字转字母
Parameters
Parameter | Type | Description |
---|---|---|
n | number | Column subscript number,e.g.,0 |
Returns
string
Column subscript letter,e.g.,"A1"
Defined in
submodules/univer/packages/core/src/shared/tools.ts:590 (opens in a new tab)
clamp()
static clamp(
value,
min,
max): number
Parameters
Parameter | Type |
---|---|
value | number |
min | number |
max | number |
Returns
number
Defined in
submodules/univer/packages/core/src/shared/tools.ts:690 (opens in a new tab)
commonExtend()
static commonExtend<T>(originJson, extendJson): T
extend two objects
Type Parameters
Type Parameter |
---|
T |
Parameters
Parameter | Type |
---|---|
originJson | IKeyValue |
extendJson | IKeyValue |
Returns
T
Defined in
submodules/univer/packages/core/src/shared/tools.ts:624 (opens in a new tab)
commonExtend1()
static commonExtend1<T>(originJson, extendJson): T
Type Parameters
Type Parameter |
---|
T |
Parameters
Parameter | Type |
---|---|
originJson | IKeyValue |
extendJson | IKeyValue |
Returns
T
Defined in
submodules/univer/packages/core/src/shared/tools.ts:642 (opens in a new tab)
deepClone()
static deepClone<T>(value): T
Type Parameters
Type Parameter | Default type |
---|---|
T | unknown |
Parameters
Parameter | Type |
---|---|
value | T |
Returns
T
Defined in
submodules/univer/packages/core/src/shared/tools.ts:314 (opens in a new tab)
deepMerge()
static deepMerge(target, ...sources): any
Parameters
Parameter | Type |
---|---|
target | any |
...sources | any [] |
Returns
any
Defined in
submodules/univer/packages/core/src/shared/tools.ts:244 (opens in a new tab)
deleteBlank()
static deleteBlank(value?): undefined | string
Parameters
Parameter | Type |
---|---|
value ? | string |
Returns
undefined
| string
Defined in
submodules/univer/packages/core/src/shared/tools.ts:143 (opens in a new tab)
diffValue()
static diffValue(one, two): boolean
Parameters
Parameter | Type |
---|---|
one | any |
two | any |
Returns
boolean
Defined in
submodules/univer/packages/core/src/shared/tools.ts:310 (opens in a new tab)
fCamelCase()
static fCamelCase(_all, letter): string
Parameters
Parameter | Type |
---|---|
_all | any |
letter | string |
Returns
string
Defined in
submodules/univer/packages/core/src/shared/tools.ts:482 (opens in a new tab)
fillTwoDimensionalArray()
static fillTwoDimensionalArray(
rows,
columns,
value): any[][]
Generate a two-dimensional array with the specified number of rows and columns, and fill in the values
Parameters
Parameter | Type | Description |
---|---|---|
rows | number | row length |
columns | number | column length |
value | any | value to be set |
Returns
any
[][]
Defined in
submodules/univer/packages/core/src/shared/tools.ts:519 (opens in a new tab)
generateRandomId()
static generateRandomId(n, alphabet?): string
Use this method without Tools
.
Parameters
Parameter | Type | Default value |
---|---|---|
n | number | 21 |
alphabet ? | string | undefined |
Returns
string
Deprecated
Defined in
submodules/univer/packages/core/src/shared/tools.ts:236 (opens in a new tab)
getBrowserType()
static getBrowserType(): string
Returns
string
Defined in
submodules/univer/packages/core/src/shared/tools.ts:183 (opens in a new tab)
getClassName()
static getClassName(instance): string
Parameters
Parameter | Type |
---|---|
instance | object |
Returns
string
Defined in
submodules/univer/packages/core/src/shared/tools.ts:240 (opens in a new tab)
getLanguage()
static getLanguage(): string
Returns
string
Defined in
submodules/univer/packages/core/src/shared/tools.ts:344 (opens in a new tab)
getSystemType()
static getSystemType(): string
Returns
string
Defined in
submodules/univer/packages/core/src/shared/tools.ts:151 (opens in a new tab)
getValueType()
static getValueType(value): string
Parameters
Parameter | Type |
---|---|
value | any |
Returns
string
Defined in
submodules/univer/packages/core/src/shared/tools.ts:352 (opens in a new tab)
hasIntersectionBetweenTwoRanges()
static hasIntersectionBetweenTwoRanges(
range1Start,
range1End,
range2Start,
range2End): boolean
Parameters
Parameter | Type |
---|---|
range1Start | number |
range1End | number |
range2Start | number |
range2End | number |
Returns
boolean
Defined in
submodules/univer/packages/core/src/shared/tools.ts:662 (opens in a new tab)
hasLength()
static hasLength(target, length?): boolean
Parameters
Parameter | Type |
---|---|
target | string | IArguments | any [] |
length ? | number |
Returns
boolean
Defined in
submodules/univer/packages/core/src/shared/tools.ts:467 (opens in a new tab)
indexAt()
static indexAt(code): number
Parameters
Parameter | Type |
---|---|
code | string |
Returns
number
Defined in
submodules/univer/packages/core/src/shared/tools.ts:132 (opens in a new tab)
isAndroid()
static isAndroid(): boolean
Returns
boolean
Defined in
submodules/univer/packages/core/src/shared/tools.ts:442 (opens in a new tab)
isArray()
static isArray<T>(value?): value is T[]
Type Parameters
Type Parameter |
---|
T |
Parameters
Parameter | Type |
---|---|
value ? | any |
Returns
value is T[]
Defined in
submodules/univer/packages/core/src/shared/tools.ts:393 (opens in a new tab)
isBlank()
static isBlank(value): boolean
Parameters
Parameter | Type |
---|---|
value | any |
Returns
boolean
Defined in
submodules/univer/packages/core/src/shared/tools.ts:360 (opens in a new tab)
isBoolean()
static isBoolean(value?): value is boolean
Parameters
Parameter | Type |
---|---|
value ? | any |
Returns
value is boolean
Defined in
submodules/univer/packages/core/src/shared/tools.ts:370 (opens in a new tab)
isDate()
static isDate(value?): value is Date
Parameters
Parameter | Type |
---|---|
value ? | Date |
Returns
value is Date
Defined in
submodules/univer/packages/core/src/shared/tools.ts:385 (opens in a new tab)
isDefine()
static isDefine<T>(value?): value is T
Type Parameters
Type Parameter |
---|
T |
Parameters
Parameter | Type |
---|---|
value ? | void | T |
Returns
value is T
Defined in
submodules/univer/packages/core/src/shared/tools.ts:356 (opens in a new tab)
isEmptyObject()
static isEmptyObject(value?): boolean
Parameters
Parameter | Type |
---|---|
value ? | any |
Returns
boolean
Defined in
submodules/univer/packages/core/src/shared/tools.ts:413 (opens in a new tab)
isFunction()
static isFunction(value?): value is boolean
Parameters
Parameter | Type |
---|---|
value ? | any |
Returns
value is boolean
Defined in
submodules/univer/packages/core/src/shared/tools.ts:381 (opens in a new tab)
isIPhone()
static isIPhone(): boolean
Returns
boolean
Defined in
submodules/univer/packages/core/src/shared/tools.ts:447 (opens in a new tab)
isLegalUrl()
static isLegalUrl(url): boolean
Parameters
Parameter | Type |
---|---|
url | string |
Returns
boolean
Defined in
submodules/univer/packages/core/src/shared/tools.ts:451 (opens in a new tab)
isMobile()
static isMobile(): boolean
Returns
boolean
Defined in
submodules/univer/packages/core/src/shared/tools.ts:421 (opens in a new tab)
isNumber()
static isNumber(value?): value is number
Parameters
Parameter | Type |
---|---|
value ? | any |
Returns
value is number
Defined in
submodules/univer/packages/core/src/shared/tools.ts:401 (opens in a new tab)
isObject()
static isObject<T>(value?): value is T
Type Parameters
Type Parameter |
---|
T |
Parameters
Parameter | Type |
---|---|
value ? | any |
Returns
value is T
Defined in
submodules/univer/packages/core/src/shared/tools.ts:409 (opens in a new tab)
isPlainObject()
static isPlainObject(value): value is object
Parameters
Parameter | Type |
---|---|
value | any |
Returns
value is object
Defined in
submodules/univer/packages/core/src/shared/tools.ts:374 (opens in a new tab)
isRegExp()
static isRegExp(value?): value is RegExp
Parameters
Parameter | Type |
---|---|
value ? | any |
Returns
value is RegExp
Defined in
submodules/univer/packages/core/src/shared/tools.ts:389 (opens in a new tab)
isStartValidPosition()
static isStartValidPosition(name): boolean
Parameters
Parameter | Type |
---|---|
name | string |
Returns
boolean
Defined in
submodules/univer/packages/core/src/shared/tools.ts:671 (opens in a new tab)
isString()
static isString(value?): value is string
Parameters
Parameter | Type |
---|---|
value ? | any |
Returns
value is string
Defined in
submodules/univer/packages/core/src/shared/tools.ts:397 (opens in a new tab)
isStringNumber()
static isStringNumber(value?): boolean
Parameters
Parameter | Type |
---|---|
value ? | any |
Returns
boolean
Defined in
submodules/univer/packages/core/src/shared/tools.ts:405 (opens in a new tab)
isTablet()
static isTablet(): boolean
Returns
boolean
Defined in
submodules/univer/packages/core/src/shared/tools.ts:433 (opens in a new tab)
isValidParameter()
static isValidParameter(name): boolean
Parameters
Parameter | Type |
---|---|
name | string |
Returns
boolean
Defined in
submodules/univer/packages/core/src/shared/tools.ts:677 (opens in a new tab)
isWeChat()
static isWeChat(): boolean
Returns
boolean
Defined in
submodules/univer/packages/core/src/shared/tools.ts:437 (opens in a new tab)
itCount()
static itCount(count): Function
Parameters
Parameter | Type |
---|---|
count | number |
Returns
Function
Defined in
submodules/univer/packages/core/src/shared/tools.ts:459 (opens in a new tab)
normalizeUrl()
static normalizeUrl(url): string
Parameters
Parameter | Type |
---|---|
url | string |
Returns
string
Defined in
submodules/univer/packages/core/src/shared/tools.ts:455 (opens in a new tab)
now()
static now(): number
Returns
number
Defined in
submodules/univer/packages/core/src/shared/tools.ts:694 (opens in a new tab)
numToWord()
static numToWord(x): string
Generate a two-dimensional array with the specified number of rows and columns, and fill in the values
Parameters
Parameter | Type |
---|---|
x | number |
Returns
string
Defined in
submodules/univer/packages/core/src/shared/tools.ts:540 (opens in a new tab)
numberFixed()
static numberFixed(value, digit): number
Parameters
Parameter | Type |
---|---|
value | number |
digit | number |
Returns
number
Defined in
submodules/univer/packages/core/src/shared/tools.ts:306 (opens in a new tab)
randSort()
static randSort<T>(arr): T[]
Type Parameters
Type Parameter |
---|
T |
Parameters
Parameter | Type |
---|---|
arr | T [] |
Returns
T
[]
Defined in
submodules/univer/packages/core/src/shared/tools.ts:608 (opens in a new tab)
removeNull()
static removeNull(value): object
remove all null from object
Parameters
Parameter | Type |
---|---|
value | IKeyValue |
Returns
object
Defined in
submodules/univer/packages/core/src/shared/tools.ts:498 (opens in a new tab)
stringAt()
static stringAt(index): string
Parameters
Parameter | Type |
---|---|
index | number |
Returns
string
Defined in
submodules/univer/packages/core/src/shared/tools.ts:119 (opens in a new tab)