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

mobx-rest

Package Overview
Dependencies
Maintainers
3
Versions
71
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mobx-rest - npm Package Compare versions

Comparing version 3.0.5 to 3.0.6

4

lib/Base.d.ts

@@ -25,3 +25,5 @@ import Request from './Request';

*/
rpc(endpoint: any, options?: {}, label?: string): Request;
rpc(endpoint: string | {
rootUrl: string;
}, options?: {}, label?: string): Request;
}

@@ -8,4 +8,12 @@ 'use strict';

var mobx = require('mobx');
var lodash = require('lodash');
var includes = _interopDefault(require('lodash/includes'));
var isObject = _interopDefault(require('lodash/isObject'));
var debounce = _interopDefault(require('lodash/debounce'));
var isEqual = _interopDefault(require('lodash/isEqual'));
var isPlainObject = _interopDefault(require('lodash/isPlainObject'));
var union = _interopDefault(require('lodash/union'));
var uniqueId = _interopDefault(require('lodash/uniqueId'));
var deepmerge = _interopDefault(require('deepmerge'));
var difference = _interopDefault(require('lodash/difference'));
var isMatch = _interopDefault(require('lodash/isMatch'));

@@ -172,6 +180,6 @@ /*! *****************************************************************************

Base.prototype.getRequest = function (label) {
return this.requests.find(function (request) { return lodash.includes(request.labels, label); });
return this.requests.find(function (request) { return includes(request.labels, label); });
};
Base.prototype.getAllRequests = function (label) {
return this.requests.filter(function (request) { return lodash.includes(request.labels, label); });
return this.requests.filter(function (request) { return includes(request.labels, label); });
};

@@ -190,6 +198,5 @@ /**

*/
// TODO: Type endpoint with string | { rootUrl: string }
Base.prototype.rpc = function (endpoint, options, label) {
if (label === void 0) { label = 'fetching'; }
var url = lodash.isObject(endpoint) ? endpoint.rootUrl : this.url() + "/" + endpoint;
var url = isObject(endpoint) ? endpoint.rootUrl : this.url() + "/" + endpoint;
var _a = apiClient().post(url, options), promise = _a.promise, abort = _a.abort;

@@ -220,3 +227,3 @@ return this.withRequest(label, promise, abort);

_this.committedAttributes = mobx.observable.map();
_this.optimisticId = lodash.uniqueId('i_');
_this.optimisticId = uniqueId('i_');
_this.collection = null;

@@ -353,3 +360,3 @@ _this.defaultAttributes = defaultAttributes;

if (attribute) {
return lodash.includes(this.changedAttributes, attribute);
return includes(this.changedAttributes, attribute);
}

@@ -442,3 +449,3 @@ return this.changedAttributes.length > 0;

}
var onProgress = lodash.debounce(function (progress) {
var onProgress = debounce(function (progress) {
if (optimistic && _this.request)

@@ -530,4 +537,4 @@ _this.request.progress = progress;

var getChangedAttributesBetween = function (source, target) {
var keys = lodash.union(Object.keys(source), Object.keys(target));
return keys.filter(function (key) { return !lodash.isEqual(source[key], target[key]); });
var keys = union(Object.keys(source), Object.keys(target));
return keys.filter(function (key) { return !isEqual(source[key], target[key]); });
};

@@ -537,3 +544,3 @@ var getChangesBetween = function (source, target) {

getChangedAttributesBetween(source, target).forEach(function (key) {
changes[key] = lodash.isPlainObject(source[key]) && lodash.isPlainObject(target[key])
changes[key] = isPlainObject(source[key]) && isPlainObject(target[key])
? getChangesBetween(source[key], target[key])

@@ -650,3 +657,3 @@ : target[key];

? query(model)
: lodash.isMatch(model.toJS(), query);
: isMatch(model.toJS(), query);
});

@@ -662,3 +669,3 @@ };

? query(model)
: lodash.isMatch(model.toJS(), query);
: isMatch(model.toJS(), query);
});

@@ -728,3 +735,3 @@ if (!model && required) {

var ids = resources.map(function (r) { return r.id; });
var toRemove = lodash.difference(this._ids(), ids);
var toRemove = difference(this._ids(), ids);
if (toRemove.length)

@@ -731,0 +738,0 @@ this.remove(toRemove);

{
"name": "mobx-rest",
"version": "3.0.5",
"version": "3.0.6",
"description": "REST conventions for mobx.",

@@ -58,2 +58,3 @@ "jest": {

"dependencies": {
"@types/lodash": "^4.14.134",
"deepmerge": "3.2.0",

@@ -60,0 +61,0 @@ "lodash": "4.17.11",

@@ -383,5 +383,5 @@ # mobx-rest

const promise = usersCollection.fetch()
usersCollection.isEmpty() // => true
usersCollection.isEmpty // => true
await promise
usersCollection.isEmpty() // => false
usersCollection.isEmpty // => false
usersCollection.models.length // => 10

@@ -525,6 +525,6 @@ ```

const promise = tasksCollection.fetch()
tasksCollection.isEmpty() // => true
tasksCollection.isEmpty // => true
tasksCollection.isRequest('fetching') // => true
await promise
tasksCollection.isEmpty() // => false
tasksCollection.isEmpty // => false
```

@@ -531,0 +531,0 @@

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