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

20
node_modules/xhr-status/.travis.yml generated vendored Normal file
View file

@ -0,0 +1,20 @@
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"
matrix:
fast_finish: true
notifications:
irc:
channels:
- "irc.freenode.org#unshift"
on_success: change
on_failure: change

22
node_modules/xhr-status/LICENSE generated vendored Normal file
View file

@ -0,0 +1,22 @@
The MIT License (MIT)
Copyright (c) 2015 Unshift.io, Arnout Kazemier, the Contributors.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

59
node_modules/xhr-status/README.md generated vendored Normal file
View file

@ -0,0 +1,59 @@
# xhr-status
[![Made by unshift][made-by]](http://unshift.io)[![Version npm][version]](http://browsenpm.org/package/xhr-status)[![Build Status][build]](https://travis-ci.org/unshiftio/xhr-status)[![Dependencies][david]](https://david-dm.org/unshiftio/xhr-status)[![Coverage Status][cover]](https://coveralls.io/r/unshiftio/xhr-status?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-status.svg?style=flat-square
[build]: https://img.shields.io/travis/unshiftio/xhr-status/master.svg?style=flat-square
[david]: https://img.shields.io/david/unshiftio/xhr-status.svg?style=flat-square
[cover]: https://img.shields.io/coveralls/unshiftio/xhr-status/master.svg?style=flat-square
[irc]: https://img.shields.io/badge/IRC-irc.freenode.net%23unshift-00a8ff.svg?style=flat-square
Normalize the XHR status codes across various of environments. This eliminates
all the odd browser bugs that you might run in to while working with XHR
requests in browsers:
- Captures thrown errors when accessing `statusText`
- Normalizes the `1233` status code in Internet Explorer for `204` content.
- Normalizes the `0` status code to `200` for `file://` requests.
## Installation
The module is released in the public npm registry and can be installed by
running:
```
npm install --save xhr-status
```
## Usage
This module exports a single function. The returned function accepts one single
argument which is a reference to the `xhr` instance that you've created. It will
return an object with the following keys:
- **code** The XHR status code.
- **text** The XHR status text.
See for an implementation example:
```js
'use strict';
var xhrstatus = require('xhr-status')
, xhr = new XMLHTTPRequest.
xhr.open('GET', 'http://google.com/gen_204', true);
xhr.onload = function () {
var status = xhrstatus(xhr);
console.log(status.code) // 204
console.log(status.text) // OK
};
xhr.send();
```
## License
MIT

55
node_modules/xhr-status/index.js generated vendored Normal file
View file

@ -0,0 +1,55 @@
'use strict';
/**
* Get the correct status code for a given XHR request.
*
* @param {XHR} xhr A XHR request who's status code needs to be retrieved.
* @returns {Object}
* @api public
*/
module.exports = function status(xhr) {
var local = /^file:/.test(xhr.responseURL)
, code = xhr.status
, text = '';
//
// Older version IE incorrectly return status code 1233 for requests that
// respond with a 204 header.
//
// @see http://stackoverflow.com/q/10046972
//
if (1233 === code) return {
error: false,
text: 'OK',
code: 204
};
//
// If you make a request with a file:// protocol it returns status code 0 by
// default so we're going to assume 200 instead. But if you do a HTTP request
// to dead server you will also get the same 0 response code in chrome. So
// we're going to assume statusCode 200 for local files.
//
if (0 === code) return local ? {
error: false,
text: 'OK',
code: 200
} : {
error: true,
text: 'An unknown error occured',
code: 0
};
//
// FireFox will throw an error when accessing the statusText on faulty
// cross-domain requests.
//
try { text = xhr.statusText; }
catch (e) {}
return {
error: code >= 400,
text: text,
code: code
};
};

37
node_modules/xhr-status/package.json generated vendored Normal file
View file

@ -0,0 +1,37 @@
{
"name": "xhr-status",
"version": "1.0.1",
"description": "Normalize XHR status code/text across various of environments",
"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-status"
},
"keywords": [
"status",
"statuscode",
"text",
"code",
"statustext",
"xhr"
],
"author": "Arnout Kazemier",
"license": "MIT",
"bugs": {
"url": "https://github.com/unshiftio/xhr-status/issues"
},
"homepage": "https://github.com/unshiftio/xhr-status",
"devDependencies": {
"assume": "1.x.x",
"istanbul": "0.x.x",
"mocha": "4.x.x",
"pre-commit": "1.x.x"
}
}

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

@ -0,0 +1,63 @@
describe('xhr-status', function () {
'use strict';
var assume = require('assume')
, status = require('./');
it('is exported as function', function () {
assume(status).is.a('function');
});
it('corrects the 1233 status code', function () {
var xhr = {
status: 1233,
responseText: 'moo',
responseURL: 'http://google.com/204'
};
assume(status(xhr).code).equals(204);
assume(status(xhr).error).equals(false);
assume(status(xhr).text).equals('OK');
});
it('corrects status code 0 to 200 for local files', function () {
var xhr = {
status: 0,
responseText: 'moo',
responseURL: 'file://google/com/204'
};
assume(status(xhr).code).equals(200);
assume(status(xhr).error).equals(false);
assume(status(xhr).text).equals('OK');
});
it('keep status 0 for non local requests', function () {
var xhr = {
status: 0,
responseText: 'moo',
responseURL: 'http://google.com/204'
};
assume(status(xhr).code).equals(0);
assume(status(xhr).error).equals(true);
assume(status(xhr).text).equals('An unknown error occured');
});
it('uses a blank statusText if it throws (firefox edgecase)', function () {
var xhr = {
status: 404,
responseURL: 'http://google.com/204'
};
Object.defineProperty(xhr, 'statusText', {
get: function () {
throw new Error('lol cakes');
}
});
assume(status(xhr).error).equals(true);
assume(status(xhr).code).equals(404);
assume(status(xhr).text).equals('');
});
});