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

@fdaciuk/ajax

Package Overview
Dependencies
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fdaciuk/ajax - npm Package Compare versions

Comparing version 2.0.1 to 2.1.0

6

dist/ajax.min.js
/**!
* ajax - v2.0.1
* ajax - v2.1.0
* Ajax module in Vanilla JS
* https://github.com/fdaciuk/ajax
* Fri May 06 2016 10:30:34 GMT-0300 (BRT)
* Sat May 14 2016 23:30:26 GMT-0300 (BRT)
* MIT (c) Fernando Daciuk
*/
!function(e,t){"use strict";"function"==typeof define&&define.amd?define("ajax",t):"object"==typeof exports?exports=module.exports=t():e.ajax=t()}(this,function(){"use strict";function e(e){var r=["get","post","put","delete"];return e=e||{},e.baseUrl=e.baseUrl||"",e.method&&e.url?n(e.method,e.baseUrl+e.url,t(e.data),e):r.reduce(function(r,u){return r[u]=function(r,o){return n(u,e.baseUrl+r,t(o),e)},r},{})}function t(e){return e||null}function n(e,t,n,u){var c=["then","catch","always"],s=c.reduce(function(e,t){return e[t]=function(n){return e[t]=n,e},e},{}),i=new XMLHttpRequest;return i.open(e,t,!0),r(i,u.headers),i.addEventListener("readystatechange",o(s,i),!1),i.send(a(n)),s}function r(e,t){t=t||{},u(t)||(t["Content-Type"]="application/x-www-form-urlencoded"),Object.keys(t).forEach(function(n){t[n]&&e.setRequestHeader(n,t[n])})}function u(e){return Object.keys(e).some(function(e){return"content-type"===e.toLowerCase()})}function o(e,t){return function n(){t.readyState===t.DONE&&(t.removeEventListener("readystatechange",n,!1),e.always.apply(e,c(t)),t.status>=200&&t.status<300?e.then.apply(e,c(t)):e["catch"].apply(e,c(t)))}}function c(e){var t;try{t=JSON.parse(e.responseText)}catch(n){t=e.responseText}return[t,e]}function a(e){return s(e)?i(e):e}function s(e){return"[object Object]"===Object.prototype.toString.call(e)}function i(e){return Object.keys(e).reduce(function(t,n){var r=t?t+"&":"";return r+f(n)+"="+f(e[n])},"")}function f(e){return encodeURIComponent(e)}return e});
!function(e,t){"use strict";"function"==typeof define&&define.amd?define("ajax",t):"object"==typeof exports?exports=module.exports=t():e.ajax=t()}(this,function(){"use strict";function e(e){var r=["get","post","put","delete"];return e=e||{},e.baseUrl=e.baseUrl||"",e.method&&e.url?n(e.method,e.baseUrl+e.url,t(e.data),e):r.reduce(function(r,u){return r[u]=function(r,o){return n(u,e.baseUrl+r,t(o),e)},r},{})}function t(e){return e||null}function n(e,t,n,u){var c=["then","catch","always"],s=c.reduce(function(e,t){return e[t]=function(n){return e[t]=n,e},e},{}),i=new XMLHttpRequest;return i.open(e,t,!0),r(i,u.headers),i.addEventListener("readystatechange",o(s,i),!1),i.send(a(n)),s.abort=function(){return i.abort()},s}function r(e,t){t=t||{},u(t)||(t["Content-Type"]="application/x-www-form-urlencoded"),Object.keys(t).forEach(function(n){t[n]&&e.setRequestHeader(n,t[n])})}function u(e){return Object.keys(e).some(function(e){return"content-type"===e.toLowerCase()})}function o(e,t){return function n(){t.readyState===t.DONE&&(t.removeEventListener("readystatechange",n,!1),e.always.apply(e,c(t)),t.status>=200&&t.status<300?e.then.apply(e,c(t)):e["catch"].apply(e,c(t)))}}function c(e){var t;try{t=JSON.parse(e.responseText)}catch(n){t=e.responseText}return[t,e]}function a(e){return s(e)?i(e):e}function s(e){return"[object Object]"===Object.prototype.toString.call(e)}function i(e){return Object.keys(e).reduce(function(t,n){var r=t?t+"&":"";return r+f(n)+"="+f(e[n])},"")}function f(e){return encodeURIComponent(e)}return e});
{
"name": "@fdaciuk/ajax",
"description": "Ajax module in Vanilla JS",
"version": "2.0.1",
"version": "2.1.0",
"main": "dist/ajax.min.js",

@@ -6,0 +6,0 @@ "scripts": {

@@ -57,3 +57,3 @@ # Ajax

```html
<script src="//cdn.rawgit.com/fdaciuk/ajax/v2.0.1/dist/ajax.min.js"></script>
<script src="//cdn.rawgit.com/fdaciuk/ajax/v2.1.0/dist/ajax.min.js"></script>
```

@@ -66,3 +66,3 @@

```js
define(['ajax'], function(ajax) {
define(['ajax'], function (ajax) {
ajax().get(...)

@@ -123,3 +123,3 @@ ...

request.then(function(response) {...})
request.then(function (response) {...})
```

@@ -212,3 +212,3 @@

```js
ajax().get('/api/users').then(function(response, xhr) {
ajax().get('/api/users').then(function (response, xhr) {
// Do something

@@ -223,3 +223,3 @@ })

```js
ajax().post('/api/users', { slug: 'john' }).catch(function(response, xhr) {
ajax().post('/api/users', { slug: 'john' }).catch(function (response, xhr) {
// Do something

@@ -234,3 +234,3 @@ })

```js
ajax().post('/api/users', { slug: 'john' }).always(function(response, xhr) {
ajax().post('/api/users', { slug: 'john' }).always(function (response, xhr) {
// Do something

@@ -240,2 +240,21 @@ })

## Abort request
If a request is very slow, you can abort it using `abort()` method:
```js
const getLazyUser = ajax().get('/api/users/lazy')
const timer = setTimeout(function () {
getLazyUser.abort()
}, 3000)
getLazyUser.then(function (response) {
clearTimeout(timer)
console.log(response)
})
```
In the above example, if request is slowest than 3 seconds, it will be aborted.
## Deprecated methods

@@ -242,0 +261,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