How to use the tinify.validate function in tinify

To help you get started, we’ve selected a few tinify examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Croc-ye / tinyhere / libs / util.js View on Github external
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
github CatchZeng / AppThinning / src / util / tinyPng / index.js View on Github external
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.")
    })

tinify

Node.js client for the Tinify API. Tinify compresses your images intelligently. Read more at https://tinify.com.

MIT
Latest version published 2 years ago

Package Health Score

50 / 100
Full package analysis