API Reference
@univerjs
@univerjs/core
classes
Tools

@univerjs/core v0.4.2Docs


Class: Tools

Universal tool library

Constructors

new Tools()

new Tools(): Tools

Returns

Tools

Methods

ABCatNum()

static ABCatNum(a): number

Column subscript letter to number

Parameters

ParameterTypeDescription
astringColumn 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

ParameterType
arrayIKeyValue[][]

Returns

IKeyValue

Defined in

submodules/univer/packages/core/src/shared/tools.ts:651 (opens in a new tab)


camelCase()

static camelCase(str): string

Parameters

ParameterType
strstring

Returns

string

Defined in

submodules/univer/packages/core/src/shared/tools.ts:489 (opens in a new tab)


capitalize()

static capitalize(str): string

Parameters

ParameterType
strstring

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

ParameterTypeDescription
nnumberColumn 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

ParameterType
valuenumber
minnumber
maxnumber

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

ParameterType
originJsonIKeyValue
extendJsonIKeyValue

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

ParameterType
originJsonIKeyValue
extendJsonIKeyValue

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 ParameterDefault type
Tunknown

Parameters

ParameterType
valueT

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

ParameterType
targetany
...sourcesany[]

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

ParameterType
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

ParameterType
oneany
twoany

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

ParameterType
_allany
letterstring

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

ParameterTypeDescription
rowsnumberrow length
columnsnumbercolumn length
valueanyvalue 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

ParameterTypeDefault value
nnumber21
alphabet?stringundefined

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

ParameterType
instanceobject

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

ParameterType
valueany

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

ParameterType
range1Startnumber
range1Endnumber
range2Startnumber
range2Endnumber

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

ParameterType
targetstring | 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

ParameterType
codestring

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

ParameterType
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

ParameterType
valueany

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

ParameterType
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

ParameterType
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

ParameterType
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

ParameterType
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

ParameterType
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

ParameterType
urlstring

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

ParameterType
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

ParameterType
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

ParameterType
valueany

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

ParameterType
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

ParameterType
namestring

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

ParameterType
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

ParameterType
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

ParameterType
namestring

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

ParameterType
countnumber

Returns

Function

Defined in

submodules/univer/packages/core/src/shared/tools.ts:459 (opens in a new tab)


normalizeUrl()

static normalizeUrl(url): string

Parameters

ParameterType
urlstring

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

ParameterType
xnumber

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

ParameterType
valuenumber
digitnumber

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

ParameterType
arrT[]

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

ParameterType
valueIKeyValue

Returns

object

Defined in

submodules/univer/packages/core/src/shared/tools.ts:498 (opens in a new tab)


stringAt()

static stringAt(index): string

Parameters

ParameterType
indexnumber

Returns

string

Defined in

submodules/univer/packages/core/src/shared/tools.ts:119 (opens in a new tab)


Copyright © 2021-2024 DreamNum Co,Ltd. All Rights Reserved.