How to use the tinify.ConnectionError 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 muwoo / tinypng-upload / src / renderer / assets / js / operate.js View on Github external
tinify.fromBuffer(sourceData).toBuffer((err, resultData) => {
        if (err instanceof tinify.AccountError) {
          reject(err)
          return new Notification('compress filed', {
            body: 'Verify your API key and account limit.'
          })
        } else if (err instanceof tinify.ServerError) {
          reject(err)
          return new Notification('compress filed', {
            body: 'Temporary issue with the Tinify API.'
          })
        } else if (err instanceof tinify.ConnectionError) {
          reject(err)
          return new Notification('compress filed', {
            body: 'A network connection error occurred.'
          })
        } else {
          resolve({compressFile: resultData, distSize: parseInt(resultData.length / 1024)})
        }
      })
    })

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