Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
request(options, function (error, response, body) {
if (null !== error || 200 != response.statusCode)
{
return reject({error:error,response:response,body:body});
}
let list = [];
const dom = htmlparser2.parseDOM(body);
const trList = CSSselect.selectAll('table tbody tr', dom);
_.forEach(trList, (tr, trIndex) => {
let tdList = CSSselect.selectAll('td', tr);
// not enough column ?
if (mapping.length != tdList.length)
{
// no date (ie single column No data was found for the selected time period. )
if (1 == tdList.length && 1 == trList.length)
{
return false;
}
logger.warn("Could not parse Coin Market Cap historical data for '%s' (row #%d) : got %d columns instead of %d", currency, trIndex, tdList.length, mapping.length);
return false;
}
let entry = {};
_.forEach(tdList, (td, tdIndex) => {
entry[mapping[tdIndex]] = 0 != tdIndex ? self._parseFloat(td) : self._parseDate(td);
_.forEach(trList, (tr, trIndex) => {
let tdList = CSSselect.selectAll('td', tr);
// not enough column ?
if (mapping.length != tdList.length)
{
// no date (ie single column No data was found for the selected time period. )
if (1 == tdList.length && 1 == trList.length)
{
return false;
}
logger.warn("Could not parse Coin Market Cap historical data for '%s' (row #%d) : got %d columns instead of %d", currency, trIndex, tdList.length, mapping.length);
return false;
}
let entry = {};
_.forEach(tdList, (td, tdIndex) => {
entry[mapping[tdIndex]] = 0 != tdIndex ? self._parseFloat(td) : self._parseDate(td);
});
// coin market cap will return newest first
return dom => {
if (matchId(opts.removeStroke, id)) {
selectAll("[stroke]", dom).forEach(removeStrokeAttrib);
}
};
}
Object.keys(selectors).forEach(selector => {
selectAll(selector, svg).forEach(applyParams(selectors[selector]));
});
};
export function querySelectorAll(query, elems) {
return CSSselect.selectAll(resolveQuery(query), elems, {adapter});
}
function querySelectorAll(query, elems) {
return CSSselect.selectAll(resolveQuery(query), elems, {
adapter: adapter
});
}
public querySelectorAll(selector) {
return css.selectAll(selector, this._dom).map(d => new Element(this._withParent(d)))
}
return dom => {
if (matchId(opts.removeFill, id)) {
selectAll("[fill]", dom).forEach(removeFillAttrib);
}
};
}
function extractFromDocumentAsync(cache, dom) {
const cssElements = CSSselect.selectAll('style, link[rel~="stylesheet"]', dom);
const resultPromises = cssElements.map(element => extractFromElementAsync(cache, element) );
const mergedPromise = Promise.all(resultPromises).then(mergeResults);
return mergedPromise;
}