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

unleash-client

Package Overview
Dependencies
Maintainers
3
Versions
123
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

unleash-client - npm Package Compare versions

Comparing version 1.0.0-beta.7 to 1.0.0-beta.8

11

lib/client.js

@@ -7,10 +7,10 @@ 'use strict';

};
var events_1 = require('events');
var events_1 = require("events");
var UnleashClient = (function (_super) {
__extends(UnleashClient, _super);
function UnleashClient(repository, strategies) {
_super.call(this);
this.repository = repository;
this.strategies = strategies || [];
this.warned = {};
var _this = _super.call(this) || this;
_this.repository = repository;
_this.strategies = strategies || [];
_this.warned = {};
strategies.forEach(function (strategy) {

@@ -25,2 +25,3 @@ if (!strategy ||

});
return _this;
}

@@ -27,0 +28,0 @@ UnleashClient.prototype.getStrategy = function (name) {

"use strict";
var unleash_1 = require('./unleash');
var strategy_1 = require('./strategy');
var unleash_1 = require("./unleash");
var strategy_1 = require("./strategy");
exports.Strategy = strategy_1.Strategy;
var unleash_2 = require('./unleash');
var unleash_2 = require("./unleash");
exports.Unleash = unleash_2.Unleash;

@@ -7,0 +7,0 @@ var instance;

@@ -7,5 +7,5 @@ "use strict";

};
var events_1 = require('events');
var url_1 = require('url');
var request_1 = require('./request');
var events_1 = require("events");
var url_1 = require("url");
var request_1 = require("./request");
var Metrics = (function (_super) {

@@ -15,15 +15,16 @@ __extends(Metrics, _super);

var appName = _a.appName, instanceId = _a.instanceId, strategies = _a.strategies, _b = _a.metricsInterval, metricsInterval = _b === void 0 ? 0 : _b, _c = _a.disableMetrics, disableMetrics = _c === void 0 ? false : _c, url = _a.url;
_super.call(this);
this.disabled = disableMetrics;
this.metricsInterval = metricsInterval;
this.appName = appName;
this.instanceId = instanceId;
this.strategies = strategies;
this.url = url;
this.started = new Date();
this.resetBucket();
if (typeof this.metricsInterval === 'number' && this.metricsInterval > 0) {
this.startTimer();
this.registerInstance();
var _this = _super.call(this) || this;
_this.disabled = disableMetrics;
_this.metricsInterval = metricsInterval;
_this.appName = appName;
_this.instanceId = instanceId;
_this.strategies = strategies;
_this.url = url;
_this.started = new Date();
_this.resetBucket();
if (typeof _this.metricsInterval === 'number' && _this.metricsInterval > 0) {
_this.startTimer();
_this.registerInstance();
}
return _this;
}

@@ -30,0 +31,0 @@ Metrics.prototype.startTimer = function () {

@@ -7,7 +7,7 @@ 'use strict';

};
var events_1 = require('events');
var data_formatter_1 = require('./data-formatter');
var storage_1 = require('./storage');
var url_1 = require('url');
var request_1 = require('./request');
var events_1 = require("events");
var data_formatter_1 = require("./data-formatter");
var storage_1 = require("./storage");
var url_1 = require("url");
var request_1 = require("./request");
;

@@ -17,13 +17,13 @@ var Repository = (function (_super) {

function Repository(_a) {
var _this = this;
var backupPath = _a.backupPath, url = _a.url, appName = _a.appName, instanceId = _a.instanceId, refreshInterval = _a.refreshInterval, _b = _a.StorageImpl, StorageImpl = _b === void 0 ? storage_1.Storage : _b;
_super.call(this);
this.url = url;
this.refreshInterval = refreshInterval;
this.instanceId = instanceId;
this.appName = appName;
this.storage = new StorageImpl({ backupPath: backupPath, appName: appName });
this.storage.on('error', function (err) { return _this.emit('error', err); });
this.storage.on('ready', function () { return _this.emit('ready'); });
var _this = _super.call(this) || this;
_this.url = url;
_this.refreshInterval = refreshInterval;
_this.instanceId = instanceId;
_this.appName = appName;
_this.storage = new StorageImpl({ backupPath: backupPath, appName: appName });
_this.storage.on('error', function (err) { return _this.emit('error', err); });
_this.storage.on('ready', function () { return _this.emit('ready'); });
process.nextTick(function () { return _this.fetch(); });
return _this;
}

@@ -30,0 +30,0 @@ Repository.prototype.timedFetch = function () {

"use strict";
var request = require('request');
var request = require("request");
exports.post = function (options, cb) {

@@ -4,0 +4,0 @@ if (!options.timeout) {

@@ -7,5 +7,5 @@ 'use strict';

};
var events_1 = require('events');
var path_1 = require('path');
var fs_1 = require('fs');
var events_1 = require("events");
var path_1 = require("path");
var fs_1 = require("fs");
var Storage = (function (_super) {

@@ -15,9 +15,10 @@ __extends(Storage, _super);

var backupPath = _a.backupPath, appName = _a.appName;
_super.call(this);
var _this = _super.call(this) || this;
// ready is a "ready"-flag to signal that storage is ready with data,
// and to signal to backup not to store fetched backup
this.ready = false;
this.data = {};
this.path = path_1.join(backupPath, "/unleash-repo-schema-v1-" + appName + ".json");
this.load();
_this.ready = false;
_this.data = {};
_this.path = path_1.join(backupPath, "/unleash-repo-schema-v1-" + appName + ".json");
_this.load();
return _this;
}

@@ -24,0 +25,0 @@ Storage.prototype.reset = function (data, doPersist) {

@@ -7,11 +7,11 @@ 'use strict';

};
var client_1 = require('./client');
var repository_1 = require('./repository');
var metrics_1 = require('./metrics');
var strategy_1 = require('./strategy');
var strategy_2 = require('./strategy');
var client_1 = require("./client");
var repository_1 = require("./repository");
var metrics_1 = require("./metrics");
var strategy_1 = require("./strategy");
var strategy_2 = require("./strategy");
exports.Strategy = strategy_2.Strategy;
var os_1 = require('os');
var events_1 = require('events');
var os_2 = require('os');
var os_1 = require("os");
var events_1 = require("events");
var os_2 = require("os");
var BACKUP_PATH = os_1.tmpdir();

@@ -22,5 +22,4 @@ ;

function Unleash(_a) {
var _this = this;
var appName = _a.appName, instanceId = _a.instanceId, url = _a.url, _b = _a.refreshInterval, refreshInterval = _b === void 0 ? 15 * 1000 : _b, _c = _a.metricsInterval, metricsInterval = _c === void 0 ? 60 * 1000 : _c, _d = _a.disableMetrics, disableMetrics = _d === void 0 ? false : _d, _e = _a.backupPath, backupPath = _e === void 0 ? BACKUP_PATH : _e, _f = _a.strategies, strategies = _f === void 0 ? [] : _f;
_super.call(this);
var _this = _super.call(this) || this;
if (!url) {

@@ -34,2 +33,5 @@ throw new Error('Unleash server URL missing');

}
if (!url.endsWith('/')) {
url += '/';
}
if (!appName) {

@@ -43,3 +45,3 @@ throw new Error('Unleash client appName missing');

}
this.repository = new repository_1["default"]({
_this.repository = new repository_1["default"]({
backupPath: backupPath,

@@ -52,3 +54,3 @@ url: url,

strategies = [new strategy_1.Strategy('default', true)].concat(strategies);
this.repository.on('ready', function () {
_this.repository.on('ready', function () {
_this.client = new client_1["default"](_this.repository, strategies);

@@ -59,10 +61,10 @@ _this.client.on('error', function (err) { return _this.emit('error', err); });

});
this.repository.on('error', function (err) {
_this.repository.on('error', function (err) {
err.message = "Unleash Repository error: " + err.message;
_this.emit('error', err);
});
this.repository.on('warn', function (msg) {
_this.repository.on('warn', function (msg) {
_this.emit('warn', msg);
});
this.metrics = new metrics_1["default"]({
_this.metrics = new metrics_1["default"]({
disableMetrics: disableMetrics,

@@ -75,18 +77,19 @@ appName: appName,

});
this.metrics.on('error', function (err) {
_this.metrics.on('error', function (err) {
err.message = "Unleash Metrics error: " + err.message;
_this.emit('error', err);
});
this.metrics.on('warn', function (msg) {
_this.metrics.on('warn', function (msg) {
_this.emit('warn', msg);
});
this.metrics.on('count', function (name, enabled) {
_this.metrics.on('count', function (name, enabled) {
_this.emit('count', name, enabled);
});
this.metrics.on('sent', function (payload) {
_this.metrics.on('sent', function (payload) {
_this.emit('sent', payload);
});
this.metrics.on('registered', function (payload) {
_this.metrics.on('registered', function (payload) {
_this.emit('registered', payload);
});
return _this;
}

@@ -93,0 +96,0 @@ Unleash.prototype.destroy = function () {

{
"name": "unleash-client",
"version": "1.0.0-beta.7",
"version": "1.0.0-beta.8",
"description": "Unleash Client for Node",

@@ -5,0 +5,0 @@ "main": "./lib/index.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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