Socket
Socket
Sign inDemoInstall

marsdb

Package Overview
Dependencies
8
Maintainers
1
Versions
66
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.6.5 to 0.6.6

.editorconfig

19

dist/Collection.js

@@ -75,15 +75,18 @@ 'use strict';

var _startUpQueue = [];
var _startUpTimeout = 0;
var _startUpId = 0;
// Internals
function _resetStartup() {
clearTimeout(_startUpTimeout);
_startUpId += 1;
_startUpQueue = [];
_startedUp = false;
_startUpTimeout = setTimeout(function () {
_startedUp = true;
(0, _forEach2.default)(_startUpQueue, function (fn) {
return fn();
});
_startUpQueue = [];
var currStartId = _startUpId;
setTimeout(function () {
if (currStartId === _startUpId) {
_startedUp = true;
(0, _forEach2.default)(_startUpQueue, function (fn) {
return fn();
});
_startUpQueue = [];
}
}, 0);

@@ -90,0 +93,0 @@ }

@@ -261,3 +261,2 @@ 'use strict';

if (insertedInResult) {
this.emit('cursorChanged');
return this.update();

@@ -311,2 +310,6 @@ }

if (!firstRun) {
this.emit('cursorChanged');
}
return this.exec().then(function (result) {

@@ -313,0 +316,0 @@ _this3._updateLatestIds();

@@ -26,13 +26,16 @@ import _map from 'fast.js/map';

let _startUpQueue = [];
let _startUpTimeout = 0;
let _startUpId = 0;
// Internals
export function _resetStartup() {
clearTimeout(_startUpTimeout);
_startUpId += 1;
_startUpQueue = [];
_startedUp = false;
_startUpTimeout = setTimeout(() => {
_startedUp = true;
_each(_startUpQueue, fn => fn());
_startUpQueue = [];
const currStartId = _startUpId;
setTimeout(() => {
if (currStartId === _startUpId) {
_startedUp = true;
_each(_startUpQueue, fn => fn());
_startUpQueue = [];
}
}, 0);

@@ -39,0 +42,0 @@ }

@@ -224,3 +224,2 @@ import _bind from 'fast.js/function/bind';

if (insertedInResult) {
this.emit('cursorChanged');
return this.update();

@@ -264,2 +263,6 @@ }

_doUpdate(firstRun = false) {
if (!firstRun) {
this.emit('cursorChanged');
}
return this.exec().then((result) => {

@@ -266,0 +269,0 @@ this._updateLatestIds();

{
"name": "marsdb",
"version": "0.6.5",
"version": "0.6.6",
"author": {

@@ -5,0 +5,0 @@ "name": "Artem Artemev",

@@ -10,17 +10,31 @@ import Collection from '../../lib/Collection';

function resolvePromises(count) {
const resolver = () => {
return Promise.resolve().then(() => {
count -= 1;
if (count > 0) {
return resolver();
}
})
};
return resolver();
}
describe('CursorObservable', () => {
let db;
let db, dbDocs;
beforeEach(function () {
db = new Collection('test');
dbDocs = [
{_id: '1', a: 'a', b: 1, c: 'some text 1', g: 'g1', f: 1, j: '2'},
{_id: '2', a: 'b', b: 2, c: 'some text 2', g: 'g1', f: 10, j: '3'},
{_id: '3', a: 'c', b: 3, c: 'some text 3', g: 'g1', f: 11, j: '4'},
{_id: '4', a: 'd', b: 4, c: 'some text 4', g: 'g1', f: 12, j: '5'},
{_id: '5', a: 'e', b: 5, c: 'some text 5', g: 'g2', d: 234, f: 2, j: '6'},
{_id: '6', a: 'f', b: 6, c: 'some text 6', g: 'g2', f: 20, k: {a: 1}, j: ['7', '5']},
{_id: '7', a: 'g', b: 7, c: 'some text 7', g: 'g2', f: 21, j: [{_id: '1'}, {_id: '2'}]},
];
return Promise.all([
db.insert({a: 'a', b: 1, c: 'some text 1', g: 'g1', f: 1}),
db.insert({a: 'b', b: 2, c: 'some text 2', g: 'g1', f: 10}),
db.insert({a: 'c', b: 3, c: 'some text 3', g: 'g1', f: 11}),
db.insert({a: 'd', b: 4, c: 'some text 4', g: 'g1', f: 12}),
db.insert({a: 'e', b: 5, c: 'some text 5', g: 'g2', d: 234, f: 2}),
db.insert({a: 'f', b: 6, c: 'some text 6', g: 'g2', f: 20}),
db.insert({a: 'g', b: 7, c: 'some text 7', g: 'g2', f: 21}),
]);
return db.insertAll(dbDocs);
});

@@ -373,2 +387,16 @@

});
it('should stop previous execution with observed joins if cursor is updated', function () {
const obspy = sinon.spy();
const cursor = db.find().join({j: db}, {observe: true});
cursor.observe(obspy);
return resolvePromises(4).then(() => {
return cursor.maybeUpdate(null, null);
}).then(() => {
obspy.should.have.callCount(2);
obspy.getCall(0).args[0][0].j.should.be.deep.equal(dbDocs[1]);
obspy.getCall(1).args[0][0].j.should.be.deep.equal(dbDocs[1]);
})
});
});

@@ -375,0 +403,0 @@

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc