New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

six-sdk

Package Overview
Dependencies
Maintainers
2
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

six-sdk - npm Package Compare versions

Comparing version 1.0.5 to 1.0.6

3

CHANGELOG.md

@@ -7,2 +7,5 @@ # Changelog

## [1.0.6]
- Performance improvements mainly aimed at Internet Explorer and Microsoft Edge
## [1.0.5]

@@ -9,0 +12,0 @@ - subscribe will always refresh the resource

25

lib/merge.js

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

if (replace) {
for (var _prop in target) {
if (target.hasOwnProperty(_prop)) {
delete target[_prop];
for (var prop in target) {
if (target.hasOwnProperty(prop)) {
delete target[prop];
}

@@ -29,13 +29,14 @@ }

for (var prop in source) {
if (source.hasOwnProperty(prop)) {
if (Array.isArray(source[prop])) {
target[prop] = source[prop];
for (var _prop in source) {
if (source.hasOwnProperty(_prop)) {
var sourceValue = source[_prop];
if (sourceValue && sourceValue.constructor === Array) {
target[_prop] = sourceValue;
// If source[prop] is null there is a bug where the engine will think it's an object
// this will prevent deepMerge from changing the value to null (clearing the value)
// therefore we check if the source[prop] is null here
} else if (source[prop] !== null && target[prop] && _typeof(source[prop]) === 'object') {
deepMerge(target[prop], source[prop]);
} else if (sourceValue !== null && target[_prop] && (typeof sourceValue === 'undefined' ? 'undefined' : _typeof(sourceValue)) === 'object') {
deepMerge(target[_prop], sourceValue);
} else {
target[prop] = source[prop];
target[_prop] = sourceValue;
}

@@ -85,6 +86,6 @@ }

if (Object.keys(subResourcesFound).length > 0) {
_extends(result, subResourcesFound);
_extends(result, subResourcesFound
// if we found a reference somewhere down the tree, make sure this
// resource is also added to the result
if (resource.url) {
);if (resource.url) {
result[resource.url] = resource;

@@ -91,0 +92,0 @@ }

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

exports.default = {
"version": "1.0.5",
"version": "1.0.6",
"git": {
"short": "3feadae",
"long": "3feadae3c9fe2adcb1c38a3587c0082e5c159966",
"short": "2157124",
"long": "215712450a7eeddde5002a4e5c5b794f2e96f118",
"branch": "master"
}
};

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

var isEnumerable = Function.bind.call(Function.call, Object.prototype.propertyIsEnumerable);
var concat = Function.bind.call(Function.call, Array.prototype.concat);
var concat = Function.bind.call(Function.call, Array.prototype.concat
// Reflect.ownkeys is eqv. to Object.getOwnPropertyNames(target).concat(Object.getOwnPropertySymbols(target)).
var keys = Object.keys;
);var keys = Object.keys;
Object.values = function values(O) {

@@ -71,0 +71,0 @@ return reduce(keys(O), function (v, k) {

@@ -23,11 +23,12 @@ 'use strict';

// and only publish X items per frame
var items = Object.values(queue);
for (var i = 0; i < items.length; i++) {
items[i].call();
for (var item in queue) {
if (queue.hasOwnProperty(item) && queue.propertyIsEnumerable(item)) {
queue[item].call();
}
}
queue = {};
}, batchInterval);
}, batchInterval
// create a fn that unsubscribes a listener
var unsubscribe = function unsubscribe(id) {
);var unsubscribe = function unsubscribe(id) {
var subscription = subscriptions[id];

@@ -64,8 +65,11 @@ if (subscription) {

var called = Object.create(null);
sessionExpiredSubscriptions.forEach(function (s) {
if (!called[s.id]) {
s.callback(err, data, s.unsubscribeFn);
called[s.id] = true;
for (var i in sessionExpiredSubscriptions) {
if (sessionExpiredSubscriptions.hasOwnProperty(i)) {
var s = sessionExpiredSubscriptions[i];
if (!called[s.id]) {
s.callback(err, data, s.unsubscribeFn);
called[s.id] = true;
}
}
});
}
}

@@ -76,16 +80,24 @@ }

var _called = Object.create(null);
errorSubscriptions.forEach(function (s) {
if (!_called[s.id]) {
setTimeout(function () {
s.callback(err, data, s.unsubscribeFn);
});
_called[s.id] = true;
for (var _i in errorSubscriptions) {
if (errorSubscriptions.hasOwnProperty(_i)) {
(function () {
var s = errorSubscriptions[_i];
if (!_called[s.id]) {
setTimeout(function () {
s.callback(err, data, s.unsubscribeFn);
});
_called[s.id] = true;
}
})();
}
});
}
}
var subscriptions = resourceToSubscription[resource];
if (subscriptions) {
subscriptions.forEach(function (s) {
return s.callback(err, data, s.unsubscribeFn);
});
for (var _i2 in subscriptions) {
if (subscriptions.hasOwnProperty(_i2)) {
var _s = subscriptions[_i2];
_s.callback(err, data, _s.unsubscribeFn);
}
}
}

@@ -120,47 +132,61 @@ },

var entities = (0, _merge.findAllEntitiesIn)(data);
var resourcesToNotify = Object.create(null // in lieu of Set
// merge entities into cache
Object.values(entities).forEach(function (entity) {
if (entity.url === data.url) {
entityCache[entity.url] = (0, _merge.deepMerge)(entityCache[entity.url], entity, replace);
} else {
entityCache[entity.url] = (0, _merge.deepMerge)(entityCache[entity.url], entity);
}
});
);for (var entityIndex in entities) {
if (entities.hasOwnProperty(entityIndex) && entities.propertyIsEnumerable(entityIndex)) {
var entity = entities[entityIndex];
// merge entities into cache
if (entity.url === data.url) {
entityCache[entity.url] = (0, _merge.deepMerge)(entityCache[entity.url], entity, replace);
} else {
entityCache[entity.url] = (0, _merge.deepMerge)(entityCache[entity.url], entity);
}
// merge cache into entities
Object.values(entities).forEach(function (entity) {
_extends(entity, entityCache[entity.url]);
});
// merge cache into entities
_extends(entity, entityCache[entity.url]
// resolve all entity references, with entity object instances from the cache
Object.values(entities).forEach(function (entity) {
for (var field in entity) {
if (entity.hasOwnProperty(field)) {
if (entity[field] && _typeof(entity[field]) === 'object') {
if (entity[field].url) {
entity[field] = entityCache[entity[field].url] || entity[field];
// resolve all entity references, with entity object instances from the cache
);for (var field in entity) {
if (entity.hasOwnProperty(field)) {
if (entity[field] && _typeof(entity[field]) === 'object') {
if (entity[field].url) {
entity[field] = entityCache[entity[field].url] || entity[field];
}
}
}
}
// entityToResource mapping
entityToResource[entity.url] = entityToResource[entity.url] || {};
entityToResource[entity.url][resource] = true;
// fetch all resources to notify subscribers for
if (entityToResource[entity.url]) {
for (var r in entityToResource[entity.url]) {
resourcesToNotify[r] = true;
}
}
}
});
}
// Domain specific, fixup level 1 in all cached listings with orderbooks
Object.values(entityCache).forEach(function (e) {
// check if this entity have quotes and orderbook
if (e.orderbook && e.orderbook.lastUpdated && e.orderbook.levels && e.orderbook.levels.length > 0) {
if (e.quotes && e.quotes.lastUpdated) {
if (e.orderbook.levels[0].bidPrice !== e.quotes.bidPrice || e.orderbook.levels[0].askPrice !== e.quotes.askPrice) {
// which of the orderbook and quotes have the latest lastUpdated
if (new Date(e.orderbook.lastUpdated).getTime() > new Date(e.quotes.lastUpdated).getTime()) {
// copy orderbook to quotes
e.quotes.bidPrice = e.orderbook.levels[0].bidPrice;
e.quotes.askPrice = e.orderbook.levels[0].askPrice;
e.quotes.lastUpdated = e.orderbook.lastUpdated;
} else {
// copy quotes to orderbook
e.orderbook.levels[0].bidPrice = e.quotes.bidPrice;
e.orderbook.levels[0].askPrice = e.quotes.askPrice;
e.orderbook.lastUpdated = e.quotes.lastUpdated;
for (var entityCacheIndex in entityCache) {
if (entityCache.hasOwnProperty(entityCacheIndex) && entityCache.propertyIsEnumerable(entityCacheIndex)) {
var e = entityCache[entityCacheIndex];
// check if this entity have quotes and orderbook
if (e.orderbook && e.orderbook.lastUpdated && e.orderbook.levels && e.orderbook.levels.length > 0) {
if (e.quotes && e.quotes.lastUpdated) {
if (e.orderbook.levels[0].bidPrice !== e.quotes.bidPrice || e.orderbook.levels[0].askPrice !== e.quotes.askPrice) {
// which of the orderbook and quotes have the latest lastUpdated
if (new Date(e.orderbook.lastUpdated).getTime() > new Date(e.quotes.lastUpdated).getTime()) {
// copy orderbook to quotes
e.quotes.bidPrice = e.orderbook.levels[0].bidPrice;
e.quotes.askPrice = e.orderbook.levels[0].askPrice;
e.quotes.lastUpdated = e.orderbook.lastUpdated;
} else {
// copy quotes to orderbook
e.orderbook.levels[0].bidPrice = e.quotes.bidPrice;
e.orderbook.levels[0].askPrice = e.quotes.askPrice;
e.orderbook.lastUpdated = e.quotes.lastUpdated;
}
}

@@ -170,10 +196,4 @@ }

}
});
}
// entityToResource mapping
Object.values(entities).forEach(function (entity) {
entityToResource[entity.url] = entityToResource[entity.url] || {};
entityToResource[entity.url][resource] = true;
});
// update the resourceCache not all resources are entities,

@@ -188,4 +208,4 @@ // for them we just merge into the resourceCache

// fixup all references from resourceCache to entityCache
Object.keys(resourceCache).forEach(function (key) {
if (resourceCache[key].url) {
for (var key in resourceCache) {
if (resourceCache.hasOwnProperty(key) && resourceCache[key].url) {
var cachedEntity = entityCache[resourceCache[key].url];

@@ -196,12 +216,4 @@ if (cachedEntity) {

}
});
}
// fetch all resources to notify subscribers for
var resourcesToNotify = Object.create(null); // in lieu of Set
Object.values(entities).forEach(function (entity) {
Object.keys(entityToResource[entity.url]).forEach(function (r) {
return resourcesToNotify[r] = true;
});
});
// domain specific

@@ -211,7 +223,7 @@ // if we are publishing quotes, make sure to notify subscribers of orderbook also

var listingUrl = resource.substring(0, resource.length - '/quotes'.length);
Object.keys(resourceCache).forEach(function (resource) {
if (resource.startsWith(listingUrl)) {
resourcesToNotify[resource] = true;
for (var resourceIndex in resourceCache) {
if (resourceCache.hasOwnProperty(resourceIndex) && resourceIndex.startsWith(listingUrl)) {
resourcesToNotify[resourceIndex] = true;
}
});
}
}

@@ -223,7 +235,7 @@

var _listingUrl = resource.substring(0, resource.length - '/orderbook'.length);
Object.keys(resourceCache).forEach(function (resource) {
if (resource.startsWith(_listingUrl)) {
resourcesToNotify[resource] = true;
for (var _resourceIndex in resourceCache) {
if (resourceCache.hasOwnProperty(_resourceIndex) && _resourceIndex.startsWith(_listingUrl)) {
resourcesToNotify[_resourceIndex] = true;
}
});
}
}

@@ -237,19 +249,29 @@

// Not strictly necessary, but improves performance and unit tests
var called = Object.create(null); // in lieu of Set
var called = Object.create(null // in lieu of Set
// notify all subscriptions
Object.keys(resourcesToNotify).forEach(function (r) {
var subscriptions = resourceToSubscription[r];
);
var _loop = function _loop(_r) {
var subscriptions = resourceToSubscription[_r];
if (subscriptions) {
subscriptions.forEach(function (subscription) {
if (!called[subscription.id]) {
queue[subscription.id] = function () {
return subscription.callback(err, resourceCache[r], subscription.unsubscribeFn);
};
called[subscription.id] = true;
for (var subscriptionIndex in subscriptions) {
if (subscriptions.hasOwnProperty(subscriptionIndex)) {
(function () {
var subscription = subscriptions[subscriptionIndex];
if (!called[subscription.id]) {
queue[subscription.id] = function () {
return subscription.callback(err, resourceCache[_r], subscription.unsubscribeFn);
};
called[subscription.id] = true;
}
})();
}
});
}
}
});
};
for (var _r in resourcesToNotify) {
_loop(_r);
}
return;

@@ -282,19 +304,19 @@ },

var sub = { id: nextId(), resource: resource, callback: callback };
var sub = { id: nextId(), resource: resource, callback: callback
// create an Fn to unsubscribe
sub.unsubscribeFn = function () {
return unsubscribe(sub.id);
};
// create an Fn to unsubscribe
};sub.unsubscribeFn = function () {
return unsubscribe(sub.id
// subscription.id -> subscription (for unsubscribe)
subscriptions[sub.id] = sub;
// subscription.id -> subscription (for unsubscribe)
);
};subscriptions[sub.id] = sub;
// resource -> subscription (exact mapping)
resourceToSubscription[resource] = resourceToSubscription[resource] || [];
resourceToSubscription[resource].push(sub);
resourceToSubscription[resource].push(sub
// console.log('resourceToSubscription',resourceToSubscription)
// check cache for this resource
if (resourceCache[resource]) {
);if (resourceCache[resource]) {
// console.log("resource found in cache, notify direct")

@@ -301,0 +323,0 @@ callback(null, resourceCache[resource], sub.unsubscribeFn);

{
"name": "six-sdk",
"version": "1.0.5",
"version": "1.0.6",
"description": "SIX Javascript SDK",

@@ -5,0 +5,0 @@ "main": "lib",

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