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

dnode-promise

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

dnode-promise

Helper for using promises on a dnode server

  • 3.0.1
  • latest
  • Source
  • npm
  • Socket score

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

dnode-promise

Use promises on your dnode server.

installation

npm install --save dnode-promise

api

dnodep.toDnode(promiseMethods)

Turns promise methods into functions with the dnode style callback function (arg, cb) {}

var dnode = require('dnode');
var dnodep = require('dnode-promise');
var server = dnode(dnodep.toDnode({
  transform: function (url) {
    // lame example of using promises
    return Promise.resolve(s.replace(/[aeiou]{2,}/, 'oo').toUpperCase());
    // returning the value directory (without Promise.resolve) would have worked as well!
  },
}));
server.listen(5004);

dnodep.toPromise(dnodeMethods, PromiseImplementation)

Turns dnode methods to functions returning promises

var dnode = require('dnode');
var dnodep = require('dnode-promise');
var client = dnode.connect(5004);
client.on('remote', function (methods) {
  var remote = dnodep.toPromise(methods);
  remote.transform('beep')
    .then(function (s) {
      console.log('beep => ' + s);
      client.end();
    });
});

If you want to use another promise implementation as the default Promise to be returned from the remote calls, supply it to the second argument of the toPromise method, example:

var BBPromise = require('bluebird');
// ...
var remote = dnodep.toPromise(methods, BBPromise);
remote.transform('beep')
  .then(function (s) {
    console.log('beep => ' + s);
    d.end();
  });
// ...

license

Copyright 2015 Koen Schmeets (hello@koenschmeets.nl)

This project is free software released under the MIT license: http://www.opensource.org/licenses/mit-license.php

Keywords

FAQs

Package last updated on 07 Oct 2015

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