Skip to content

Module: lib/util/object

Utility module for object, type checking, and data manipulation functions. Provides helper methods for working with objects, arrays, types, and cloning.

Version
1.1.0
Author
Frank Kudermann - alphanull
License
MIT
Source
object.js, line 1

Methods

static export isObject(obj) → boolean

Checks if the given value is an object.

Parameters:
Name Type Description
obj *

The value to check.

Returns

True if the value is an object, false otherwise.

Type boolean
Source
object.js, line 34

static export isArray(obj) → boolean

Checks if the given value is an array.

Parameters:
Name Type Description
obj *

The value to check.

Returns

True if the value is an array, false otherwise.

Type boolean
Source
object.js, line 44

static export isNumber(obj) → boolean

Checks if the given value is a number.

Parameters:
Name Type Description
obj *

The value to check.

Returns

True if the value is a number, false otherwise.

Type boolean
Source
object.js, line 54

static export isInteger(obj) → boolean

Checks if the given value is an integer.

Parameters:
Name Type Description
obj *

The value to check.

Returns

True if the value is an integer, false otherwise.

Type boolean
Source
object.js, line 64

static export isString(obj) → boolean

Checks if the given value is a string.

Parameters:
Name Type Description
obj *

The value to check.

Returns

True if the value is a string, false otherwise.

Type boolean
Source
object.js, line 74

static export isFunction(obj) → boolean

Checks if the given value is a function.

Parameters:
Name Type Description
obj *

The value to check.

Returns

True if the value is a function, false otherwise.

Type boolean
Source
object.js, line 84

static export isSymbol(obj) → boolean

Checks if the given value is a symbol.

Parameters:
Name Type Description
obj *

The value to check.

Returns

True if the value is a symbol, false otherwise.

Type boolean
Source
object.js, line 95

static export isElement(obj) → boolean

Checks if the given value is a DOM element.

Parameters:
Name Type Description
obj *

The value to check.

Returns

True if the value is a DOM element, false otherwise.

Type boolean
Source
object.js, line 105

static export isDomFragment(obj) → boolean

Checks if the given value is a DOM fragment.

Parameters:
Name Type Description
obj *

The value to check.

Returns

True if the value is a DOM fragment, false otherwise.

Type boolean
Source
object.js, line 117

static export isNode(obj) → boolean

Checks if the given value is a DOM node.

Parameters:
Name Type Description
obj *

The value to check.

Returns

True if the value is a DOM node, false otherwise.

Type boolean
Source
object.js, line 129

static export isNodeList(obj) → boolean

Checks if the given value is a NodeList.

Parameters:
Name Type Description
obj *

The value to check.

Returns

True if the value is a NodeList, false otherwise.

Type boolean
Source
object.js, line 141

static export isRegex(obj) → boolean

Checks if the given value is a regular expression.

Parameters:
Name Type Description
obj *

The value to check.

Returns

True if the value is a regex, false otherwise.

Type boolean
Source
object.js, line 151

static export isDate(obj) → boolean

Checks if the given value is a Date.

Parameters:
Name Type Description
obj *

The value to check.

Returns

True if the value is a valid Date, false otherwise.

Type boolean
Source
object.js, line 161

static export isBoolean(obj) → boolean

Checks if the given value is a boolean.

Parameters:
Name Type Description
obj *

The value to check.

Returns

True if the value is a boolean, false otherwise.

Type boolean
Source
object.js, line 173

static export isUndefined(obj) → boolean

Checks if the given value is undefied.

Parameters:
Name Type Description
obj *

The value to check.

Returns

True if the value is undefined, false otherwise.

Type boolean
Source
object.js, line 183

static export isEmpty(obj, nonEnumerableopt) → boolean

Checks if the given value is empty.

Parameters:
Name Type Attributes Default Description
obj *

The value to check.

nonEnumerable boolean optional false

If true, checks non-enumerable properties as well.

Returns

True if the value is empty, false otherwise.

Type boolean
Source
object.js, line 194

static export clone(obj, wmopt) → *

Deeply clones an object with optional support for tracking references to prevent cyclic references.

Parameters:
Name Type Attributes Description
obj *

The object to clone.

wm WeakMap optional

A WeakMap to track references and prevent cyclic references.

Returns

A deeply cloned copy of the input object.

Type *
Source
object.js, line 212

static export extend(…sources) → Object

Extends a target object with properties from one or more source objects. Supports deep cloning and cyclic reference tracking using a WeakMap.

Parameters:
Name Type Attributes Description
sources Object repeatable

The source objects from which to copy properties.

Returns

The extended target object.

Type Object
Source
object.js, line 223

private, static _extend(target, source, refMapopt) → *

Internal helper function to recursively extend objects. Handles various data types and prevents cyclic references using a WeakMap.

Parameters:
Name Type Attributes Description
target *

The target object to extend.

source *

The source object providing properties.

refMap WeakMap optional

A WeakMap to track references and handle cyclic structures.

Returns

The extended or cloned target.

Type *
Throws

If the constructor of the source object is invalid.

Type Error
Source
object.js, line 260