Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

data-urls

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

data-urls

Parses data: URLs

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is data-urls?

The data-urls npm package is used to parse and serialize data URLs as per the WHATWG specification. It allows you to work with data URLs in a structured way, extracting components like MIME type, base64 encoding, and the actual data.

What are data-urls's main functionalities?

Parsing Data URLs

This feature allows you to parse a data URL into its components. The `parse` function takes a data URL string and returns an object containing the MIME type, whether it's base64 encoded, and the actual data.

const { parse } = require('data-urls');
const dataUrl = 'data:text/plain;base64,SGVsbG8sIFdvcmxkIQ==';
const parsed = parse(dataUrl);
console.log(parsed);

Serializing Data URLs

This feature allows you to serialize data into a data URL. The `serialize` function takes an object with MIME type and data, and returns a data URL string.

const { serialize } = require('data-urls');
const data = Buffer.from('Hello, World!');
const mimeType = 'text/plain';
const serialized = serialize({ mimeType, body: data });
console.log(serialized);

Other packages similar to data-urls

Keywords

FAQs

Package last updated on 31 Jan 2018

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