Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return new Promise(async (resolve)=> {
tinify.key = apiKey;
tinify.validate(function(err) {
if (err) {
console.log('该api-key不是有效值');
resolve(false);
}
});
let count = 500;
Object.defineProperty(tinify, 'compressionCount', {
get: ()=> {
return count;
},
set: newValue => {
count = newValue;
resolve(true);
},
enumerable : true,
configurable : true
return new Promise((resolve, reject) => {
tinify.validate(function(err) {
if (err) {
reject(new TinyPngValidateError())
}
const compressionsThisMonth = tinify.compressionCount
if (compressionsThisMonth + images.length > 500) {
console.log(
colors.red("compressions this month is over follow (> 500).")
)
} else {
const left = 500 - compressionsThisMonth
console.log(colors.yellow("compressions this month left " + left))
}
resolve("tinyPng is valid.")
})