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

vnls-promise

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vnls-promise

Promises

  • 0.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

vnls-promise

Cross platform Promise.

Install:

Nodejs:

On node nodejs

npm install vnls
npm install vnls-event
npm install vnls-promise

Then, somewhere at the top of your code

require('vnls');
require('vnls-event');
require('vnls-promise');

There is no need to bind it to a var because var VNLS is made global to the nodejs process so it's behavior is exactly like in a browser environment. All-though this IS a kind of pollution on nodejs.

Browser

In a browser (you may also download the file first):

 <script type="text/javascript" src="https://raw.githubusercontent.com/jorritd/vnls/master/lib/vnls.min.js"></script>
 <script type="text/javascript" src="https://raw.githubusercontent.com/jorritd/vnls-event/master/lib/vnls-event.min.js"></script>
 <script type="text/javascript" src="https://raw.githubusercontent.com/jorritd/vnls-promise/master/lib/vnls-promise.min.js"></script>

Usage:

var promise = VNLS.getObject('event',"Promise");
promise.Do('set a timeOut and 2 increments',
  // Can we pass something
  // extra to 'this' promise
  function(promise){
    callback_counter ++;
    
    setTimeout(function(){
      // promise.done();
      setTimeout(function(){
        
        promise.done();
        
      },100);
    },100);
    
  },
  
  function(promise){
    callback_counter ++;
    promise.done();
  },
  
  function(promise){
    callback_counter ++;
    promise.done();
  }

).whenDone( function(){
  success_called = true;
}).whenFail( function(){
  error_called = true;
});

or:

promise.Do(
  function(promise){
    callback_counter ++;
    promise.done();
  },
  function(promise){
    callback_counter ++;
    // This block is causing an error
    // So the next block will be valid
    promise.fail();
  },
  function(promise){
    callback_counter ++;
    promise.done();
  } 
).orDo(
  function(promise){
    callback_counter ++;
    promise.done();
  },
  function(promise){
    callback_counter ++;
    promise.done();
  },
  function(promise){
    callback_counter ++;
    promise.done();
  } 
).whenDone( function(){
  success_called = true;
}).whenFail( function(){
  error_called = true;
});

or:

promise.Do(

  function(promise){
    promise.done();
  }
    
).thenDo(
    
  function(promise){
    // console.log('Then called');
    setTimeout(function(){
        // console.log('READY');
        // self.pOptions.current_level == 2 at this position
        // console.log(u.inspect(promise),true);
      promise.done();
    },100);
  }

).orDo(

  function(promise){
    // console.log('Or called');
     // console.log('ERROR');
     // console.log(u.inspect(promise),true);
    promise.fail();
  }
  
).whenDone( function(){
  success_called = true;
}).whenFail( function(){
  error_called = true;
});

Dependencies:

vnls vnls-event

Development:
  • jasmine-node Testing npm install jasmine-node
  • nodewatch Autotesting TDD npm install nodewatch
  • uglify-js Building npm install uglify-js
  • jake rake, make, ant substitute (Java-script all the way) npm install -g jake

For jake these are the commands:

  • jake compress : build minified version in './lib/*'
  • jake test : run the specs
  • jake autotest : run the specs on a filechange for TDD

For testing in a browser environment just point your browser to 'specs/index.html'. It should run the same specs as jake test does. (The tests cover both browser and server)

Keywords

FAQs

Package last updated on 27 Aug 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