本文整理汇总了TypeScript中@daybrush/utils.isObject函数的典型用法代码示例。如果您正苦于以下问题:TypeScript isObject函数的具体用法?TypeScript isObject怎么用?TypeScript isObject使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了isObject函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: set
/**
* set property
* @param {...Number|String|PropertyObject} args - property names or values
* @return {Frame} An instance itself
* @example
// one parameter
frame.set({
display: "none",
transform: {
translate: "10px, 10px",
scale: "1",
},
filter: {
brightness: "50%",
grayscale: "100%"
}
});
// two parameters
frame.set("transform", {
translate: "10px, 10px",
scale: "1",
});
// three parameters
frame.set("transform", "translate", "50px");
*/
public set(...args: any[]) {
const self = this;
const length = args.length;
const params = args.slice(0, -1);
const value = args[length - 1];
if (params[0] in ALIAS) {
self._set(ALIAS[params[0]], value);
} else if (length === 2 && isArray(params[0])) {
self._set(params[0], value);
} else if (isArray(value)) {
self._set(params, value);
} else if (isPropertyObject(value)) {
if (isRole(params)) {
self.set(...params, toObject(value));
} else {
self._set(params, value);
}
} else if (isObject(value)) {
for (const name in value) {
self.set(...params, name, value[name]);
}
} else if (isString(value)) {
if (isRole(params, true)) {
if (isFixed(params) || !isRole(params)) {
this._set(params, value);
} else {
const obj = toPropertyObject(value);
if (isObject(obj)) {
self.set(...params, obj);
}
}
return this;
} else {
const { styles, length: stylesLength } = splitStyle(value);
for (const name in styles) {
self.set(...params, name, styles[name]);
}
if (stylesLength) {
return this;
}
}
self._set(params, value);
} else {
self._set(params, value);
}
return self;
}
开发者ID:daybrush,项目名称:scenejs,代码行数:77,代码来源:Frame.ts
示例2: getValueByNames
export function getValueByNames(
names: Array<string | number>,
properties: IObject<any>, length: number = names.length) {
let value = properties;
for (let i = 0; i < length; ++i) {
if (!isObject(value)) {
return undefined;
}
value = value[names[i]];
}
return value;
}
开发者ID:daybrush,项目名称:scenejs,代码行数:13,代码来源:utils.ts
示例3: remove
/**
* remove property value
* @param {...String} args - property name
* @return {Frame} An instance itself
* @example
frame.remove("display")
*/
public remove(...args: NameType[]) {
const params = getPropertyName(args);
const length = params.length;
if (!length) {
return this;
}
const value = getValueByNames(params, this.properties, length - 1);
if (isObject(value)) {
delete value[params[length - 1]];
}
return this;
}
开发者ID:daybrush,项目名称:scenejs,代码行数:21,代码来源:Frame.ts
示例4: merge
function merge(to: IObject<any>, from: IObject<any>, toValue = false) {
for (const name in from) {
const value = from[name];
const type = getType(value);
if (type === PROPERTY) {
to[name] = toValue ? value.toValue() : value.clone();
} else if (type === FUNCTION) {
to[name] = toValue ? getValue([name], value) : value;
} else if (type === ARRAY) {
to[name] = value.slice();
} else if (type === OBJECT) {
if (isObject(to[name]) && !isPropertyObject(to[name])) {
merge(to[name], value, toValue);
} else {
to[name] = clone(value, toValue);
}
} else {
to[name] = from[name];
}
}
return to;
}
开发者ID:daybrush,项目名称:scenejs,代码行数:23,代码来源:Frame.ts
示例5: _on
public _on(name: string | EventParameter, callback?: CallbackType | CallbackType[], once?: boolean) {
const events = this.events;
if (isObject(name)) {
for (const n in name) {
this._on(n, name[n], once);
}
return;
}
if (!(name in events)) {
events[name] = [];
}
if (!callback) {
return;
}
if (isArray(callback)) {
callback.forEach(func => this._on(name, func, once));
return;
}
events[name].push(once ? function callback2(...args) {
callback(...args);
this.off(name, callback2);
} : callback);
}
开发者ID:daybrush,项目名称:scenejs,代码行数:24,代码来源:EventTrigger.ts
注:本文中的@daybrush/utils.isObject函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论