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

pacta

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pacta

An algebraic implementation of Promises.

  • 0.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.7K
increased by6595%
Maintainers
1
Weekly downloads
 
Created
Source

pacta Build Status

This is an implementation of algebraic Promises in node.js having been convinced by James Coglan and Aanand Prasad.

Pacta's promises can be used as the following algebraic structures:

Note that Pacta does not handle errors or the concept of a failed promise as yet.

See the test suite for more information.

Usage

var Promise = require('pacta').Promise;

var p = new Promise();
setTimeout(function () {
  p.resolve('Foo');
}, 1000);

var p2 = new Promise();
setTimeout(function () {
  p2.resolve('bar');
}, 500);

var p3 = Promise.of('baz');

p.map(console.log); //=> "Foo"

p.map(function (x) {
  return x + '!';
}).map(console.log); //=> "Foo!"

p.concat(p2).concat(p3).map(function (x, y, z) {
  console.log('p says: ' + x);  //=> "p says: Foo"
  console.log('p2 says: ' + y); //=> "p2 says: bar"
  console.log('p3 says: ' + z); //=> "p3 says: baz"
});

Keywords

FAQs

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