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

backbone.dropboxdatastore

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

backbone.dropboxdatastore - npm Package Compare versions

Comparing version 0.4.1 to 0.4.2

4

backbone.dropboxDatastore.js

@@ -107,4 +107,6 @@ (function (root, factory) {

return Backbone.DropboxDatastore.getDatastore(this.datastoreId).then(_.bind(function(datastore) {
var table = datastore.getTable(this.name);
this._startListenToChangeStatus(datastore);
return datastore.getTable(this.name);
this._table = table;
return table;
}, this));

@@ -111,0 +113,0 @@ },

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

/*! backbone.dropboxdatastore - v0.4.1 - 2013-12-18
* Copyright (c) 2013 Dmytro Yarmak <dmytroyarmak@gmail.com>;*/
!function(a,b){"use strict";"object"==typeof exports&&"function"==typeof require?module.exports=b(require("underscore"),require("backbone")):"function"==typeof define&&define.amd?define(["underscore","backbone"],function(c,d){return b(c||a._,d||a.Backbone)}):b(_,Backbone)}(this,function(a,b){"use strict";return b.DropboxDatastore=function(a,b){b=b||{},this.name=a,this.datastoreId=b.datastoreId||"default"},a.extend(b.DropboxDatastore.prototype,b.Events,{create:function(c){var d=a.bind(this._createWithTable,this,c);return this.getTable().then(d).then(b.DropboxDatastore.recordToJson)},update:function(c){var d=a.bind(this._updateWithTable,this,c);return this.getTable().then(d).then(b.DropboxDatastore.recordToJson)},find:function(c){var d=a.bind(this._findWithTable,this,c),e=this._throwIfNotFound;return this.getTable().then(d).then(e).then(b.DropboxDatastore.recordToJson)},findAll:function(){var b=a.bind(this._findAllWithTable,this);return this.getTable().then(b)},destroy:function(b){var c=a.bind(this._destroyWithTable,this,b);return this.getTable().then(c)},getTable:function(){return this._tablePromise||(this._tablePromise=this._createTablePromise()),this._tablePromise},getStatus:function(){return this._table&&this._table._datastore.getSyncStatus().uploading?"uploading":"synced"},close:function(){this._table&&this._stopListenToChangeStatus(this._table._datastore)},_createTablePromise:function(){return b.DropboxDatastore.getDatastore(this.datastoreId).then(a.bind(function(a){return this._startListenToChangeStatus(a),a.getTable(this.name)},this))},_createWithTable:function(a,b){return b.insert(a.toJSON())},_updateWithTable:function(a,b){var c=this._findWithTable(a,b);return c?c.update(a.toJSON()):c=b.insert(a.toJSON()),c},_findWithTable:function(b,c){var d,e={};if(b.isNew())throw new Error("Cannot fetch data for model without id");return"id"===b.idAttribute?d=c.get(b.id):(e[b.idAttribute]=b.id,d=a.first(c.query(e))),d},_findAllWithTable:function(c){var d=a.map(c.query(),b.DropboxDatastore.recordToJson);return d},_destroyWithTable:function(a,b){var c=this._findWithTable(a,b);return c&&c.deleteRecord(),{}},_throwIfNotFound:function(a){if(!a)throw new Error("Record not found");return a},_startListenToChangeStatus:function(b){this._changeStatusListener=a.bind(this._onChangeStatus,this),b.syncStatusChanged.addListener(this._changeStatusListener)},_stopListenToChangeStatus:function(a){this._changeStatusListener&&(a.syncStatusChanged.removeListener(this._changeStatusListener),delete this._changeStatusListener)},_onChangeStatus:function(){this.trigger("change:status",this.getStatus(),this)}}),a.extend(b.DropboxDatastore,{_datastorePromises:{},getDatastore:function(a){var b=this._datastorePromises[a];return b||(b=this._createDatastorePromise(a),this._datastorePromises[a]=b),b},_createDatastorePromise:function(c){var d=b.$.Deferred();return this.getDatastoreManager()._getOrCreateDatastoreByDsid(c,a.bind(function(a,b){a?d.reject(a):d.resolve(b)},this)),d.promise()},getDatastoreManager:function(){return this.getDropboxClient().getDatastoreManager()},getDropboxClient:function(){var a=b.DropboxDatastore.client;if(!a)throw new Error("Client should be defined for Backbone.DropboxDatastore");if(!a.isAuthenticated())throw new Error("Client should be authenticated for Backbone.DropboxDatastore");return a},recordToJson:function(b){return a.extend(b.getFields(),{id:b.getId()})},sync:function(c,d,e){var f=a.partial(b.DropboxDatastore._callSuccessHandler,d,e);return b.DropboxDatastore._doSyncMethod(d,c).then(f)},_doSyncMethod:function(a,c){var d=b.DropboxDatastore._getStoreFromModel(a);switch(c){case"read":return a instanceof b.Collection?d.findAll():d.find(a);case"create":return d.create(a);case"update":return d.update(a);case"delete":return d.destroy(a);default:throw new Error("Incorrect Sync method")}},_getStoreFromModel:function(a){return a.dropboxDatastore||a.collection.dropboxDatastore},_callSuccessHandler:function(a,c,d){return c&&c.success&&("0.9.10"===b.VERSION?c.success(a,d,c):c.success(d)),d}}),b.originalSync=b.sync,b.getSyncMethod=function(a){return a.dropboxDatastore||a.collection&&a.collection.dropboxDatastore?b.DropboxDatastore.sync:b.originalSync},b.sync=function(a,c,d){return b.getSyncMethod(c).call(this,a,c,d)},b.DropboxDatastore});
/*! backbone.dropboxdatastore - v0.4.2 - 2014-01-01
* Copyright (c) 2014 Dmytro Yarmak <dmytroyarmak@gmail.com>;*/
!function(a,b){"use strict";"object"==typeof exports&&"function"==typeof require?module.exports=b(require("underscore"),require("backbone")):"function"==typeof define&&define.amd?define(["underscore","backbone"],function(c,d){return b(c||a._,d||a.Backbone)}):b(_,Backbone)}(this,function(a,b){"use strict";return b.DropboxDatastore=function(a,b){b=b||{},this.name=a,this.datastoreId=b.datastoreId||"default"},a.extend(b.DropboxDatastore.prototype,b.Events,{create:function(c){var d=a.bind(this._createWithTable,this,c);return this.getTable().then(d).then(b.DropboxDatastore.recordToJson)},update:function(c){var d=a.bind(this._updateWithTable,this,c);return this.getTable().then(d).then(b.DropboxDatastore.recordToJson)},find:function(c){var d=a.bind(this._findWithTable,this,c),e=this._throwIfNotFound;return this.getTable().then(d).then(e).then(b.DropboxDatastore.recordToJson)},findAll:function(){var b=a.bind(this._findAllWithTable,this);return this.getTable().then(b)},destroy:function(b){var c=a.bind(this._destroyWithTable,this,b);return this.getTable().then(c)},getTable:function(){return this._tablePromise||(this._tablePromise=this._createTablePromise()),this._tablePromise},getStatus:function(){return this._table&&this._table._datastore.getSyncStatus().uploading?"uploading":"synced"},close:function(){this._table&&this._stopListenToChangeStatus(this._table._datastore)},_createTablePromise:function(){return b.DropboxDatastore.getDatastore(this.datastoreId).then(a.bind(function(a){var b=a.getTable(this.name);return this._startListenToChangeStatus(a),this._table=b,b},this))},_createWithTable:function(a,b){return b.insert(a.toJSON())},_updateWithTable:function(a,b){var c=this._findWithTable(a,b);return c?c.update(a.toJSON()):c=b.insert(a.toJSON()),c},_findWithTable:function(b,c){var d,e={};if(b.isNew())throw new Error("Cannot fetch data for model without id");return"id"===b.idAttribute?d=c.get(b.id):(e[b.idAttribute]=b.id,d=a.first(c.query(e))),d},_findAllWithTable:function(c){var d=a.map(c.query(),b.DropboxDatastore.recordToJson);return d},_destroyWithTable:function(a,b){var c=this._findWithTable(a,b);return c&&c.deleteRecord(),{}},_throwIfNotFound:function(a){if(!a)throw new Error("Record not found");return a},_startListenToChangeStatus:function(b){this._changeStatusListener=a.bind(this._onChangeStatus,this),b.syncStatusChanged.addListener(this._changeStatusListener)},_stopListenToChangeStatus:function(a){this._changeStatusListener&&(a.syncStatusChanged.removeListener(this._changeStatusListener),delete this._changeStatusListener)},_onChangeStatus:function(){this.trigger("change:status",this.getStatus(),this)}}),a.extend(b.DropboxDatastore,{_datastorePromises:{},getDatastore:function(a){var b=this._datastorePromises[a];return b||(b=this._createDatastorePromise(a),this._datastorePromises[a]=b),b},_createDatastorePromise:function(c){var d=b.$.Deferred();return this.getDatastoreManager()._getOrCreateDatastoreByDsid(c,a.bind(function(a,b){a?d.reject(a):d.resolve(b)},this)),d.promise()},getDatastoreManager:function(){return this.getDropboxClient().getDatastoreManager()},getDropboxClient:function(){var a=b.DropboxDatastore.client;if(!a)throw new Error("Client should be defined for Backbone.DropboxDatastore");if(!a.isAuthenticated())throw new Error("Client should be authenticated for Backbone.DropboxDatastore");return a},recordToJson:function(b){return a.extend(b.getFields(),{id:b.getId()})},sync:function(c,d,e){var f=a.partial(b.DropboxDatastore._callSuccessHandler,d,e);return b.DropboxDatastore._doSyncMethod(d,c).then(f)},_doSyncMethod:function(a,c){var d=b.DropboxDatastore._getStoreFromModel(a);switch(c){case"read":return a instanceof b.Collection?d.findAll():d.find(a);case"create":return d.create(a);case"update":return d.update(a);case"delete":return d.destroy(a);default:throw new Error("Incorrect Sync method")}},_getStoreFromModel:function(a){return a.dropboxDatastore||a.collection.dropboxDatastore},_callSuccessHandler:function(a,c,d){return c&&c.success&&("0.9.10"===b.VERSION?c.success(a,d,c):c.success(d)),d}}),b.originalSync=b.sync,b.getSyncMethod=function(a){return a.dropboxDatastore||a.collection&&a.collection.dropboxDatastore?b.DropboxDatastore.sync:b.originalSync},b.sync=function(a,c,d){return b.getSyncMethod(c).call(this,a,c,d)},b.DropboxDatastore});
{
"name": "backbone.dropboxDatastore",
"version": "0.4.1",
"version": "0.4.2",
"main": "./backbone.dropboxDatastore.js",

@@ -5,0 +5,0 @@ "dependencies": {

# Changelog
## 0.4.2 - Jan 1, 2014
- fix problem with incorrect sync status of datastore
- fix problem with not unbounded listeners on close
## 0.4.1 - Dec 18, 2013

@@ -4,0 +8,0 @@ - rewrite library using $.Deferred

{
"name": "backbone.dropboxdatastore",
"description": "Backbone Dropbox Datastore API adapter",
"version": "0.4.1",
"version": "0.4.2",
"keywords": [

@@ -6,0 +6,0 @@ "backbone",

@@ -71,2 +71,6 @@ describe('Backbone.DropboxDatastore#getTable', function() {

it('store table in _table when resolve', function() {
expect(dropboxDatastore._table).toBe('tableMock');
});
it('return promise resolved by table', function() {

@@ -73,0 +77,0 @@ resultPromise.then(function(result) {

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