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

cls-bluebird

Package Overview
Dependencies
Maintainers
2
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cls-bluebird

Make bluebird work with the continuation-local-storage module.

  • 2.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
209K
decreased by-16.74%
Maintainers
2
Weekly downloads
 
Created

What is cls-bluebird?

The cls-bluebird npm package is a utility that integrates continuation-local storage (CLS) with the Bluebird promise library. This allows you to maintain context across asynchronous operations, which is particularly useful for things like request tracing, logging, and managing user sessions.

What are cls-bluebird's main functionalities?

Integrate CLS with Bluebird

This feature allows you to integrate CLS with Bluebird promises. The code sample demonstrates how to create a namespace, integrate it with Bluebird, and maintain context across asynchronous operations.

const cls = require('cls-hooked');
const ns = cls.createNamespace('myNamespace');
const Promise = require('bluebird');
require('cls-bluebird')(ns, Promise);

ns.run(() => {
  ns.set('key', 'value');
  Promise.resolve().then(() => {
    console.log(ns.get('key')); // Outputs: 'value'
  });
});

Maintain context in nested promises

This feature ensures that the context is maintained even in nested promises. The code sample shows how the context set in the outer promise is accessible in the inner promise.

const cls = require('cls-hooked');
const ns = cls.createNamespace('myNamespace');
const Promise = require('bluebird');
require('cls-bluebird')(ns, Promise);

ns.run(() => {
  ns.set('key', 'value');
  Promise.resolve().then(() => {
    return Promise.resolve().then(() => {
      console.log(ns.get('key')); // Outputs: 'value'
    });
  });
});

Other packages similar to cls-bluebird

Keywords

FAQs

Package last updated on 09 Dec 2017

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