New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

async-canvas-to-blob

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

async-canvas-to-blob

A small wrapper around canvas.toBlob to make async usage cleaner

  • 1.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
326
increased by73.4%
Maintainers
1
Weekly downloads
 
Created
Source

async-canvas-to-blob

A small wrapper around canvas.toBlob to make async usage cleaner

Usage

Let's say you want to save a canvas as a png file. Using the built in canvas syntax you would do something like

import FileSaver from 'file-saver';
...
const canvas = document.getElementById('my-canvas');
canvas.toBlob(blob => {
  FileSaver.saveAs(blob, 'my-canvas.png');
});

Doing this can feel out of place when you use async/await syntax everywhere else to handle promises. Having a callback to handle promise resolution like that is not ideal. Instead we can do something like

import canvasToBlob from 'async-canvas-to-blob';
import FileSaver from 'file-saver';
...
const canvas = document.getElementById('my-canvas');
const blob = await canvasToBlob(canvas);
FileSaver.saveAs(blob, 'my-canvas.png');

FAQs

Package last updated on 04 Feb 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc