API / geotoolkit / base

Module: base

Table of contents

Type Aliases
Variables
Functions

Contents

Type Aliases

AnyRecord

Ƭ AnyRecord: Record<PropertyKey, unknown>

Any js object with the record-like type


CamelToKebabCase

Ƭ CamelToKebabCase<S>: S extends `${infer T}${infer U}` ? `${T extends Capitalize<T> ? "-" : ""}${Lowercase<T>}${CamelToKebabCase<U>}` : S

Type parameters

NameType
Sextends string

ClassType

Ƭ ClassType<T>: Function & { prototype: T }

Type parameters

NameType
Tany

Constructable

Ƭ Constructable<T>: (...args: any) => T

Type parameters

NameType
Tany

Type declaration

• (...args)

Parameters
Name Type
...argsany

Constructor

Ƭ Constructor<T>: (...args: any) => T

Type parameters

NameType
Tany

Type declaration

• (...args)

Parameters
Name Type
...argsany

DeepMerge

Ƭ DeepMerge<T, U>: U extends AnyRecord ? T extends AnyRecord ? { [K in keyof U]: K extends keyof T ? DeepMerge<T[K], U[K]> : U[K] } & Omit<T, keyof U> : U : U

Recursively merge types by second type parameter properties substitution

Type parameters

Name
T
U

DeepPartial

Ƭ DeepPartial<T>: T extends AnyRecord ? { [K in keyof T]?: DeepPartial<T[K]> } : T

Recursively make record properties partial

Type parameters

Name
T

DeepRequired

Ƭ DeepRequired<T>: T extends AnyRecord ? { [K in keyof T]-?: DeepRequired<T[K]> } : T

Recursively make record properties required

Type parameters

Name
T

EmptyRecord

Ƭ EmptyRecord: Record<PropertyKey, never>

Empty js object with the record-like type


KeysToKebabCase

Ƭ KeysToKebabCase<T>: { [K in keyof T as CamelToKebabCase<string & K>]: T[K] }

Transform keys in CamelCase into kebab-case

Type parameters

Name
T

Merge

Ƭ Merge<T, U>: Omit<T, keyof U> & U

Shallow merge types by properties substitution

Type parameters

NameType
Textends AnyRecord
Uextends AnyRecord

ToDeepLowercase

Ƭ ToDeepLowercase<T>: T extends AnyRecord ? { [K in string & keyof T as Lowercase<K>]: ToDeepLowercase<T[K]> } : T

Recursively toggle lowercase for the property names.

Type parameters

Name
T

ToLowercase

Ƭ ToLowercase<T>: { [Key in keyof T & string as Lowercase<Key>]: T[Key] }

Toggle lowercase for the property names, one level only.

Type parameters

NameType
Textends AnyRecord

ToRecord

Ƭ ToRecord<T>: { [K in keyof T]: T[K] }

Makes interface, class, etc, looks like Record<,> for the typescript type system

Type parameters

Name
T
Variables

logLevel

Const logLevel: number

Functions

abstractMethod

abstractMethod(): never

This method is used to mark a method, which does not have implementation. By default, it throws exception that method is not implemented.

Throws

when invoked to indicate the method should be overridden.

Returns

never


addWatermark

addWatermark(text, color, size): void

Parameters

Name Type
textstring
colorstring
sizestring

Returns

void


convertCssToCanvas

convertCssToCanvas(size): number

Converts css size to canvas size

Parameters

Name Type Description
sizenumbercanvas size

Returns

number


createCopy

createCopy<T>(obj, target?, param?): T

Create copy of the object

Type parameters

NameType
Tany

Parameters

Name Type Description
objTobject to copy
Optional targetTtarget
Optional paramanyparam to be passed to copy constructor

Returns

T

a copy of the input object


deepArrayCopy

deepArrayCopy<T>(array, lowercase?): T

Create a deep copy of array

Type parameters

Name
T

Parameters

Name Type Description
arrayTarray of object or primitive types
Optional lowercasebooleanoptional parameters to convert properties of object to lower case

