meteora
Advanced tools
Comparing version 0.0.5 to 0.0.6
@@ -13,5 +13,6 @@ function Event(event, params) { | ||
exports.Event = Event; | ||
function ajax(options) { | ||
function ajax() { | ||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
var httpRequest = new XMLHttpRequest(); | ||
var settings = Object.assign({ | ||
var settings = { | ||
url: '/', | ||
@@ -34,9 +35,11 @@ method: 'GET', | ||
} | ||
}, options); | ||
}; // Object assign the settings | ||
if (settings.method === 'GET') { | ||
settings.contentType = 'application/json;charset=UTF-8'; | ||
} else if (settings.method === 'POST') { | ||
settings.contentType = 'application/x-www-form-urlencoded'; | ||
} else { | ||
for (var key in settings) { | ||
if (Object.hasOwnProperty.call(settings, key) && options[key] !== undefined) { | ||
settings[key] = options[key]; | ||
} | ||
} | ||
if (settings.method != 'GET' && settings.method != 'POST') { | ||
console.warn('method: ', settings.method, 'is not valid.'); | ||
@@ -46,2 +49,10 @@ return false; | ||
if (settings.contentType == undefined) { | ||
if (settings.method === 'GET') { | ||
settings.contentType = 'application/json;charset=UTF-8'; | ||
} else if (settings.method === 'POST') { | ||
settings.contentType = 'application/x-www-form-urlencoded'; | ||
} | ||
} | ||
httpRequest.addEventListener("load", settings.load); | ||
@@ -48,0 +59,0 @@ httpRequest.addEventListener("error", settings.error); |
{ | ||
"name": "meteora", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "A library of common javascript functions to make life easier.", | ||
@@ -9,2 +9,6 @@ "main": "dist/index.js", | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/meteora-digital/meteora.git" | ||
}, | ||
"keywords": [ | ||
@@ -20,2 +24,5 @@ "library", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/meteora-digital/meteora/issues" | ||
}, | ||
"devDependencies": { | ||
@@ -29,3 +36,4 @@ "@babel/core": "^7.10.2", | ||
"gulp-plumber": "^1.2.1" | ||
} | ||
}, | ||
"homepage": "https://github.com/meteora-digital/meteora#readme" | ||
} |
# Meteora | ||
### What is this? | ||
A growing library of helper functions to help speed up development time, and / or avoid linking polyfills for older browsers. | ||
### Functions: | ||
#### ajax | ||
This is a basic jQuery ajax replacement which can be used to make XHR requests. | ||
```javascript | ||
ajax | ||
```` | ||
###### Note: The functions is subject to improve and change at any time, things may break if you update the package. Check back in the readme for code updates or feel free to report any issues. |
@@ -1,4 +0,4 @@ | ||
function ajax(options) { | ||
function ajax(options = {}) { | ||
const httpRequest = new XMLHttpRequest(); | ||
const settings = Object.assign({ | ||
const settings = { | ||
url: '/', | ||
@@ -19,9 +19,12 @@ method: 'GET', | ||
} | ||
}, options); | ||
}; | ||
if (settings.method === 'GET') { | ||
settings.contentType = 'application/json;charset=UTF-8' | ||
} else if (settings.method === 'POST') { | ||
settings.contentType = 'application/x-www-form-urlencoded' | ||
} else { | ||
// Object assign the settings | ||
for (const key in settings) { | ||
if (Object.hasOwnProperty.call(settings, key) && options[key] !== undefined) { | ||
settings[key] = options[key]; | ||
} | ||
} | ||
if (settings.method != 'GET' && settings.method != 'POST') { | ||
console.warn('method: ', settings.method, 'is not valid.'); | ||
@@ -31,2 +34,10 @@ return false; | ||
if (settings.contentType == undefined) { | ||
if (settings.method === 'GET') { | ||
settings.contentType = 'application/json;charset=UTF-8' | ||
} else if (settings.method === 'POST') { | ||
settings.contentType = 'application/x-www-form-urlencoded' | ||
} | ||
} | ||
httpRequest.addEventListener("load", settings.load); | ||
@@ -33,0 +44,0 @@ httpRequest.addEventListener("error", settings.error); |
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
20044
519
0
1
15
0