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

lie

Package Overview
Dependencies
Maintainers
1
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lie

A minimal and fast promise implementation

  • 2.7.7
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
9.5M
decreased by-25.65%
Maintainers
1
Weekly downloads
 
Created

What is lie?

The 'lie' npm package is a lightweight, performant promise library implementing the Promises/A+ specification. It provides a simple way to work with asynchronous operations in JavaScript, allowing developers to create, manage, and compose promises for better asynchronous flow control.

What are lie's main functionalities?

Creating a new promise

This feature allows you to create a new promise. The constructor takes a function that contains the asynchronous operation. The function provides two arguments, resolve and reject, which are used to settle the promise.

var Promise = require('lie');
var myPromise = new Promise(function (resolve, reject) {
  // Asynchronous operation here
  if (/* operation successful */) {
    resolve('Success!');
  } else {
    reject('Failure!');
  }
});

Promise resolution

This feature is used to create a promise that is immediately resolved with a given value. It's useful for converting values to promises.

var Promise = require('lie');
Promise.resolve('Immediate resolve').then(function (value) {
  console.log(value); // 'Immediate resolve'
});

Promise rejection

This feature is used to create a promise that is immediately rejected with a given reason. It's useful for representing asynchronous operations that have failed.

var Promise = require('lie');
Promise.reject(new Error('Immediate reject')).catch(function (error) {
  console.error(error); // Error: 'Immediate reject'
});

Chaining promises

This feature allows you to chain multiple promises together and perform actions once all of them are settled. The Promise.all method returns a single promise that resolves when all of the promises in the iterable argument have resolved.

var Promise = require('lie');
var p1 = Promise.resolve(3);
var p2 = 1337;
var p3 = new Promise(function (resolve, reject) {
  setTimeout(resolve, 100, 'foo');
});

Promise.all([p1, p2, p3]).then(function (values) {
  console.log(values); // [3, 1337, 'foo']
});

Other packages similar to lie

Keywords

FAQs

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