Comparing version 3.0.4 to 3.0.5
@@ -10,2 +10,3 @@ { | ||
"polyfill", | ||
"postpublish", | ||
"reqheaders", | ||
@@ -12,0 +13,0 @@ "truthy", |
'use strict'; | ||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); | ||
@@ -9,4 +11,2 @@ | ||
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
@@ -152,3 +152,3 @@ | ||
if (authorization) { | ||
headers = Object.assign({}, headers, { authorization: authorization }); | ||
headers = _extends({}, headers, { authorization: authorization }); | ||
} | ||
@@ -212,3 +212,3 @@ | ||
if (reqBody) { | ||
headers = Object.assign({}, headers, { | ||
headers = _extends({}, headers, { | ||
'content-type': 'application/json' | ||
@@ -247,31 +247,11 @@ }); | ||
case 'fetch': | ||
reqValue.then(function () { | ||
var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(response) { | ||
var status, headers, data; | ||
return regeneratorRuntime.wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
status = response.status, headers = response.headers; | ||
_context.next = 3; | ||
return response.text(); | ||
reqValue.then(function (response) { | ||
var status = response.status, | ||
headers = response.headers; | ||
case 3: | ||
data = _context.sent; | ||
return response.text().then(function (data) { | ||
return { data: data, status: status, headers: headers }; | ||
}); | ||
}).then(resolve, reject); | ||
resolve({ data: data, status: status, headers: headers }); | ||
case 5: | ||
case 'end': | ||
return _context.stop(); | ||
} | ||
} | ||
}, _callee, _this); | ||
})); | ||
return function (_x5) { | ||
return _ref.apply(this, arguments); | ||
}; | ||
}(), reject); | ||
break; | ||
@@ -278,0 +258,0 @@ } |
'use strict'; | ||
Object.assign(exports, { | ||
queryString: function queryString(input) { | ||
if (!Array.isArray(input) && Object(input) !== input) return ''; | ||
exports.queryString = function (input) { | ||
if (!Array.isArray(input) && Object(input) !== input) return ''; | ||
var output = []; | ||
var output = []; | ||
unwrap(false, input); | ||
return '?' + output.join('&'); | ||
unwrap(false, input); | ||
return '?' + output.join('&'); | ||
function unwrap(base, input) { | ||
var before = '', | ||
after = ''; | ||
if (base) { | ||
before = base + '['; | ||
after = ']'; | ||
} | ||
function unwrap(base, input) { | ||
var before = '', | ||
after = ''; | ||
if (base) { | ||
before = base + '['; | ||
after = ']'; | ||
} | ||
if (Array.isArray(input)) for (var i = 0; i < input.length; i++) { | ||
loop(i + '', input[i]); | ||
} else if (Object(input) === input) for (var key in input) { | ||
loop(key, input[key]); | ||
} else output.push(base + '=' + encodeURIComponent(input)); | ||
if (Array.isArray(input)) for (var i = 0; i < input.length; i++) { | ||
loop(i + '', input[i]); | ||
} else if (Object(input) === input) for (var key in input) { | ||
loop(key, input[key]); | ||
} else output.push(base + '=' + encodeURIComponent(input)); | ||
function loop(key, value) { | ||
unwrap(before + encodeURIComponent(key) + after, value); | ||
} | ||
function loop(key, value) { | ||
unwrap(before + encodeURIComponent(key) + after, value); | ||
} | ||
} | ||
}); | ||
}; |
@@ -101,3 +101,3 @@ const { http, https, URL, btoa, fetch } = require('./requires.node') | ||
if (authorization) { | ||
headers = Object.assign({}, headers, { authorization }) | ||
headers = { ...headers, authorization } | ||
} | ||
@@ -151,5 +151,6 @@ | ||
if (reqBody) { | ||
headers = Object.assign({}, headers, { | ||
headers = { | ||
...headers, | ||
'content-type': 'application/json' | ||
}) | ||
} | ||
} | ||
@@ -180,7 +181,8 @@ | ||
case 'fetch': | ||
reqValue.then(async response => { | ||
const { status, headers } = response | ||
const data = await response.text() | ||
resolve({ data, status, headers }) | ||
}, reject) | ||
reqValue | ||
.then(response => { | ||
const { status, headers } = response | ||
return response.text().then(data => ({ data, status, headers })) | ||
}) | ||
.then(resolve, reject) | ||
@@ -187,0 +189,0 @@ break |
@@ -1,29 +0,27 @@ | ||
Object.assign(exports, { | ||
queryString(input) { | ||
if (!Array.isArray(input) && Object(input) !== input) return '' | ||
exports.queryString = input => { | ||
if (!Array.isArray(input) && Object(input) !== input) return '' | ||
let output = [] | ||
let output = [] | ||
unwrap(false, input) | ||
return '?' + output.join('&') | ||
unwrap(false, input) | ||
return '?' + output.join('&') | ||
function unwrap(base, input) { | ||
let before = '', | ||
after = '' | ||
if (base) { | ||
before = base + '[' | ||
after = ']' | ||
} | ||
function unwrap(base, input) { | ||
let before = '', | ||
after = '' | ||
if (base) { | ||
before = base + '[' | ||
after = ']' | ||
} | ||
if (Array.isArray(input)) | ||
for (let i = 0; i < input.length; i++) loop(i + '', input[i]) | ||
else if (Object(input) === input) | ||
for (let key in input) loop(key, input[key]) | ||
else output.push(base + '=' + encodeURIComponent(input)) | ||
if (Array.isArray(input)) | ||
for (let i = 0; i < input.length; i++) loop(i + '', input[i]) | ||
else if (Object(input) === input) | ||
for (let key in input) loop(key, input[key]) | ||
else output.push(base + '=' + encodeURIComponent(input)) | ||
function loop(key, value) { | ||
unwrap(before + encodeURIComponent(key) + after, value) | ||
} | ||
function loop(key, value) { | ||
unwrap(before + encodeURIComponent(key) + after, value) | ||
} | ||
} | ||
}) | ||
} |
{ | ||
"name": "danbooru", | ||
"version": "3.0.4", | ||
"version": "3.0.5", | ||
"description": "danbooru api wrapper", | ||
@@ -27,2 +27,3 @@ "keywords": [ | ||
"prepublishOnly": "babel lib -d build", | ||
"postpublish": "rimraf build", | ||
"lint": "eslint **/*.js", | ||
@@ -35,2 +36,3 @@ "test": "jest" | ||
"babel-plugin-rewrite-require": "^1.14.5", | ||
"babel-plugin-transform-object-rest-spread": "^6.26.0", | ||
"babel-preset-env": "^1.6.1", | ||
@@ -43,4 +45,5 @@ "eslint": "^4.18.1", | ||
"node-fetch-polyfill": "^2.0.6", | ||
"prettier": "^1.11.1" | ||
"prettier": "^1.11.1", | ||
"rimraf": "^2.6.2" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6
41931
13
22
852