How to use the valid-data-url function in valid-data-url

To help you get started, we’ve selected a few valid-data-url 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 roast-cms / french-press-editor / src / utils / actions-image.js View on Github external
return new Promise((resolve, reject) => {
    if (file instanceof Blob) {
      const reader = new FileReader();
      reader.readAsDataURL(file);
      reader.addEventListener("load", () => {
        resolve(reader.result);
      });
      reader.addEventListener("error", error => {
        reject(error);
      });
    } else if (isDataString(file)) {
      resolve(file);
    } else
      reject({
        error: "TypeError: parameter must be a File/blob or a data-uri string."
      });
  });
};

valid-data-url

Detect if a string is a data URL

MIT
Latest version published 9 months ago

Package Health Score

66 / 100
Full package analysis

Popular valid-data-url functions