New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

resultify

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

resultify

convert node functions to Result returning ones

  • 0.2.4
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

resultify

convert node functions to Result returning ones

Installation

With component, packin or npm

$ {package mananger} install jkroso/resultify

then in your app:

var resultify = require('resultify')

API

resultify(fn:Function)

Teach a node function all about the Result type

var readFile = resultify(fs.readFile)
readFile('/path/to/file.js', 'utf8').then(function(src){
  process.stdout.write(src)
})

fs

just a copy of the fs module from node but with all of the async functions run through the above function

Examples

Results are like dataflow variables. If all the functions in your program understand them you can hardly tell your code isn't blocking.

fs.readFile(prompt('which file? '), 'utf8').read(function(file){
	console.log(file)
})

Performance

once a function has been decorated with resultify it will incur an extra 700-1000ns per invocation which is nothing to worry about. To put that in perspective a function bound with .bind() will become 1500-2000ns slower. Tested on a mac air with node@v0.10.12

Running the tests

Just run make test

Keywords

FAQs

Package last updated on 27 Jun 2013

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc