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

marsdb-angular

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

marsdb-angular - npm Package Compare versions

Comparing version 0.0.5 to 0.0.6

dist/AngularCollectionDelegate.js

200

build/marsdb.angular.js

@@ -6,6 +6,8 @@ (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){

var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.AngularCollection = undefined;
exports.createCollectionDelegate = createCollectionDelegate;

@@ -20,88 +22,78 @@ var _AngularCursorObservable = require('./AngularCursorObservable');

function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var Collection = typeof window !== 'undefined' && window.Mars ? window.Mars.Collection : require('marsdb').Collection;
/**
* Collection that just delegate all methods to an
* original Collection and wrapps all returned promises
* with angular's $q.
*
* It's not extending an original Collection for
* safity porpuse. But if you really wants to access
* storage or indexes, use a '_collcetion' field
* of the object.
*/
function createCollectionDelegate() {
// Build new delegate upon current default
var _defaultDelegate = Collection.defaultDelegate();
var AngularCollection = exports.AngularCollection = (function () {
function AngularCollection(name, options, $q) {
_classCallCheck(this, AngularCollection);
/**
* CollectionDelegate that just wraps methods with $q
* promises and uses special AngularCursorObservable
* for finds.
*/
this.$q = $q;
this._collection = new Collection(name, options);
}
var AngularCollectionDelegate = (function (_defaultDelegate2) {
_inherits(AngularCollectionDelegate, _defaultDelegate2);
_createClass(AngularCollection, [{
key: 'insert',
value: function insert() {
var _collection;
function AngularCollectionDelegate(db, options) {
_classCallCheck(this, AngularCollectionDelegate);
return this.$q.resolve((_collection = this._collection).insert.apply(_collection, arguments));
}
}, {
key: 'insertAll',
value: function insertAll() {
var _collection2;
var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(AngularCollectionDelegate).call(this, db, options));
return this.$q.resolve((_collection2 = this._collection).insertAll.apply(_collection2, arguments));
_this.db = db;
_this.$q = options._$q;
return _this;
}
}, {
key: 'update',
value: function update() {
var _collection3;
return this.$q.resolve((_collection3 = this._collection).update.apply(_collection3, arguments));
}
}, {
key: 'remove',
value: function remove() {
var _collection4;
_createClass(AngularCollectionDelegate, [{
key: 'insert',
value: function insert() {
var _get2;
return this.$q.resolve((_collection4 = this._collection).remove.apply(_collection4, arguments));
}
}, {
key: 'find',
value: function find(query) {
return new _AngularCursorObservable2.default(this, query);
}
}, {
key: 'findOne',
value: function findOne() {
var _collection5;
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return this.$q.resolve((_collection5 = this._collection).findOne.apply(_collection5, arguments));
}
}, {
key: 'count',
value: function count() {
var _collection6;
return this.$q.resolve((_get2 = _get(Object.getPrototypeOf(AngularCollectionDelegate.prototype), 'insert', this)).call.apply(_get2, [this].concat(args)));
}
}, {
key: 'remove',
value: function remove() {
var _get3;
return this.$q.resolve((_collection6 = this._collection).count.apply(_collection6, arguments));
}
}, {
key: 'ids',
value: function ids() {
var _collection7;
for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
args[_key2] = arguments[_key2];
}
return this.$q.resolve((_collection7 = this._collection).ids.apply(_collection7, arguments));
}
}, {
key: 'modelName',
get: function get() {
return this._collection.modelName;
}
}]);
return this.$q.resolve((_get3 = _get(Object.getPrototypeOf(AngularCollectionDelegate.prototype), 'remove', this)).call.apply(_get3, [this].concat(args)));
}
}, {
key: 'update',
value: function update() {
var _get4;
return AngularCollection;
})();
for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
args[_key3] = arguments[_key3];
}
exports.default = AngularCollection;
return this.$q.resolve((_get4 = _get(Object.getPrototypeOf(AngularCollectionDelegate.prototype), 'update', this)).call.apply(_get4, [this].concat(args)));
}
}, {
key: 'find',
value: function find(query) {
var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
return new _AngularCursorObservable2.default(this.$q, this.db, query, options);
}
}]);
return AngularCollectionDelegate;
})(_defaultDelegate);
return AngularCollectionDelegate;
}
},{"./AngularCursorObservable":2,"marsdb":undefined}],2:[function(require,module,exports){

@@ -129,8 +121,14 @@ 'use strict';

function AngularCursorObservable(db, query) {
function AngularCursorObservable($q) {
var _Object$getPrototypeO;
_classCallCheck(this, AngularCursorObservable);
var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(AngularCursorObservable).call(this, db._collection, query));
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
_this.$q = db.$q;
var _this = _possibleConstructorReturn(this, (_Object$getPrototypeO = Object.getPrototypeOf(AngularCursorObservable)).call.apply(_Object$getPrototypeO, [this].concat(args)));
_this.$q = $q;
return _this;

@@ -152,6 +150,4 @@ }

value: function destroy(cursor) {
if (cursor && cursor._prevStopper) {
cursor._prevStopper.stop();
}
return this;
console.warn('DEPRECATED: `destroy` of cursor is deprecated! use `stopObservers` instead');
return this.stopObservers();
}

@@ -179,16 +175,14 @@

}
this._prevStopper = stopper;
return stopper;
}
}, {
key: 'exec',
value: function exec() {
key: '_doUpdate',
value: function _doUpdate() {
var _get2;
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
args[_key2] = arguments[_key2];
}
return this.$q.resolve((_get2 = _get(Object.getPrototypeOf(AngularCursorObservable.prototype), 'exec', this)).call.apply(_get2, [this].concat(args)));
return this.$q.resolve((_get2 = _get(Object.getPrototypeOf(AngularCursorObservable.prototype), '_doUpdate', this)).call.apply(_get2, [this].concat(args)));
}

@@ -200,13 +194,2 @@ }, {

for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
args[_key2] = arguments[_key2];
}
return this.$q.resolve((_get3 = _get(Object.getPrototypeOf(AngularCursorObservable.prototype), 'then', this)).call.apply(_get3, [this].concat(args)));
}
}, {
key: 'update',
value: function update() {
var _get4;
for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {

@@ -216,3 +199,3 @@ args[_key3] = arguments[_key3];

return this.$q.resolve((_get4 = _get(Object.getPrototypeOf(AngularCursorObservable.prototype), 'update', this)).call.apply(_get4, [this].concat(args)));
return this.$q.resolve((_get3 = _get(Object.getPrototypeOf(AngularCursorObservable.prototype), 'then', this)).call.apply(_get3, [this].concat(args)));
}

@@ -228,8 +211,4 @@ }]);

