@fabwcie/free-drawing / utils/functions
utils/functions
Functions
createId()
createId():
string
Defined in: packages/free-drawing/src/utils/functions.ts:46
Unique id of a drawing shape (collaboration), crypto.randomUUID needs a secure context (https)
Returns
string
id of time and random characters (base 36)
deepMerge()
deepMerge<
T>(target,source):T
Defined in: packages/free-drawing/src/utils/functions.ts:26
Merge deeply 2 object with check of validity
Type Parameters
T
T extends object
Parameters
target
T
default values (e.g. defaultOptions), not modified
source
T | Partial<T>
given values: replace those of target, except undefined, null and empty string; arrays replaced, objects merged into objects
Returns
T
Merged object
isObject()
isObject(
item):boolean
Defined in: packages/free-drawing/src/utils/functions.ts:6
Check if an item is an object: arrays and functions are not, dates and class instances are
Parameters
item
any
The item that needs to be checked
Returns
boolean
Whether or not item is an object
isTruthy()
isTruthy(
t):boolean
Defined in: packages/free-drawing/src/utils/functions.ts:15
Check if an item is set: not undefined, null or empty string (false and 0 are)
Parameters
t
any
The item that needs to be checked
Returns
boolean
Whether or not t is set
stringToNode()
stringToNode<
T>(string):T
Defined in: packages/free-drawing/src/utils/functions.ts:56
Element created from HTML code (its first element)
Type Parameters
T
T
type of the element
Parameters
string
string
HTML code of one element
Returns
T
first element of the code, not added to the page (null without element)