本文整理汇总了TypeScript中util.isFunction函数的典型用法代码示例。如果您正苦于以下问题:TypeScript isFunction函数的具体用法?TypeScript isFunction怎么用?TypeScript isFunction使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了isFunction函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: return
return (...value) => {
let pattern = fn.apply(fn, value)
let runFns = []
pattern.forEach((v, i) => {
let lastPattern = pattern[i - 1]
if (isFunction(v) && lastPattern && !isFunction(lastPattern))
runFns.push(v)
})
if (runFns.length == 0) {
let l = pattern.length
if (isFunction(pattern[l - 1]) && isFunction(pattern[l - 2])) {
runFns.push(pattern[l - 1])
}
}
runFns.forEach(f => f.apply(fn, value))
}
示例2: openMenuPopup
export async function openMenuPopup(event: MouseEvent, popup: React.ReactNode | ((rowItem: any) => Promise<React.ReactNode>), rowItem: any = null) {
var elemDiv = document.createElement('div');
$(elemDiv).addClass("buhta-popup-menu");
document.body.appendChild(elemDiv);
let scrollTop = $(window).scrollTop();
let scrollLeft = $(window).scrollLeft();
let left = event.clientX + 5 + scrollLeft!;
let top = event.clientY + 5 + scrollTop!;
if (isFunction(popup)) {
ReactDOM.render(await (popup as any)(rowItem), elemDiv);
}
else {
ReactDOM.render(popup as any, elemDiv);
}
}
示例3: patternMatch
export function patternMatch(arg) {
let a = arg
if (a.length >= 2) {
let p = parsePattern(a)
return (...value) => {
let matchFn = p.map[value.join(',')]
if (!matchFn) matchFn = p.map[value[0]]
if (matchFn) matchFn.apply(matchFn, value)
else if (p.else) p.else.apply(matchFn, value)
}
} else {
a = a[0]
if (isFunction(a)) {
let fn = a as any as Function
return (...value) => {
let pattern = fn.apply(fn, value)
let runFns = []
pattern.forEach((v, i) => {
let lastPattern = pattern[i - 1]
if (isFunction(v) && lastPattern && !isFunction(lastPattern))
runFns.push(v)
})
if (runFns.length == 0) {
let l = pattern.length
if (isFunction(pattern[l - 1]) && isFunction(pattern[l - 2])) {
runFns.push(pattern[l - 1])
}
}
runFns.forEach(f => f.apply(fn, value))
}
}
}
return v => {
console.error("patternMatch unsupported pattern", v, arg)
}
}
示例4:
pattern.forEach((v, i) => {
let lastPattern = pattern[i - 1]
if (isFunction(v) && lastPattern && !isFunction(lastPattern))
runFns.push(v)
})
示例5: isFunction
export function isFunction(value: any) {
return isFunc(value);
}