var _AngularCollection = require('./AngularCollection');
var _AngularCollectionDelegate = require('./AngularCollectionDelegate');
var _AngularCollection2 = _interopRequireDefault(_AngularCollection);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var angular = typeof window !== 'undefined' && window.angular ? window.angular : require('angular');

@@ -240,3 +219,10 @@ var Collection = typeof window !== 'undefined' && window.Mars ? window.Mars.Collection : require('marsdb').Collection;

angular.module('MarsDB', []).provider('$collection', function () {
var _angularCollectionDelegate = (0, _AngularCollectionDelegate.createCollectionDelegate)();
Collection.defaultDelegate(_angularCollectionDelegate);
this.defaultDelegate = function (delegate) {
Collection.defaultDelegate(delegate);
return this;
};
this.defaultStorageManager = function (storageManager) {

@@ -257,6 +243,10 @@ Collection.defaultStorageManager(storageManager);

// For using within delegate
options._$q = $q;
// Use cache or create new Colleciton
if (collections[name] && !options.noCache) {
return collections[name];
} else {
var newInstance = new _AngularCollection2.default(name, options, $q);
var newInstance = new Collection(name, options);
if (!options.noCache) {

@@ -272,5 +262,5 @@ collections[name] = newInstance;

module.export = 'MarsDB';
},{"./AngularCollection":1,"angular":undefined,"marsdb":undefined}],4:[function(require,module,exports){
},{"./AngularCollectionDelegate":1,"angular":undefined,"marsdb":undefined}],4:[function(require,module,exports){
module.exports = require('./dist/index');
},{"./dist/index":3}]},{},[4]);

@@ -1,1 +0,1 @@

!function e(t,r,n){function o(u,a){if(!r[u]){if(!t[u]){var l="function"==typeof require&&require;if(!a&&l)return l(u,!0);if(i)return i(u,!0);var s=new Error("Cannot find module '"+u+"'");throw s.code="MODULE_NOT_FOUND",s}var c=r[u]={exports:{}};t[u][0].call(c.exports,function(e){var r=t[u][1][e];return o(r?r:e)},c,c.exports,e,t,r,n)}return r[u].exports}for(var i="function"==typeof require&&require,u=0;u<n.length;u++)o(n[u]);return o}({1:[function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();Object.defineProperty(r,"__esModule",{value:!0}),r.AngularCollection=void 0;var u=e("./AngularCursorObservable"),a=n(u),l="undefined"!=typeof window&&window.Mars?window.Mars.Collection:e("marsdb").Collection,s=r.AngularCollection=function(){function e(t,r,n){o(this,e),this.$q=n,this._collection=new l(t,r)}return i(e,[{key:"insert",value:function(){var e;return this.$q.resolve((e=this._collection).insert.apply(e,arguments))}},{key:"insertAll",value:function(){var e;return this.$q.resolve((e=this._collection).insertAll.apply(e,arguments))}},{key:"update",value:function(){var e;return this.$q.resolve((e=this._collection).update.apply(e,arguments))}},{key:"remove",value:function(){var e;return this.$q.resolve((e=this._collection).remove.apply(e,arguments))}},{key:"find",value:function(e){return new a["default"](this,e)}},{key:"findOne",value:function(){var e;return this.$q.resolve((e=this._collection).findOne.apply(e,arguments))}},{key:"count",value:function(){var e;return this.$q.resolve((e=this._collection).count.apply(e,arguments))}},{key:"ids",value:function(){var e;return this.$q.resolve((e=this._collection).ids.apply(e,arguments))}},{key:"modelName",get:function(){return this._collection.modelName}}]),e}();r["default"]=s},{"./AngularCursorObservable":2,marsdb:void 0}],2:[function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var u=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),a=function c(e,t,r){null===e&&(e=Function.prototype);var n=Object.getOwnPropertyDescriptor(e,t);if(void 0===n){var o=Object.getPrototypeOf(e);return null===o?void 0:c(o,t,r)}if("value"in n)return n.value;var i=n.get;if(void 0!==i)return i.call(r)};Object.defineProperty(r,"__esModule",{value:!0});var l="undefined"!=typeof window&&window.Mars?window.Mars.CursorObservable:e("marsdb").CursorObservable,s=r.AngularCursorObservable=function(e){function t(e,r){n(this,t);var i=o(this,Object.getPrototypeOf(t).call(this,e._collection,r));return i.$q=e.$q,i}return i(t,e),u(t,[{key:"destroy",value:function(e){return e&&e._prevStopper&&e._prevStopper.stop(),this}},{key:"observe",value:function(e,r){var n=a(Object.getPrototypeOf(t.prototype),"observe",this).call(this,e);return r&&r.$on("$destroy",function(){n.stop()}),this._prevStopper=n,n}},{key:"exec",value:function(){for(var e,r=arguments.length,n=Array(r),o=0;r>o;o++)n[o]=arguments[o];return this.$q.resolve((e=a(Object.getPrototypeOf(t.prototype),"exec",this)).call.apply(e,[this].concat(n)))}},{key:"then",value:function(){for(var e,r=arguments.length,n=Array(r),o=0;r>o;o++)n[o]=arguments[o];return this.$q.resolve((e=a(Object.getPrototypeOf(t.prototype),"then",this)).call.apply(e,[this].concat(n)))}},{key:"update",value:function(){for(var e,r=arguments.length,n=Array(r),o=0;r>o;o++)n[o]=arguments[o];return this.$q.resolve((e=a(Object.getPrototypeOf(t.prototype),"update",this)).call.apply(e,[this].concat(n)))}}]),t}(l);r["default"]=s},{marsdb:void 0}],3:[function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}var o=e("./AngularCollection"),i=n(o),u="undefined"!=typeof window&&window.angular?window.angular:e("angular"),a="undefined"!=typeof window&&window.Mars?window.Mars.Collection:e("marsdb").Collection;u.module("MarsDB",[]).provider("$collection",function(){this.defaultStorageManager=function(e){return a.defaultStorageManager(e),this},this.defaultIdGenerator=function(e){return a.defaultIdGenerator(e),this};var e={};this.$get=["$q",function(t){return function(r){var n=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];if(e[r]&&!n.noCache)return e[r];var o=new i["default"](r,n,t);return n.noCache||(e[r]=o),o}}]}),t["export"]="MarsDB"},{"./AngularCollection":1,angular:void 0,marsdb:void 0}],4:[function(e,t,r){t.exports=e("./dist/index")},{"./dist/index":3}]},{},[4]);
!function e(t,r,n){function o(u,i){if(!r[u]){if(!t[u]){var l="function"==typeof require&&require;if(!i&&l)return l(u,!0);if(a)return a(u,!0);var s=new Error("Cannot find module '"+u+"'");throw s.code="MODULE_NOT_FOUND",s}var c=r[u]={exports:{}};t[u][0].call(c.exports,function(e){var r=t[u][1][e];return o(r?r:e)},c,c.exports,e,t,r,n)}return r[u].exports}for(var a="function"==typeof require&&require,u=0;u<n.length;u++)o(n[u]);return o}({1:[function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function i(){var e=p.defaultDelegate(),t=function(e){function t(e,r){o(this,t);var n=a(this,Object.getPrototypeOf(t).call(this,e,r));return n.db=e,n.$q=r._$q,n}return u(t,e),l(t,[{key:"insert",value:function(){for(var e,r=arguments.length,n=Array(r),o=0;r>o;o++)n[o]=arguments[o];return this.$q.resolve((e=s(Object.getPrototypeOf(t.prototype),"insert",this)).call.apply(e,[this].concat(n)))}},{key:"remove",value:function(){for(var e,r=arguments.length,n=Array(r),o=0;r>o;o++)n[o]=arguments[o];return this.$q.resolve((e=s(Object.getPrototypeOf(t.prototype),"remove",this)).call.apply(e,[this].concat(n)))}},{key:"update",value:function(){for(var e,r=arguments.length,n=Array(r),o=0;r>o;o++)n[o]=arguments[o];return this.$q.resolve((e=s(Object.getPrototypeOf(t.prototype),"update",this)).call.apply(e,[this].concat(n)))}},{key:"find",value:function(e){var t=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];return new f["default"](this.$q,this.db,e,t)}}]),t}(e);return t}var l=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),s=function d(e,t,r){null===e&&(e=Function.prototype);var n=Object.getOwnPropertyDescriptor(e,t);if(void 0===n){var o=Object.getPrototypeOf(e);return null===o?void 0:d(o,t,r)}if("value"in n)return n.value;var a=n.get;if(void 0!==a)return a.call(r)};Object.defineProperty(r,"__esModule",{value:!0}),r.createCollectionDelegate=i;var c=e("./AngularCursorObservable"),f=n(c),p="undefined"!=typeof window&&window.Mars?window.Mars.Collection:e("marsdb").Collection},{"./AngularCursorObservable":2,marsdb:void 0}],2:[function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var u=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),i=function c(e,t,r){null===e&&(e=Function.prototype);var n=Object.getOwnPropertyDescriptor(e,t);if(void 0===n){var o=Object.getPrototypeOf(e);return null===o?void 0:c(o,t,r)}if("value"in n)return n.value;var a=n.get;if(void 0!==a)return a.call(r)};Object.defineProperty(r,"__esModule",{value:!0});var l="undefined"!=typeof window&&window.Mars?window.Mars.CursorObservable:e("marsdb").CursorObservable,s=r.AngularCursorObservable=function(e){function t(e){var r;n(this,t);for(var a=arguments.length,u=Array(a>1?a-1:0),i=1;a>i;i++)u[i-1]=arguments[i];var l=o(this,(r=Object.getPrototypeOf(t)).call.apply(r,[this].concat(u)));return l.$q=e,l}return a(t,e),u(t,[{key:"destroy",value:function(e){return console.warn("DEPRECATED: `destroy` of cursor is deprecated! use `stopObservers` instead"),this.stopObservers()}},{key:"observe",value:function(e,r){var n=i(Object.getPrototypeOf(t.prototype),"observe",this).call(this,e);return r&&r.$on("$destroy",function(){n.stop()}),n}},{key:"_doUpdate",value:function(){for(var e,r=arguments.length,n=Array(r),o=0;r>o;o++)n[o]=arguments[o];return this.$q.resolve((e=i(Object.getPrototypeOf(t.prototype),"_doUpdate",this)).call.apply(e,[this].concat(n)))}},{key:"then",value:function(){for(var e,r=arguments.length,n=Array(r),o=0;r>o;o++)n[o]=arguments[o];return this.$q.resolve((e=i(Object.getPrototypeOf(t.prototype),"then",this)).call.apply(e,[this].concat(n)))}}]),t}(l);r["default"]=s},{marsdb:void 0}],3:[function(e,t,r){"use strict";var n=e("./AngularCollectionDelegate"),o="undefined"!=typeof window&&window.angular?window.angular:e("angular"),a="undefined"!=typeof window&&window.Mars?window.Mars.Collection:e("marsdb").Collection;o.module("MarsDB",[]).provider("$collection",function(){var e=(0,n.createCollectionDelegate)();a.defaultDelegate(e),this.defaultDelegate=function(e){return a.defaultDelegate(e),this},this.defaultStorageManager=function(e){return a.defaultStorageManager(e),this},this.defaultIdGenerator=function(e){return a.defaultIdGenerator(e),this};var t={};this.$get=["$q",function(e){return function(r){var n=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];if(n._$q=e,t[r]&&!n.noCache)return t[r];var o=new a(r,n);return n.noCache||(t[r]=o),o}}]}),t["export"]="MarsDB"},{"./AngularCollectionDelegate":1,angular:void 0,marsdb:void 0}],4:[function(e,t,r){t.exports=e("./dist/index")},{"./dist/index":3}]},{},[4]);

