Socket
Socket
Sign inDemoInstall

futr

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

futr

Simple Future Variables in javascript.


Version published
Maintainers
1
Created
Source

futr Build Status

Simple Future Variables in javascript.

Installation

node.js

$ npm install futr

Example

var Future = require('futr')
, assert = require('assert')
;

var one = Future.create()
, two = Future.create()
, three = Future.create()
;

// One has no value...

assert.ok(!one.get());
assert.ok(typeof one.get() === 'undefined');

one.set(1);

assert.strictEqual(1, one.get());

assert.throws(function() {
	// Futures are set once...
	one.set(2);
});

// Futures will invoke a callback if one
// is given to the #get method.
var capture;

var before = two.get(function (val) {
	capture = val;
});

assert.ok(typeof before === 'undefined');
assert.ok(typeof capture === 'undefined');

// now set the second future...
var after = two.set(2);

assert.strictEqual(after, 2);

// and check that the callback was invoked.
assert.strictEqual(capture, 2);

// Futures will report whether they have a value...
assert.ok(one.has());
assert.ok(two.has());
assert.ok(!three.has());

FAQs

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