Returns

T

a new instance of objects' array


deepMergeObject

deepMergeObject(options, result?, lowercase?): any

Deep merge object method is the same as mergeObject method , except it supports nested objects.

Parameters

Name Type Description
optionsanyan object to merge properties.
Optional resultanyObject to merge properties from options
Optional lowercasebooleanmerge all properties to lower case. if this flag is set then result will have all properties in lower case

Returns

any


dummyMethod

dummyMethod(): void

Does nothing. Intended to use as a default implementation of the optional method.

Returns

void


enableRenderNativeResolution

enableRenderNativeResolution(enabled): void

Enables render using native resolution

Parameters

Name Type Description
enabledbooleandevice pixel ratio is set based on this flag

Returns

void


error

error(...args): void

Print in console error message. Passes on all parameters as passed.

Parameters

Name Type Description
...argsany[]a list of objects to output. The string representations of each of these objects are appended together in the order listed and output

Returns

void


getBaseClassName

getBaseClassName(className): string

Return a base class name if it exists

Parameters

Name Type Description
classNamestringclass name

Returns

string


getClassType

getClassType(className): ClassType<any>

Returns class constructor of the class, which is specified as string with full namespace.

Parameters

Name Type Description
classNamestringclass name to get the type for

Returns

ClassType<any>

constructor of the specified type


getFullVersion

getFullVersion(): string

Return the current version with full information

Returns

string


getObjectClassName

getObjectClassName(obj): string

Return an object class name

Parameters

Name Type Description
objanyobject to return a class name

Returns

string


getPixelScale

getPixelScale(): number

Returns pixel scale on current device

Returns

number


getResource

getResource(moduleName, resourceName): any

Return a resource for the current module and resource name.

Deprecated

since 4.0. Use external storage instead.

Parameters

Name Type Description
moduleNamestringcurrent module
resourceNamestringresource name

Returns

any


getVersion

getVersion(): string

Return the current version

Returns

string


implementsInterface

implementsInterface(childClass, parentInterface): void

Declares "childClass" to implement "parentInterface"

Parameters

Name Type Description
childClassClassType<any>child class
parentInterfaceClassType<any>parent interface

Returns

void


info

info(...args): void

Print in console info message. Passes on all parameters as passed.

Parameters

Name Type Description
...argsany[]a list of objects to output. The string representations of each of these objects are appended together in the order listed and output

Returns

void


inherits

inherits(childClass, parentClass): void

Inherit the prototype methods from one constructor into another. Based on the Closure Library

Deprecated

since 4.0, use standard extends instead

Parameters

Name Type Description
childClassClassType<any>Child class.
parentClassClassType<any>Parent class.

Returns

void


init

init(options): void

initialize modules

Parameters

Name Type Description
optionsObjectoptions
Optional options.importsClassType<any>[]modules to init

Returns

void


instantiateClass

instantiateClass(className, options?): any

Create instance of the class, which is specified as string with full namespace. This class must have default constructor

Parameters

Name Type Description
classNamestringclass name to instantiate
Optional optionsRecord<string, any>optional parameters

Returns

any

instance of the specified type


interfaceCast

interfaceCast(childInstance, parentInterface): any

Requests "childClass" for "parentInterface" support

Throws

if parentInterface is not defined

Parameters

Name Type Description
childInstanceanychild class instance
parentInterfacestring | ClassType<any>parent interface or its short name

Returns

any

child class instance if "parentInterface" is implemented; null otherwise


isInstanceOf

isInstanceOf<T>(instance, parentClass): instance is T

Check if instance is a parentClass or implements interface

Type parameters

Name
T

Parameters

Name Type Description
instanceunknowninstance to check implementation
parentClassstring | Constructor<T> | ClassType<T>parent interface or class

Returns

instance is T


isObjectEmpty

isObjectEmpty(object): boolean

Check if object is empty (has no properties)

Parameters

Name Type Description
objectanyobject to check

Returns

boolean


