Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

genify

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

genify

Convert passed javascript object to generator

  • 1.0.9
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

genify

Build Status

Bringing power of javascript generators into normal javascript environment

Installation

npm install genify

Example

var Q = require('q');
var fs = require('fs');
var genify = require('genify');

// wrap your object into genify function
var object = genify({
  concatFiles: function * (file1, file2, outFile) {
    file1 = yield Q.nfcall(fs.readFile, file1);
    file2 = yield Q.nfcall(fs.readFile, file2);
    var concated = file1 + file2;

    yield Q.nfcall(fs.writeFile, outFile, concated);

    return concated;
  }
});

// concatFiles is generator function, and it is using generator power to do some things,
// and here you are using that power inside normal javascript environment,
// handling results and errors using promises
object.concatFiles('./somefile1.txt', './somefile2.txt', './concated.txt').then(function (res) {
  // do something with result
}, function (err) {
  // do something with error
});

License

MIT

Keywords

FAQs

Package last updated on 07 May 2014

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