diff --git a/src/none.ts b/src/none.ts index 83c6b60..3f094f1 100644 --- a/src/none.ts +++ b/src/none.ts @@ -1,8 +1,12 @@ import Maybe, { MatchType, Nil } from "./maybe"; import { maybe } from "./index"; +const isNoArgFunc = (x: any): x is (() => any) => { + return typeof x === "function" && x.length === 0; +}; + const invokeFunc = (funcOrT: T | (() => T)): T => { - if(typeof funcOrT === "function") { + if(isNoArgFunc(funcOrT)) { return funcOrT(); } return funcOrT;