🚀 Big News:Socket Has Acquired Secure Annex.Learn More →
Socket
Book a DemoSign in
Socket

toDataURL

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

toDataURL

Download something in the browser as a file

latest
Source
npmnpm
Version
0.1.1
Version published
Maintainers
1
Created
Source

Intro

toDataURL takes whatever you give it (assuming it's supported) and turns it into something you can download.

Supported inputs are:

  • string- uses built-in btoa function
  • Array- takes Array of numbers and assumes they're bytes (converts to Uint8Array internally)
  • Uint8Array- uses a home-grown base64 conversion function

toDataURL works with pakmanager and probably any other CommonJS compliant browser package builders.

Exported Methods

  • toDataURL- takes up to three arguments
    • data- one of the supported formats listed above
    • mimeType- optional; application/octet-stream is the default
    • download- optional; defaults to false; this will automagically download the data if true
  • openDataURL- takes up to two arguments
    • data- the dataURL output from toDataURL
    • name- name of the window to open it in (defaults to _self)

Keywords

dataURL

FAQs

Package last updated on 21 Nov 2011

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