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

so

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

so

So, the most straightforward coroutine library for everyday use

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
45
decreased by-79.82%
Maintainers
1
Weekly downloads
 
Created
Source

So

NPM version build status Test coverage

The most straightforward co-routine library for Node.JS ever. Provides predictable composable async/await from C#5.0 style co-routines for everyday use since you can live in a Harmony.

Inspired by @ForbesLindesay's great presentation: http://pag.forbeslindesay.co.uk/#/ and @visionmedia co. As of co-4.0 that was rewritten to use promises, so-1.0 can be compared with co.wrap and represents its more light and strict version.

Platform Compatibility

When using node 0.11.x or greater, you must use the --harmony-generators flag or just --harmony to get access to generators.

When using node 0.10.x and lower or browsers without generator support, you must use gnode and/or regenerator.

Also as of so-1.0 you should ensure existence of Promise either by using --harmony or any available polyfill.

Installation

$ npm install so

Usage


var so = require('so');
var fs = require('then-fs');

var readJSON = so(function*(path){
  return JSON.parse(yield fs.readFile(path, 'utf8'));
});

var main = so(function*(){
  var a = yield readJSON('a.json');
  var b = yield readJSON('b.json');
  console.log({a:a, b:b});
});

main().catch(function(e){
  console.log(e.stack || e.message || e);
});

or for CoffeeScript

so = require 'so'
fs = require 'then-fs'

readJSON = so (path) ->
  JSON.parse yield fs.readFile path, 'utf8'

main = so ->
  a = yield readJSON 'a.json'
  b = yield readJSON 'b.json'
  console.log {a, b}

main().catch (e) ->
  console.log e.stack ? e.message ? e

Keywords

FAQs

Package last updated on 09 Dec 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