Coder Social home page Coder Social logo

petuomin / node-async-context Goto Github PK

View Code? Open in Web Editor NEW

This project forked from gms1/node-async-context

0.0 1.0 0.0 486 KB

a continuation local storage / asynchronous execution context for node.js via async_hooks

License: MIT License

Makefile 0.68% Shell 3.84% TypeScript 95.48%

node-async-context's Introduction

npm version Known Vulnerabilities Build Status Coverage Status Dependency Status Greenkeeper badge

node-async-context (asyncctx)

This module allows you to create an asynchronous execution context for JavaScript or TypeScript

NOTE: This module is based on async_hooks an experimental built-in node.js module introduced in v8.0.0

NOTE: Your contribution is highly welcome!

Introduction

To give you an idea of how asyncctx is supposed to be used:

import { ContinuationLocalStorage } from 'asyncctx';

class MyLocalStorage {
  value: number;
}

let cls = new ContinuationLocalStorage<MyLocalStorage>();
cls.setRootContext({ value: 1});

process.nextTick(() => {
  let curr1 = cls.getContext(); // value is 1
  cls.setContext({ value: 2});  // value should be 2 in the current execution context and below
  process.nextTick(() => {
    let curr2 = cls.getContext(); // value is 2
    cls.setContext({ value: 3});  // value should be 3 in the current execution context and below
    process.nextTick(() => {
      let curr3 = cls.getContext(); // value is 3
    });
  });
  process.nextTick(() => {
    let curr4 = cls.getContext(); // value is 2
  });
});

License

node-async-context (asyncctx) is licensed under the MIT License: LICENSE

Release Notes

Release Notes
2.0.1 maintenance release
2.0.0 targeting es2015; dropped support for nodejs < v8
please use asyncctx@<2.0 for nodejs v4 - v11 support
1.1.0 fixed support for nodes < v8
1.0.5-10 maintenance release
1.0.4 node 10
1.0.3 node 9
1.0.2 maintenance release
1.0.1 added support for older nodejs versions (4,6,7) using internal copy of [email protected]
1.0.0 is now based on 'async_hooks' (a built-in nodejs v8.0 module)
0.0.6 maintenance releases
0.0.5 async-hook 1.7.1
0.0.1-4 initial version

node-async-context's People

Contributors

gms1 avatar greenkeeper[bot] avatar greenkeeperio-bot avatar lautis avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.