![Introducing Enhanced Alert Actions and Triage Functionality](https://cdn.sanity.io/images/cgdhsj6q/production/fe71306d515f85de6139b46745ea7180362324f0-2530x946.png?w=800&fit=max&auto=format)
Product
Introducing Enhanced Alert Actions and Triage Functionality
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
relike
Advanced tools
Changelog
1.0.3 - 2016-01-26
.promisify
methodReadme
Simple promisify a callback-style function with sane defaults. Support promisify-ing sync functions.
What's the difference between me and you?!
–– Dr Dre feat. Eminem & X-Zibit - Whats the Difference, https://youtu.be/8y5MjguI-pM
What's the difference between this module, relike-value and redolent?
–– Simply, almost nothing.
sync
or async
function which is executed immediately with next arguments, after that it returns Promise
.Promise
. But it is little bit tricky:function
as first argument, next arguments will be passed to this functionPromise
. Above things applies here, because it is on top of relike-value
.Notice: Both
relike
andrelike-value
direcly executes first argument (if function) and returnsPromise
.
npm i relike --save
For more use-cases see the tests
const relike = require('relike')
Will try to promisify
fn
with native Promise, otherwise will useBluebird
or you can give different promise module torelike.promise
, for examplepinkie
.
<fn>
{Function} callback-style or synchronous function to promisifyreturn
{Promise} promiseExample
const fs = require('fs')
const request = require('request')
const relike = require('relike')
relike(fs.readFile, 'package.json', 'utf-8').then(data => {
console.log(JSON.parse(data).name)
})
// promisify sync function
relike(fs.readFileSync, 'package.json', 'utf-8')
.then(JSON.parse)
.then(res => {
console.log(res.name)
})
// handles multiple arguments by default (comes from `request`)
relike(request, 'http://www.tunnckocore.tk/').then(result => {
const [httpResponse, body] = result
})
Wraps a function and returns a function that when is invoked returns Promise.
Same asBluebird.promisify
or any other "promisify" thing - accept function and return a function.
<fn>
{Function} callback-style or synchronous function to promisify[Prome]
{Function} custom Promise constructor/module to use, e.g. Q
return
{Function} promisified functionExample
const fs = require('fs')
const relike = require('relike')
const readFile = relike.promisify(fs.readFile)
readFile('package.json', 'utf8')
.then(JSON.parse)
.then(data => {
console.log(data.name) // => 'relike'
})
Static property on which you can pass custom Promise module to use, e.g.
Q
constructor.
Example
const fs = require('fs')
const relike = require('relike')
// `q` promise will be used if not native promise available
// but only in node <= 0.11.12
relike.promise = require('q')
relike(fs.readFile, 'package.json', 'utf-8').then(data => {
console.log(JSON.parse(data).name)
})
You can access the used Promise constructor for promisify-ing from
promise.Prome
Example
const fs = require('fs')
const relike = require('relike')
// use `pinkie` promise if not native promise available
// but only in node <= 0.11.12
relike.promise = require('pinkie')
const promise = relike(fs.readFile, 'package.json', 'utf8')
console.log(promise.Prome)
//=> will be `pinkie` promise constructor (only in node <= 0.11.12)
console.log(promise.Prome.___customPromise) //=> true (only on node <= 0.11.12)
console.log(promise.___customPromise) //=> true (only on node <= 0.11.12)
promise
.then(JSON.parse)
.then(data => {
console.log(data.name) //=> `relike`
})
Promise
if available, otherwise Bluebird
but only if you don't give another promise module like q
or promise
or what you want.Promise
or falsey value if not available.relike
.relike
, used by redolent
to build robust (hybrid) APIs.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.
FAQs
Simple promisify async or sync function with sane defaults. Lower level than `promisify` thing. Can be used to create `promisify` method.
The npm package relike receives a total of 3 weekly downloads. As such, relike popularity was classified as not popular.
We found that relike demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.