Skip to content

Commit

Permalink
add "is fun X" variations
Browse files Browse the repository at this point in the history
  • Loading branch information
mitranim committed Feb 3, 2022
1 parent f6939d6 commit b1be51b
Show file tree
Hide file tree
Showing 12 changed files with 253 additions and 169 deletions.
4 changes: 4 additions & 0 deletions changelog.md
@@ -1,3 +1,7 @@
## `0.12.1`

Add `isFunSync`, `isFunGen`, `isFunAsync`, `isFunAsyncGen`.

## `0.12.0`

Massive revision:
Expand Down
2 changes: 1 addition & 1 deletion doc/api/isFun.md
@@ -1 +1 @@
Same as `typeof val === 'function'`. True if value is a function.
Same as `typeof val === 'function'`. True if value is any function, regardless of its type (arrow, async, generator, etc.).
1 change: 1 addition & 0 deletions doc/api/isFunAsync.md
@@ -0,0 +1 @@
True if the input is an async non-generator function. False for sync functions, generator functions, or async generator functions.
1 change: 1 addition & 0 deletions doc/api/isFunAsyncGen.md
@@ -0,0 +1 @@
True if the input is an async generator function. False for sync functions and async non-generator functions.
1 change: 1 addition & 0 deletions doc/api/isFunGen.md
@@ -0,0 +1 @@
True if the input is a sync generator function. False for normal sync functions and async functions.
1 change: 1 addition & 0 deletions doc/api/isFunSync.md
@@ -0,0 +1 @@
True if the input is a normal sync function. False for generator functions or async functions.
2 changes: 0 additions & 2 deletions doc/doc.mjs
Expand Up @@ -19,8 +19,6 @@ const [
function main() {
dat.reqTests()
dat.reqDocs()

const readme = new Templ(srcReadme, dat)
Deno.writeTextFileSync(`readme.md`, readme.toString())
}

Expand Down
5 changes: 5 additions & 0 deletions fpx.mjs
Expand Up @@ -33,6 +33,10 @@ export function isJunk(val) {return isNil(val) || isNaN(val) || isInf(val)}
export function isComp(val) {return isObj(val) || isFun(val)}
export function isPrim(val) {return !isComp(val)}
export function isFun(val) {return typeof val === `function`}
export function isFunSync(val) {return isFunType(val, `Function`)}
export function isFunGen(val) {return isFunType(val, `GeneratorFunction`)}
export function isFunAsync(val) {return isFunType(val, `AsyncFunction`)}
export function isFunAsyncGen(val) {return isFunType(val, `AsyncGeneratorFunction`)}
export function isObj(val) {return val !== null && typeof val === `object`}
export function isStruct(val) {return isObj(val) && !isIter(val) && !isIterAsync(val)}
export function isArr(val) {return Array.isArray(val)}
Expand All @@ -54,6 +58,7 @@ export function isList(val) {return isArr(val) || (isIter(val) && isNat(getLengt
export function isSeq(val) {return isList(val) || isSet(val) || isIterator(val)}

function isDictProto(val) {return val === null || val === Object.prototype}
function isFunType(val, name) {return isFun(val) && val.constructor.name === name}

export function isInst(val, cls) {
req(cls, isCls)
Expand Down
2 changes: 1 addition & 1 deletion makefile
Expand Up @@ -24,7 +24,7 @@ lint_w:
watchexec -r -c -d=0 -e=mjs -n -- $(MAKE) lint

lint:
deno lint --rules-exclude=no-empty,require-yield
deno lint --rules-exclude=no-empty,require-yield,require-await

# TODO consider watching all related files.
doc_w:
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "fpx",
"version": "0.12.0",
"version": "0.12.1",
"description": "Functional Programming eXtensions for JavaScript. Lightweight replacement for Lodash.",
"type": "module",
"main": "./fpx.mjs",
Expand Down

0 comments on commit b1be51b

Please sign in to comment.