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

yaku

Package Overview
Dependencies
Maintainers
1
Versions
137
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

yaku

A lightweight promise library

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
131K
decreased by-20.58%
Maintainers
1
Weekly downloads
 
Created

What is yaku?

Yaku is a lightweight and fast Promise library that is fully compatible with ES6 Promises. It aims to provide better performance and smaller size compared to native Promises and other Promise libraries.

What are yaku's main functionalities?

Basic Promise Usage

This demonstrates the basic usage of Yaku to create a new Promise and handle its resolution.

const Yaku = require('yaku');

const promise = new Yaku((resolve, reject) => {
  setTimeout(() => resolve('Hello, Yaku!'), 1000);
});

promise.then(value => console.log(value));

Chaining Promises

This demonstrates how to chain multiple `then` calls to handle the resolved value step by step.

const Yaku = require('yaku');

const promise = new Yaku((resolve, reject) => {
  setTimeout(() => resolve(1), 1000);
});

promise
  .then(value => value + 1)
  .then(value => value * 2)
  .then(value => console.log(value));

Error Handling

This demonstrates how to handle errors in Yaku Promises using the `catch` method.

const Yaku = require('yaku');

const promise = new Yaku((resolve, reject) => {
  setTimeout(() => reject(new Error('Something went wrong')), 1000);
});

promise
  .then(value => console.log(value))
  .catch(error => console.error(error.message));

Promise.all

This demonstrates how to use `Yaku.all` to wait for multiple Promises to resolve.

const Yaku = require('yaku');

const promise1 = Yaku.resolve(1);
const promise2 = Yaku.resolve(2);
const promise3 = Yaku.resolve(3);

Yaku.all([promise1, promise2, promise3])
  .then(values => console.log(values));

Other packages similar to yaku

Keywords

FAQs

Package last updated on 09 Mar 2020

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