Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
for (let type of
Object.keys(nodeResources)
.map(r => nodeResources[r].type)
.filter(v => !v.startsWith('num:'))
.filter((v, i, a) => a.indexOf(v) === i) // make unique
) {
let resourceIndices =
Object.keys(nodeResources)
.map(r => nodeResources[r])
.filter(r => r.type == type)
.map(r => r.index)
if (resourceIndices.length > 0) {
if (!first) {
summary += ' + '
}
summary += type + ' ' + new MultiRange(resourceIndices.join(',')).getRanges()
.map(range => range[0] == range[1] ? range[0] : range[0] + '-' + range[1])
.join(',')
first = false
}
}
summary += ']'
}
return summary
} catch (ex) {}
}
var url = options.url;
if (!url) {
reject(new Error('"url" option is required.'));
return promise;
}
var frames = options.frames;
if (!frames && frames !== 0) {
reject(new Error('"frames" option is required.'));
return promise;
}
var outputType = options.outputType || 'jpg';
var quality = options.quality;
var cumulative = options.cumulative;
var acceptedFrames = frames === 'all' ? 'all' : new MultiRange(frames);
// Necessary to check if we're in Node or the browser until this is fixed:
// https://github.com/scijs/get-pixels/issues/33
var inputType = typeof window === 'undefined' ? 'image/gif' : '.GIF';
getPixels(url, inputType, function (err, pixels, framesInfo) {
if (err) {
reject(err);
return;
}
if (pixels.shape.length < 4) {
reject(new Error('"url" input should be multi-frame GIF.'));
return;
}
var frameData = [];
var maxAccumulatedFrame = 0;
for (var i = 0; i < pixels.shape[0]; i++) {
console.log(' --save-poster-images Save first frame of each page as image');
process.exit(1);
}
if (argv.help) {
usage();
}
const input = argv._[0];
if (!input) {
usage();
}
let pagesRange = null;
try {
pagesRange = multirange(
argv.pages || '0-',
{ parseUnbounded: true },
);
} catch (e) {
console.error('Invalid pages range');
process.exit(1);
}
let json;
try {
json = JSON.parse(fs.readFileSync(input, 'utf8'));
} catch (e) {
console.error(`Unable to load json ${input}`);
process.exit(1);
}
}
let summary = ''
for(let nodeId of Object.keys(nodes)) {
let nodeResources = nodes[nodeId].filter(r => r.type)
if (summary != '') {
summary += ' + '
}
summary += nodeId + '['
let first = true
for(let type of nodeResources.map(r => r.type).filter((v, i, a) => a.indexOf(v) === i)) {
let resourceIndices = nodeResources.filter(r => r.type == type).map(r => r.index)
if (resourceIndices.length > 0) {
if (!first) {
summary += ' + '
}
summary += type + ' ' + new MultiRange(resourceIndices.join(',')).getRanges()
.map(range => range[0] == range[1] ? range[0] : range[0] + '-' + range[1])
.join(',')
first = false
}
}
summary += ']'
}
return summary
}
const mr = value =>
multirange(value, { parseUnbounded: true, parseNegative: true });