bing-image-search-async-iterator
Advanced tools
Comparing version 1.2.1 to 1.2.2
@@ -18,12 +18,2 @@ 'use strict'; | ||
const apiEndPoint = 'https://api.cognitive.microsoft.com/bing/v7.0/images/search'; | ||
const defaults = { | ||
key: null, | ||
query: null, | ||
market: null, | ||
safeSearch: null, | ||
offset: 0, | ||
count: 150, | ||
amount: 2000, | ||
fetchCb: _crossFetch2.default | ||
}; | ||
const HEADERS = { | ||
@@ -49,37 +39,36 @@ API_KEY: 'Ocp-Apim-Subscription-Key', | ||
exports.default = (() => { | ||
var _ref = _asyncGenerator.wrap(function* (options) { | ||
var _Object$assign = Object.assign({}, defaults, options); | ||
const key = _Object$assign.key, | ||
query = _Object$assign.query, | ||
market = _Object$assign.market, | ||
safeSearch = _Object$assign.safeSearch, | ||
aspect = _Object$assign.aspect, | ||
color = _Object$assign.color, | ||
imageContent = _Object$assign.imageContent, | ||
imageType = _Object$assign.imageType, | ||
license = _Object$assign.license, | ||
freshness = _Object$assign.freshness, | ||
size = _Object$assign.size, | ||
width = _Object$assign.width, | ||
height = _Object$assign.height, | ||
minWidth = _Object$assign.minWidth, | ||
minHeight = _Object$assign.minHeight, | ||
maxWidth = _Object$assign.maxWidth, | ||
maxHeight = _Object$assign.maxHeight, | ||
minFileSize = _Object$assign.minFileSize, | ||
maxFileSize = _Object$assign.maxFileSize, | ||
offset = _Object$assign.offset, | ||
count = _Object$assign.count, | ||
amount = _Object$assign.amount, | ||
clientIP = _Object$assign.clientIP, | ||
location = _Object$assign.location, | ||
queryParams = _Object$assign.queryParams, | ||
headerParams = _Object$assign.headerParams, | ||
fetchCb = _Object$assign.fetchCb; | ||
var _ref = _asyncGenerator.wrap(function* ({ | ||
key, | ||
query, | ||
market, | ||
safeSearch, | ||
aspect, | ||
color, | ||
imageContent, | ||
imageType, | ||
license, | ||
freshness, | ||
size, | ||
width, | ||
height, | ||
minWidth, | ||
minHeight, | ||
maxWidth, | ||
maxHeight, | ||
minFileSize, | ||
maxFileSize, | ||
offset = 0, | ||
count = 150, | ||
amount = 2000, | ||
clientID, | ||
clientIP, | ||
location, | ||
queryParams, | ||
headerParams, | ||
fetchCb = _crossFetch2.default | ||
} = {}) { | ||
let currOffset = offset; | ||
let currAmount = amount; | ||
let available = currOffset + currAmount; | ||
let clientID = options.clientID; | ||
let responseClientID; | ||
@@ -111,3 +100,3 @@ while (currOffset < Math.min(currOffset + currAmount, available)) { | ||
[HEADERS.API_KEY]: key, | ||
[HEADERS.CLIENT_ID]: clientID, | ||
[HEADERS.CLIENT_ID]: clientID === undefined ? responseClientID : clientID, | ||
[HEADERS.CLIENT_IP]: clientIP, | ||
@@ -134,3 +123,3 @@ [HEADERS.LOCATION]: location, | ||
available = body.totalEstimatedMatches; | ||
clientID = clientID === undefined ? response.headers.get(HEADERS.CLIENT_ID) : clientID; | ||
responseClientID = response.headers.get(HEADERS.CLIENT_ID); | ||
yield body; | ||
@@ -140,3 +129,3 @@ } | ||
function search(_x) { | ||
function search() { | ||
return _ref.apply(this, arguments); | ||
@@ -143,0 +132,0 @@ } |
{ | ||
"name": "bing-image-search-async-iterator", | ||
"description": "Async iterator for Bing Image Search API call responses", | ||
"version": "1.2.1", | ||
"version": "1.2.2", | ||
"author": "David Hu", | ||
"bugs": "https://github.com/funpokes/bing-image-search-async-iterator/issues", | ||
"dependencies": { | ||
"cross-fetch": "^2.2.1" | ||
"cross-fetch": "^2.2.3" | ||
}, | ||
@@ -19,3 +19,3 @@ "devDependencies": { | ||
"eslint-config-airbnb-base": "^12.1.0", | ||
"eslint-plugin-import": "^2.12.0", | ||
"eslint-plugin-import": "^2.16.0", | ||
"eslint-plugin-node": "^6.0.1" | ||
@@ -22,0 +22,0 @@ }, |
15990
121
Updatedcross-fetch@^2.2.3