Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
docs: update README; fix: add warnings for deprecation; version: bump…
Browse files Browse the repository at this point in the history
… to 0.0.53--alpha
  • Loading branch information
js2me committed Dec 19, 2018
1 parent 82dc3e5 commit c6dc880
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 7 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</div>
<b>kinka</b> it is very light weight (<b>~4KB minfied version</b>, <b>~1.5KB gzipped</b>) JavaScript library which allows to reduce http code ( which are using <a href="https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest">XMLHttpRequests</a> ) and do http code more simple and easy to read.

**CAUTION** : alpha version.
❗️❗️❗️**CAUTION**❗️❗️❗️ : Currently it is alpha version. And soon the package will has been updated to [release version (1.0.0)](https://github.com/acacode/kinka/pull/3) and then most changes in the release version will be not compatible with alpha version ( property "body" will be renamed to "data" for more readable ). And also all code of the kinka will has been wrapped to unit tests and ,of course, most bugs has been fixed in the release version.

<a href="https://jsfiddle.net/js2me/0y3ng8xu/"> Test kinka in JSFiddle </a>

Expand Down Expand Up @@ -57,4 +57,4 @@ 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.
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
4 changes: 2 additions & 2 deletions dist/kinka.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ eval("function merge() {\n var object = {};\n for (var args = Array.prototype.
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

eval("var baseHelpers = __webpack_require__(/*! ./base */ \"./lib/helpers/base.js\");\nvar createResponse = __webpack_require__(/*! ./response */ \"./lib/helpers/response.js\").createResponse;\n\nvar isObject = baseHelpers.isObject;\nvar merge = baseHelpers.merge;\n\nvar abortableRequests = {};\n\nfunction abortRequest(key) {\n if (abortableRequests[key]) {\n abortableRequests[key].abort();\n removeAbortableKey(key);\n }\n}\n\nfunction getAbortableRequest(key) {\n abortRequest(key);\n abortableRequests[key] = new XMLHttpRequest();\n return abortableRequests[key];\n}\n\nfunction removeAbortableKey(key) {\n abortableRequests[key] = null;\n delete abortableRequests[key];\n}\n\nfunction requestIsSuccess(request, specificSuccessStatus) {\n var status = request.status;\n return specificSuccessStatus ? status === specificSuccessStatus : status >= 200 && status < 300 || status === 101;\n}\n\nfunction setHeaders(request, headers) {\n var headerNames = Object.keys(headers);\n for (var x = 0; x < headerNames.length; x++) request.setRequestHeader(headerNames[x], headers[headerNames[x]]);\n}\n\nfunction getUrlWithQuery(url, query) {\n var parsed = url.split('?');\n var rawUrl = parsed[0];\n var queryString = parsed[1] ? [parsed[1]] : [];\n Object.keys(query).forEach(function (key) {\n queryString.push(key + '=' + query[key]);\n });\n return rawUrl + '?' + queryString.join('&');\n}\n\nfunction getUrl(path, baseURL, query) {\n var protocol = path.substring(0, 4);\n var url = protocol === 'http' || protocol.indexOf('ws') !== -1 || protocol.indexOf('//') !== -1 ? path : baseURL + path;\n if (!query) return url;\n return getUrlWithQuery(url, query);\n}\n\nfunction createRequest(method, path, requestOptions, requestBody) {\n var options = merge(this.options, requestOptions, requestBody);\n var abortableKey = options.abortableKey;\n var rawBody = options.body;\n var body = !isObject(rawBody) || rawBody instanceof FormData ? rawBody : JSON.stringify(rawBody);\n var url = getUrl(path, this.baseURL, options.query);\n var request = abortableKey ? getAbortableRequest(abortableKey) : new XMLHttpRequest();\n request.timeout = options.timeout;\n return new Promise(function (resolve, reject) {\n request.withCredentials = !!options.withAuth;\n request.onreadystatechange = function () {\n if (request.readyState === XMLHttpRequest.DONE) {\n var isError = !requestIsSuccess(request, options.successStatus);\n var response = createResponse(request, isError);\n if (!options.omitCatches && isError) reject(response);else resolve(response);\n request = null;\n if (abortableKey) removeAbortableKey(abortableKey);\n }\n };\n request.open(method.toUpperCase(), url, true);\n if (isObject(options.headers)) setHeaders(request, options.headers);\n request.send(body);\n });\n}\n\nmodule.exports = {\n createRequest: createRequest,\n abortRequest: abortRequest\n};\n\n//# sourceURL=webpack://kinka/./lib/helpers/request.js?");
eval("var baseHelpers = __webpack_require__(/*! ./base */ \"./lib/helpers/base.js\");\nvar createResponse = __webpack_require__(/*! ./response */ \"./lib/helpers/response.js\").createResponse;\n\nvar isObject = baseHelpers.isObject;\nvar merge = baseHelpers.merge;\n\nvar abortableRequests = {};\n\nfunction abortRequest(key) {\n if (abortableRequests[key]) {\n abortableRequests[key].abort();\n removeAbortableKey(key);\n }\n}\n\nfunction getAbortableRequest(key) {\n abortRequest(key);\n abortableRequests[key] = new XMLHttpRequest();\n return abortableRequests[key];\n}\n\nfunction removeAbortableKey(key) {\n abortableRequests[key] = null;\n delete abortableRequests[key];\n}\n\nfunction requestIsSuccess(request, specificSuccessStatus) {\n var status = request.status;\n return specificSuccessStatus ? status === specificSuccessStatus : status >= 200 && status < 300 || status === 101;\n}\n\nfunction setHeaders(request, headers) {\n var headerNames = Object.keys(headers);\n for (var x = 0; x < headerNames.length; x++) request.setRequestHeader(headerNames[x], headers[headerNames[x]]);\n}\n\nfunction getUrlWithQuery(url, query) {\n var parsed = url.split('?');\n var rawUrl = parsed[0];\n var queryString = parsed[1] ? [parsed[1]] : [];\n Object.keys(query).forEach(function (key) {\n queryString.push(key + '=' + query[key]);\n });\n return rawUrl + '?' + queryString.join('&');\n}\n\nfunction getUrl(path, baseURL, query) {\n var protocol = path.substring(0, 4);\n var url = protocol === 'http' || protocol.indexOf('ws') !== -1 || protocol.indexOf('//') !== -1 ? path : baseURL + path;\n if (!query) return url;\n return getUrlWithQuery(url, query);\n}\n\nfunction createRequest(method, path, requestOptions, requestBody) {\n var requestInspector = this.inspectors.request;\n var responseInspector = this.inspectors.response;\n var options = merge(this.options, requestOptions, requestOptions && this.auth && requestOptions.auth && this.auth(requestOptions.auth));\n if (options.body) {\n console.warn('kinka warning: property \"body\" will be renamed to \"data\" in the 1.0.0 kinka release version');\n }\n if (options.data) {\n options.body = options.data;\n }\n if (requestBody) {\n options.body = requestBody;\n }\n if (requestInspector) {\n options = requestInspector(getUrl(path, this.baseURL, options.query), method, options) || options;\n }\n var abortableKey = options.abortableKey;\n var rawBody = options.body;\n var body = !isObject(rawBody) || rawBody instanceof FormData ? rawBody : JSON.stringify(rawBody);\n var url = getUrl(path, this.baseURL, options.query);\n var request = abortableKey ? getAbortableRequest(abortableKey) : new XMLHttpRequest();\n return new Promise(function (resolve, reject) {\n request.withCredentials = !!options.withAuth;\n request.onreadystatechange = function () {\n if (request.readyState === XMLHttpRequest.DONE) {\n var isError = !requestIsSuccess(request, options.successStatus);\n var response = createResponse(request, isError);\n if (responseInspector) {\n response = responseInspector(url, method, response) || response;\n }\n if (!options.omitCatches && isError) reject(response);else resolve(response);\n request = null;\n if (abortableKey) removeAbortableKey(abortableKey);\n }\n };\n request.open(method.toUpperCase(), url, true);\n request.timeout = options.timeout;\n if (isObject(options.headers)) setHeaders(request, options.headers);\n request.send(body);\n });\n}\n\nmodule.exports = {\n createRequest: createRequest,\n abortRequest: abortRequest\n};\n\n//# sourceURL=webpack://kinka/./lib/helpers/request.js?");

/***/ }),