@@ -22,8 +22,14 @@ 'use strict';

function AngularCursorObservable(db, query) {
function AngularCursorObservable($q) {
var _Object$getPrototypeO;
_classCallCheck(this, AngularCursorObservable);
var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(AngularCursorObservable).call(this, db._collection, query));
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
_this.$q = db.$q;
var _this = _possibleConstructorReturn(this, (_Object$getPrototypeO = Object.getPrototypeOf(AngularCursorObservable)).call.apply(_Object$getPrototypeO, [this].concat(args)));
_this.$q = $q;
return _this;

@@ -45,6 +51,4 @@ }

value: function destroy(cursor) {
if (cursor && cursor._prevStopper) {
cursor._prevStopper.stop();
}
return this;
console.warn('DEPRECATED: `destroy` of cursor is deprecated! use `stopObservers` instead');
return this.stopObservers();
}

@@ -72,16 +76,14 @@

}
this._prevStopper = stopper;
return stopper;
}
}, {
key: 'exec',
value: function exec() {
key: '_doUpdate',
value: function _doUpdate() {
var _get2;
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
args[_key2] = arguments[_key2];
}
return this.$q.resolve((_get2 = _get(Object.getPrototypeOf(AngularCursorObservable.prototype), 'exec', this)).call.apply(_get2, [this].concat(args)));
return this.$q.resolve((_get2 = _get(Object.getPrototypeOf(AngularCursorObservable.prototype), '_doUpdate', this)).call.apply(_get2, [this].concat(args)));
}

@@ -93,13 +95,2 @@ }, {

for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
args[_key2] = arguments[_key2];
}
return this.$q.resolve((_get3 = _get(Object.getPrototypeOf(AngularCursorObservable.prototype), 'then', this)).call.apply(_get3, [this].concat(args)));
}
}, {
key: 'update',
value: function update() {
var _get4;
for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {

@@ -109,3 +100,3 @@ args[_key3] = arguments[_key3];

return this.$q.resolve((_get4 = _get(Object.getPrototypeOf(AngularCursorObservable.prototype), 'update', this)).call.apply(_get4, [this].concat(args)));
return this.$q.resolve((_get3 = _get(Object.getPrototypeOf(AngularCursorObservable.prototype), 'then', this)).call.apply(_get3, [this].concat(args)));
}

@@ -112,0 +103,0 @@ }]);

