本文整理汇总了TypeScript中@daybrush/utils.isArray函数的典型用法代码示例。如果您正苦于以下问题:TypeScript isArray函数的具体用法?TypeScript isArray怎么用?TypeScript isArray使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了isArray函数的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;
}
示例2: toPropertyObject
export function toPropertyObject(value: string | IObject<any> | any[]) {
if (!isString(value)) {
if (isArray(value)) {
return arrayToPropertyObject(value, ",");
}
return value;
}
let values = splitComma(value);
if (values.length > 1) {
return arrayToPropertyObject(values.map(v => toPropertyObject(v)), ",");
}
values = splitSpace(value);
if (values.length > 1) {
return arrayToPropertyObject(values.map(v => toPropertyObject(v)), " ");
}
values = /^(['"])([^'"]*)(['"])$/g.exec(value);
if (values && values[1] === values[3]) {
// Quotes
return new PropertyObject([toPropertyObject(values[2])], {
prefix: values[1],
suffix: values[1],
});
} else if (value.indexOf("(") !== -1) {
// color
return stringToBracketObject(value);
} else if (value.charAt(0) === "#") {
return stringToColorObject(value);
}
return value;
}
示例3: setEasing
/**
* set animator's easing.
* @param curverArray - The speed curve of an animation.
* @return {Animator} An instance itself.
* @example
animator.({
delay: 2,
diretion: "alternate",
duration: 2,
fillMode: "forwards",
iterationCount: 3,
easing: Scene.easing.EASE,
});
*/
public setEasing(curveArray: string | number[] | EasingFunction): this {
let easing: EasingFunction;
if (isString(curveArray)) {
if (curveArray in EASINGS) {
easing = EASINGS[curveArray];
} else {
const obj = toPropertyObject(curveArray);
if (isString(obj)) {
return this;
} else {
if (obj.model === "cubic-bezier") {
curveArray = obj.value.map(v => parseFloat(v));
easing = bezier(curveArray[0], curveArray[1], curveArray[2], curveArray[3]);
} else if (obj.model === "steps") {
easing = steps(parseFloat(obj.value[0]), obj.value[1]);
} else {
return this;
}
}
}
} else if (isArray(curveArray)) {
easing = bezier(curveArray[0], curveArray[1], curveArray[2], curveArray[3]);
} else {
easing = curveArray;
}
const easingName = easing[EASING_NAME] || "linear";
const state = this.state;
state[EASING] = easing;
state[EASING_NAME] = easingName;
return this;
}
示例4: getType
export function getType(value: any) {
const type = typeof value;
if (type === OBJECT) {
if (isArray(value)) {
return ARRAY;
} else if (isPropertyObject(value)) {
return PROPERTY;
}
} else if (type === STRING || type === NUMBER) {
return "value";
}
return type;
}
示例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);
}