Awesome
is-sync-function
Opposite of is-async-function. Check that given function is synchronous.
Install
npm i is-sync-function --save
npm test
Usage
For more use-cases see the tests
var isSyncFunction = require('is-sync-function')
var fs = require('fs')
isSyncFunction(fs.readFileSync) //=> true
isSyncFunction(fs.renameSync) //=> true
isSyncFunction(fs.chownSync) //=> true
isSyncFunction(fs.statSync) //=> true
isSyncFunction(fs.readFile) //=> false
isSyncFunction(fs.rename) //=> false
isSyncFunction(fs.chown) //=> false
isSyncFunction(fs.stat) //=> false
isSyncFunction(JSON.stringify) //=> true
isSyncFunction(JSON.parse) //=> true
Related
- always-callback: Create callback api for given sync function. Guarantee that given function (sync or async, no matter) will always have callback api and will handle errors correctly.
- is-async-function: Check that given function is async (callback) function or not. Trying to guess that based on check if
callback
,cb
,done
ornext
exists as function argument name. - is-empty-function: Checks the given function (or fn.toString()) is with empty body - dont have body.
- is-hexcolor: Check that given value is valid hex color, using
hex-color-regex
- the best regex for matching hex color values - is-ansi: Check that given string contain ANSI color codes, without CLI
- make-callback: Make synchronous function or generator to support callback api
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
But before doing anything, please read the CONTRIBUTING.md guidelines.