'use strict';
var _AngularCollection = require('./AngularCollection');
var _AngularCollectionDelegate = require('./AngularCollectionDelegate');
var _AngularCollection2 = _interopRequireDefault(_AngularCollection);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var angular = typeof window !== 'undefined' && window.angular ? window.angular : require('angular');

@@ -14,3 +10,10 @@ var Collection = typeof window !== 'undefined' && window.Mars ? window.Mars.Collection : require('marsdb').Collection;

angular.module('MarsDB', []).provider('$collection', function () {
var _angularCollectionDelegate = (0, _AngularCollectionDelegate.createCollectionDelegate)();
Collection.defaultDelegate(_angularCollectionDelegate);
this.defaultDelegate = function (delegate) {
Collection.defaultDelegate(delegate);
return this;
};
this.defaultStorageManager = function (storageManager) {

@@ -31,6 +34,10 @@ Collection.defaultStorageManager(storageManager);

// For using within delegate
options._$q = $q;
// Use cache or create new Colleciton
if (collections[name] && !options.noCache) {
return collections[name];
} else {
var newInstance = new _AngularCollection2.default(name, options, $q);
var newInstance = new Collection(name, options);
if (!options.noCache) {

@@ -37,0 +44,0 @@ collections[name] = newInstance;

@@ -6,5 +6,5 @@ const CursorObservable = typeof window !== 'undefined' && window.Mars

export class AngularCursorObservable extends CursorObservable {
constructor(db, query) {
super(db._collection, query);
this.$q = db.$q;
constructor($q, ...args) {
super(...args);
this.$q = $q;
}

@@ -22,6 +22,4 @@

destroy(cursor) {
if (cursor && cursor._prevStopper) {
cursor._prevStopper.stop();
}
return this;
console.warn('DEPRECATED: `destroy` of cursor is deprecated! use `stopObservers` instead');
return this.stopObservers();
}

@@ -46,9 +44,7 @@

}
this._prevStopper = stopper;
return stopper;
}
exec(...args) {
return this.$q.resolve(super.exec(...args));
_doUpdate(...args) {
return this.$q.resolve(super._doUpdate(...args));
}

@@ -59,8 +55,4 @@

}
update(...args) {
return this.$q.resolve(super.update(...args));
}
}
export default AngularCursorObservable;

@@ -1,2 +0,2 @@

import AngularCollection from './AngularCollection';
import { createCollectionDelegate } from './AngularCollectionDelegate';
const angular = typeof window !== 'undefined' && window.angular

@@ -11,3 +11,10 @@ ? window.angular : require('angular');

.provider('$collection', function() {
const _angularCollectionDelegate = createCollectionDelegate();
Collection.defaultDelegate(_angularCollectionDelegate);
this.defaultDelegate = function(delegate) {
Collection.defaultDelegate(delegate);
return this;
};
this.defaultStorageManager = function(storageManager) {

@@ -26,6 +33,10 @@ Collection.defaultStorageManager(storageManager);

return function(name, options = {}) {
// For using within delegate
options._$q = $q;
// Use cache or create new Colleciton
if (collections[name] && !options.noCache) {
return collections[name];
} else {
const newInstance = new AngularCollection(name, options, $q);
const newInstance = new Collection(name, options);
if (!options.noCache) {

@@ -32,0 +43,0 @@ collections[name] = newInstance;

{
"name": "marsdb-angular",
"version": "0.0.5",
"version": "0.0.6",
"author": "Artem Artemev <art@studytime.me>",

@@ -27,9 +27,8 @@ "contributors": [

"dependencies": {
"marsdb": "^0.5.10",
"invariant": "^2.2.0"
"invariant": "^2.2.0",
"marsdb": "^0.5.14"
},
"devDependencies": {
"core-js": "^2.0.1",
"angular": "^1.4.8",
"angular-mocks": "^1.4.8",
"angular": "^1.4.9",
"angular-mocks": "^1.4.9",
"babel-cli": "^6.3.17",

@@ -46,2 +45,3 @@ "babel-eslint": "^5.0.0-beta6",

"chai-as-promised": "^5.2.0",
"core-js": "^2.0.1",
"coveralls": "^2.11.6",

@@ -48,0 +48,0 @@ "del": "^2.2.0",

@@ -31,3 +31,2 @@ import { Collection, Cursor, CursorObservable } from 'marsdb';

describe('observing', function() {
/*
it('should change scope when new data available', (done) => window.inject(

@@ -50,3 +49,2 @@ function($collection, $q, $rootScope, $timeout) {

}, $scope).then(() => {
console.log('asdas');
coll.insert({_id: 1, a: 2});

@@ -57,4 +55,4 @@ setTimeout(() => $rootScope.$apply(), 100);

})
);*/
);
});
});
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