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

mobx-rest-jquery-adapter

Package Overview
Dependencies
Maintainers
2
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mobx-rest-jquery-adapter - npm Package Compare versions

Comparing version 1.0.5 to 1.0.6

lib/utils.js

27

__tests__/adapter.spec.js

@@ -185,2 +185,29 @@ import adapter from '../src'

})
describe('when it contains an array of files', () => {
const values = [{ id: 1, avatar: 'lol.png' }]
beforeEach(() => {
data = { files: [new File([''], 'filename')] }
injectDone(values)
action()
})
it('sends a xhr request with data parameters', () => {
expect(ret.abort).toBeTruthy()
return ret.promise.then((vals) => {
const res = jq.ajax.mock.calls[0][1]
expect(vals).toEqual(values)
expect(jq.ajax.mock.calls[0][0]).toBe('/api/users')
expect(res.cache).toBe(false)
expect(res.contentType).toBe(false)
expect(res.data).toBeTruthy()
expect(res.method).toBe('POST')
expect(res.processData).toBe(false)
expect(res.xhr).toBeTruthy()
})
})
})
})

@@ -187,0 +214,0 @@

17

lib/index.js

@@ -11,2 +11,4 @@ 'use strict';

var _utils = require('./utils');
var _lodash = require('lodash');

@@ -32,2 +34,3 @@

function ajaxOptions(options) {

@@ -42,14 +45,8 @@ if (options.method === 'GET') {

var formData = new FormData();
var hasFile = false;
var _buildFormData = (0, _utils.buildFormData)(options.data),
hasFile = _buildFormData.hasFile,
formData = _buildFormData.formData;
(0, _lodash.forEach)(options.data, function (val, attr) {
hasFile = hasFile || val instanceof File;
if (!(0, _lodash.isNull)(val)) formData.append(attr, val);
});
var baseOptions = { method: options.method };
var baseOptions = {
method: options.method
};
if (hasFile) {

@@ -56,0 +53,0 @@ return Object.assign({}, baseOptions, {

{
"name": "mobx-rest-jquery-adapter",
"version": "1.0.5",
"version": "1.0.6",
"description": "jQuery adapter for mobx-rest",

@@ -28,3 +28,3 @@ "repository": {

"jquery": "3.4.0",
"lodash": "4.17.11"
"lodash": "4.17.13"
},

@@ -31,0 +31,0 @@ "devDependencies": {

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