本文整理匯總了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);
}