isRenderNativeResolution

isRenderNativeResolution(): boolean

Returns true if render native resolution

Returns

boolean


log

log(...args): void

Print in console log message. Passes on all parameters as passed.

Parameters

Name Type Description
...argsany[]a list of objects to output. The string representations of each of these objects are appended together in the order listed and output

Returns

void


mergeObjects

mergeObjects<T, U>(options, result?, lowercase?, copyUndefinedOptions?): Merge<ToLowercase<ToRecord<T>>, ToRecord<U>>

This method is used to merge properties of two objects from options to results

Type parameters

Name
T
U

Parameters

Name Type Description
optionsTan object to merge properties.
Optional resultUObject to merge properties from options. All properties from options are copied to result. If result contains property from options it is replaced. If result has a property and options doesn't have a property the property will be saved in result.
Optional lowercasetruemerge all properties to lower case. if this flag is set then result will have all properties in lower case
Optional copyUndefinedOptionsbooleancopy input options with undefined values

Returns

Merge<ToLowercase<ToRecord<T>>, ToRecord<U>>

mergeObjects<T, U>(options, result?, lowercase?, copyUndefinedOptions?): Merge<ToRecord<T>, ToRecord<U>>

This method is used to merge properties of two objects from options to results

Type parameters

Name
T
U

Parameters

Name Type Description
optionsTan object to merge properties.
Optional resultUObject to merge properties from options. All properties from options are copied to result. If result contains property from options it is replaced. If result has a property and options doesn't have a property the property will be saved in result.
Optional lowercasefalsemerge all properties to lower case. if this flag is set then result will have all properties in lower case
Optional copyUndefinedOptionsbooleancopy input options with undefined values

Returns

Merge<ToRecord<T>, ToRecord<U>>


parseFont

parseFont(font): Object

Utility function to parse inline font string to json object. if the font string is not valid it will return an null object.

Parameters

Name Type
fontstring

Returns

Object

props

props.fontweight font weight (normal, bold, etc.)

props.fontsize font size (ex: 12px)

props.fontfamily font family

props.fontlineheight line height

props.fontstyle font weight (normal, italic, etc.)

NameType
fontfamilystring
fontlineheightstring
fontsizestring
fontstylestring
fontweightstring

processObjectProperties

processObjectProperties(object, recursive?): any

Process object in order to return a copy of the object with flat property names. This method doesn't change original object properties

Parameters

Name Type Description
objectanyobject to be processed
Optional recursivebooleanis recursive call flag

Returns

any


setClassName

setClassName(currentClass, className): void

Sets name of the class, which can be retrieved using method getClassName() or toString()

Parameters

Name Type Description
currentClassClassType<any>class
classNamestringname of the class

Returns

void


setResource

setResource(moduleName, resourceName, resource): void

Sets resources

Deprecated

since 4.0. Use external storage instead.

Parameters

Name Type Description
moduleNamestringmodule name
resourceNamestringresource name
resourceanyresource object

Returns

void


shallowEqual

shallowEqual(firstObject, secondObject): boolean

Make shallow comparison of two objects

Parameters

Name Type Description
firstObjectRecord<string, any>first object to compare
secondObjectRecord<string, any>second object to compare

Returns

boolean


str2Function

str2Function(str): Function

Create a function from a string containing the function

Deprecated

since 4.0

Parameters

Name Type Description
strstringstring to unpack into a function

Returns

Function

func function created from string


toLowerCase

toLowerCase(object): Record<string, any>

Converts object to object with properties in lower case

Parameters

Name Type Description
objectRecord<string, any>object to be processed

Returns

Record<string, any>

object new object (!not modified)


virtualMethod

virtualMethod(): void

Specifies a virtual method.

by default, it generates log message when invoked to indicate the method should be overridden.

Returns

void


warn

warn(...args): void

Print in console warn message. Passes on all parameters as passed.

Parameters

Name Type Description
...argsany[]a list of objects to output. The string representations of each of these objects are appended together in the order listed and output

Returns

void