🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

ic-ajax

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ic-ajax - npm Package Compare versions

Comparing version

to
0.2.0

18

main.js
/*!
* ic-ajax
*
* - please see license at https://github.com/instructure/ember-ajax
* - (c) 2013 Instructure, Inc
* - please see license at https://github.com/instructure/ic-ajax/blob/master/LICENSE
* - inspired by discourse ajax: https://github.com/discourse/discourse/blob/master/app/assets/javascripts/discourse/mixins/ajax.js#L19

@@ -21,7 +22,18 @@ */

* jQuery.ajax wrapper, supports the same signature except providing
* `success` and `error` handlers will throw an error (use promises
* instead).
* `success` and `error` handlers will throw an error (use promises instead)
* and it resolves only the response (no access to jqXHR or textStatus).
*/
var ajax = function() {
return ajax.raw.apply(null, arguments).then(function(result) {
return result.response;
});
};
/*
* Same as `ajax` except it resolves an object with `{response, textStatus,
* jqXHR}`, useful if you need access to the jqXHR object for headers, etc.
*/
ajax.raw = function() {
return makePromise(parseArgs.apply(null, arguments));

@@ -28,0 +40,0 @@ };

2

package.json
{
"name": "ic-ajax",
"version": "0.1.2",
"version": "0.2.0",
"description": "ember friendly $.ajax wrapper",

@@ -5,0 +5,0 @@ "main": "main.js",

@@ -42,5 +42,6 @@ ic-ajax

- success and error callbacks are not supported
- does not resolve three arguments like $.ajax but instead an object
with the three "arguments" as keys (real promises only resolve a
single value and ic-ajax uses RSVP).
- does not resolve three arguments like $.ajax (real promises only
resolve a single value). `ic.ajax` only resolves the response data
from the request, while ic.ajax.raw resolves an object with the three
"arguments" as keys if you need them.

@@ -53,10 +54,12 @@ Other than that, use it exactly like `$.ajax`.

model: function() {
return ajax('/foo').then(function(result) {
// result.response
// result.textStatus
// result.jqXHR
return result.response;
});
return ajax('/foo');
}
}
// if you need access to the jqXHR or textStatus, use raw
ajax.raw('/foo').then(function(result) {
// result.response
// result.textStatus
// result.jqXHR
});
```

@@ -81,3 +84,3 @@

ic.ajax('api/v1/courses').then(function(result) {
deepEqual(result, ic.ajax.lookupFixture('api/v1/courses'));
deepEqual(result, ic.ajax.lookupFixture('api/v1/courses').response);
});

@@ -89,2 +92,4 @@ ```

Install dependencies and run tests with the following:
```sh

@@ -91,0 +96,0 @@ bower install

Sorry, the diff of this file is not supported yet