This commit is contained in:
Lukian LEIZOUR 2022-11-26 15:56:34 +01:00
parent 70e2f7a8aa
commit 008d2f30d7
675 changed files with 189892 additions and 0 deletions

3
node_modules/xhr-response/.npmignore generated vendored Normal file
View file

@ -0,0 +1,3 @@
node_modules
.tern-port
coverage

18
node_modules/xhr-response/.travis.yml generated vendored Normal file
View file

@ -0,0 +1,18 @@
language: node_js
node_js:
- "0.12"
- "0.10"
- "0.8"
- "iojs"
before_install:
- "npm install -g npm@1.4.x"
script:
- "npm run test-travis"
after_script:
- "npm install coveralls@2.11.x && cat coverage/lcov.info | coveralls"
notifications:
irc:
channels:
- "irc.freenode.org#unshift"
on_success: change
on_failure: change

45
node_modules/xhr-response/README.md generated vendored Normal file
View file

@ -0,0 +1,45 @@
# xhr-response
[![Made by unshift][made-by]](http://unshift.io)[![Version npm][version]](http://browsenpm.org/package/xhr-response)[![Build Status][build]](https://travis-ci.org/unshiftio/xhr-response)[![Dependencies][david]](https://david-dm.org/unshiftio/xhr-response)[![Coverage Status][cover]](https://coveralls.io/r/unshiftio/xhr-response?branch=master)[![IRC channel][irc]](http://webchat.freenode.net/?channels=unshift)
[made-by]: https://img.shields.io/badge/made%20by-unshift-00ffcc.svg?style=flat-square
[version]: https://img.shields.io/npm/v/xhr-response.svg?style=flat-square
[build]: https://img.shields.io/travis/unshiftio/xhr-response/master.svg?style=flat-square
[david]: https://img.shields.io/david/unshiftio/xhr-response.svg?style=flat-square
[cover]: https://img.shields.io/coveralls/unshiftio/xhr-response/master.svg?style=flat-square
[irc]: https://img.shields.io/badge/IRC-irc.freenode.net%23unshift-00a8ff.svg?style=flat-square
The `xhr-response` is a small helper library for safely extracting response data
from XHR requests. There are some minor bugs in browsers which can cause
exceptions to be thrown when accessing the wrong properties of an XHR request
instance. This module works around these bugs.
## Installation
This module is primary written for client-side code which use the commonjs
module pattern for exporting.
```
npm install --save xhr-response
```
## Usage
It's just as simple as:
```js
var response = require("xhr-response");
var xhr = new XMLHTTPRequest();
// .. stuffs ..
xhr.onload = function () {
var data = response(xhr);
console.log('data', data);
};
```
## License
MIT

30
node_modules/xhr-response/index.js generated vendored Normal file
View file

@ -0,0 +1,30 @@
'use strict';
/**
* Safely access the response body.
*
* @param {XHR} xhr XHR request who's body we need to safely extract.
* @returns {Mixed} The response body.
* @api public
*/
module.exports = function get(xhr) {
if (xhr.response) return xhr.response;
var type = xhr.responseType || '';
//
// Browser bugs:
//
// IE<10: Accessing binary data's responseText will throw an Exception
// Chrome: When responseType is set to Blob it will throw errors even when
// Accessing the responseText property.
//
// Firefox: An error is thrown when reading the `responseText` after unload
// when responseType is using a `moz-chunked-*` type.
// https://bugzilla.mozilla.org/show_bug.cgi?id=687087
//
if (~type.indexOf('moz-chunked') && xhr.readyState === 4) return;
if ('blob' !== type && 'string' === typeof xhr.responseText) {
return xhr.responseText || xhr.responseXML;
}
};

39
node_modules/xhr-response/package.json generated vendored Normal file
View file

@ -0,0 +1,39 @@
{
"name": "xhr-response",
"version": "1.0.1",
"description": "Safely extract the XHR response from your XHR instance.",
"main": "index.js",
"scripts": {
"100%": "istanbul check-coverage --statements 100 --functions 100 --lines 100 --branches 100",
"test": "mocha test.js",
"watch": "mocha --watch test.js",
"coverage": "istanbul cover ./node_modules/.bin/_mocha -- test.js",
"test-travis": "istanbul cover node_modules/.bin/_mocha --report lcovonly -- test.js"
},
"repository": {
"type": "git",
"url": "https://github.com/unshiftio/xhr-response"
},
"keywords": [
"xhr",
"response",
"body",
"data",
"responseText",
"responseXML",
"XMLHTTPRequest",
"request"
],
"author": "Arnout Kazemier",
"license": "MIT",
"bugs": {
"url": "https://github.com/unshiftio/xhr-response/issues"
},
"homepage": "https://github.com/unshiftio/xhr-response",
"devDependencies": {
"assume": "1.2.x",
"istanbul": "0.3.x",
"mocha": "2.2.x",
"pre-commit": "1.0.x"
}
}

63
node_modules/xhr-response/test.js generated vendored Normal file
View file

@ -0,0 +1,63 @@
describe('xhr-response', function () {
'use strict';
var assume = require('assume')
, response = require('./');
it('is exported as a function', function () {
assume(response).is.a('function');
});
it('defaults to the `reponse` property when available', function () {
var wat = response({
response: 'wat',
responseText: 'lol'
});
assume(wat).equals('wat');
});
it('does not access the `responseText` for `blob` types', function () {
var wat = response({
responseText: 'lol',
responseType: 'blob'
});
assume(wat).is.a('undefined');
});
it('does not access the `responseText` during load for moz-chunked-* calls', function () {
var wat = response({
responseText: 'lol',
responseType: 'moz-chunked-text',
readyState: 4
});
assume(wat).is.a('undefined');
wat = response({
responseText: 'lol',
responseType: 'moz-chunked-text',
readyState: 3
});
assume(wat).equals('lol');
wat = response({
responseText: 'lol',
responseType: 'moz-chunked-arraybuffer',
readyState: 4
});
assume(wat).is.a('undefined');
});
it('returns the responseXML if there is no text', function () {
var wat = response({
responseText: '',
responseXML: '<xml>'
});
assume(wat).equals('<xml>');
});
});