Expand All @@ -136,7 +136,7 @@ eval("var parseJSON = __webpack_require__(/*! ./base */ \"./lib/helpers/base.js\
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

eval("/**\r\n * Copyright (c) acacode, Inc. and its affiliates.\r\n *\r\n * This source code is licensed under the MIT license found in the\r\n * LICENSE file in the root directory of this source tree.\r\n *\r\n * @flow\r\n */\nvar baseHelpers = __webpack_require__(/*! ./helpers/base */ \"./lib/helpers/base.js\");\nvar requestHelpers = __webpack_require__(/*! ./helpers/request */ \"./lib/helpers/request.js\");\nvar isUndefined = baseHelpers.isUndefined;\n\nfunction Kinka(instanceOptions) {\n if (!(this instanceof Kinka)) {\n return new Kinka(instanceOptions);\n }\n if (!instanceOptions) instanceOptions = {};\n var customMethods = instanceOptions.customMethods;\n this.baseURL = isUndefined(instanceOptions.baseURL, location ? location.origin : '');\n this.options = {\n omitCatches: isUndefined(instanceOptions.omitCatches, true),\n headers: isUndefined(instanceOptions.headers, {}),\n timeout: isUndefined(instanceOptions.timeout, 0)\n };\n if (customMethods) for (var i in customMethods) this[customMethods[i]] = createMethodHandler(customMethods[i]);\n this.inspectors = instanceOptions.inspectors || {};\n return this;\n}\n\nfunction createMethodHandler(methodName, hasBody) {\n return function (path, arg1, arg2) {\n var config = hasBody ? [arg2, arg1] : [arg1];\n return this.custom(methodName, path, config[0], config[1]);\n };\n}\n\nKinka.prototype = {\n abort: requestHelpers.abortRequest,\n all: Promise.all,\n create: Kinka,\n custom: requestHelpers.createRequest,\n delete: createMethodHandler('delete'),\n get: createMethodHandler('get'),\n head: createMethodHandler('head'),\n options: createMethodHandler('options'),\n patch: createMethodHandler('patch', true),\n post: createMethodHandler('post', true),\n put: createMethodHandler('put', true)\n};\n\nmodule.exports = window.kinka = new Kinka();\n\n//# sourceURL=webpack://kinka/./lib/kinka.js?");
eval("/**\n * Copyright (c) acacode, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * @flow\n */\nvar baseHelpers = __webpack_require__(/*! ./helpers/base */ \"./lib/helpers/base.js\");\nvar requestHelpers = __webpack_require__(/*! ./helpers/request */ \"./lib/helpers/request.js\");\nvar isUndefined = baseHelpers.isUndefined;\n\nfunction Kinka(instanceOptions) {\n if (!(this instanceof Kinka)) {\n return new Kinka(instanceOptions);\n }\n if (!instanceOptions) instanceOptions = {};\n var customMethods = instanceOptions.customMethods;\n this.baseURL = isUndefined(instanceOptions.baseURL, location ? location.origin : '');\n this.options = {\n omitCatches: isUndefined(instanceOptions.omitCatches, true),\n headers: isUndefined(instanceOptions.headers, {}),\n timeout: isUndefined(instanceOptions.timeout, 0)\n };\n if (customMethods) for (var i in customMethods) this[customMethods[i]] = createMethodHandler(customMethods[i]);\n this.inspectors = instanceOptions.inspectors || {};\n if (instanceOptions.auth) this.auth = instanceOptions.auth;\n return this;\n}\n\nfunction createMethodHandler(methodName, hasBody) {\n return function (path, arg1, arg2) {\n var config = hasBody ? [arg2, arg1] : [arg1];\n return this.custom(methodName, path, config[0], config[1]);\n };\n}\n\nKinka.prototype = {\n abort: requestHelpers.abortRequest,\n all: Promise.all,\n create: Kinka,\n custom: requestHelpers.createRequest,\n delete: createMethodHandler('delete'),\n get: createMethodHandler('get'),\n head: createMethodHandler('head'),\n options: createMethodHandler('options'),\n patch: createMethodHandler('patch', true),\n post: createMethodHandler('post', true),\n put: createMethodHandler('put', true)\n};\n\nmodule.exports = window.kinka = new Kinka();\n\n//# sourceURL=webpack://kinka/./lib/kinka.js?");

/***/ })

Expand Down
2 changes: 1 addition & 1 deletion dist/kinka.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit c6dc880

Please sign in to comment.