Util

Util

Source:

Methods

(static) camelize(str)

Source:
transform strings to camel-case
Example
console.log(camelize(" abcd")); // Abcd
console.log(camelize("abc def ghi")); // abcDefGhi
Parameters:
Name Type Description
str String value to transform.

(static) defineGetter(obj)

Source:
define getter function.
Example
const obj = {};
defineGetter({target: obj, name: "test", prefix: "_"});
obj._test = 10;
console.log(obj.test); // 10
Parameters:
Name Type Description
obj Object parameters.
Properties
Name Type Attributes Description
target Object the target to define the property.
name name the name of the property to be defined.
parent name <optional>
the target of the instance to define the property.
prefix name <optional>
the prefix of the name to define the property.

(static) defineGetterSetter(obj)

Source:
define getter and setter function.
Example
const obj = {};
defineGetterSetter({target: obj, name: "test", prefix: "_"});
obj.test = 10;
console.log(obj.test); // 10
Parameters:
Name Type Description
obj Object parameters.
Properties
Name Type Attributes Description
target Object the target to define the property.
name name the name of the property to be defined.
parent name <optional>
the target of the instance to define the property.
prefix name <optional>
the prefix of the name to define the property.

(static) defineProperty(target, name, descriptor)

Source:
define the function or the variable.
Example
const obj = {};
defineProperty(obj, "test", {
	get: function() {
		return "test2";
	},
});
console.log(obj.test); // test2
Parameters:
Name Type Description
target Object the target to define the property.
name name the name of the property to be defined.
descriptor Object the descriptor for the property being defined.

(static) defineSetter(obj)

Source:
define setter function.
Example
const obj = {};
defineSetter({target: obj, name: "test", prefix: "_"});
obj.test = 10;
console.log(obj._test); // 10
Parameters:
Name Type Description
obj Object parameters.
Properties
Name Type Attributes Description
target Object the target to define the property.
name name the name of the property to be defined.
parent name <optional>
the target of the instance to define the property.
prefix name <optional>
the prefix of the name to define the property.

(static) has(object)

Source:
check if this object has a property.
Example
if (has({a:1}, "a")) {
	// has
}
Parameters:
Name Type Description
object Object target

(static) isObject(value)

Source:
check if type of value is object.
Example
if (isObject({})) {
	// object
}
Parameters:
Name Type Description
value Object value to check.

(static) isString(value)

Source:
check if type of value is string.
Example
if (isString("String")) {
	// string
}
Parameters:
Name Type Description
value Object value to check.

(static) isUndefined(value)

Source:
check if type of value is undefined.
Example
if (!isUndefined("11")) {
	// defined
}
Parameters:
Name Type Description
value Object value to check.

(static) splitUnit(value)

Source:
split number and unit of the value.
Example
const v = splitUnit("10px");
console.log(v.value); // 10
console.log(v.unit); // px
Parameters:
Name Type Description
value String value with or without unit.