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

zipkin-context-cls

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zipkin-context-cls - npm Package Compare versions

Comparing version 0.6.0 to 0.6.1

80

lib/CLSContext.js

@@ -1,37 +0,59 @@

const { createNamespace, getNamespace } = require('continuation-local-storage');
'use strict';
module.exports = class CLSContext {
constructor(namespace = 'zipkin') {
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var _require = require('continuation-local-storage'),
createNamespace = _require.createNamespace,
getNamespace = _require.getNamespace;
module.exports = function () {
function CLSContext() {
var namespace = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'zipkin';
_classCallCheck(this, CLSContext);
this._session = getNamespace(namespace) || createNamespace(namespace);
const defaultContext = this._session.createContext();
var defaultContext = this._session.createContext();
this._session.enter(defaultContext);
}
setContext(ctx) {
this._session.set('zipkin', ctx);
}
_createClass(CLSContext, [{
key: 'setContext',
value: function setContext(ctx) {
this._session.set('zipkin', ctx);
}
}, {
key: 'getContext',
value: function getContext() {
var currentCtx = this._session.get('zipkin');
if (currentCtx != null) {
return currentCtx;
} else {
return null; // explicitly return null (not undefined)
}
}
}, {
key: 'scoped',
value: function scoped(callable) {
var result = void 0;
this._session.run(function () {
result = callable();
});
return result;
}
}, {
key: 'letContext',
value: function letContext(ctx, callable) {
var _this = this;
getContext() {
const currentCtx = this._session.get('zipkin');
if (currentCtx != null) {
return currentCtx;
} else {
return null; // explicitly return null (not undefined)
return this.scoped(function () {
_this.setContext(ctx);
return callable();
});
}
}
}]);
scoped(callable) {
let result;
this._session.run(() => {
result = callable();
});
return result;
}
letContext(ctx, callable) {
return this.scoped(() => {
this.setContext(ctx);
return callable();
});
}
};
return CLSContext;
}();
{
"name": "zipkin-context-cls",
"version": "0.6.0",
"version": "0.6.1",
"description": "A Context API implementation that uses continuation-local-storage under the hood",
"main": "lib/CLSContext.js",
"scripts": {
"build": "../../node_modules/.bin/babel src -d lib",
"test": "node ../../node_modules/mocha/bin/mocha --require ../../test/helper.js",
"build": "babel src -d lib",
"test": "mocha --require ../../test/helper.js",
"prepublish": "npm run build"

@@ -17,3 +17,6 @@ },

},
"devDependencies": {}
"devDependencies": {
"babel-cli": "^6.23.0",
"mocha": "^3.2.0"
}
}
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