Socket
Book a DemoInstallSign in
Socket

data-uri

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

data-uri

Create data uris of anything from anywhere.

latest
Source
npmnpm
Version
0.0.3
Version published
Maintainers
1
Created
Source

Data-URI

Convert files (locally and via http/https) into data uris with ease.

Installing

npm install data-uri

Usage

Explore demo/demo.js for more examples.

data_uri.encode("buy_a_bonsai.jpg", function(results){
	console.log(results);
});

Result:

{
	buy_a_bonsai.jpg: {
		status: "SUCCESS",
		dataUri: "data:SOMELONGDATASTRING",
		err: null,
		statusCode: 200,
		res: { RESPOSE OBJECT }
	}
}

API

encode(paths, callback, [startPos, endPos, results])

Creates data-uris for a file path or an array of files paths.

  • paths: a string file path or an array of string file paths.
  • callback: a function with a single parameter which will be passed a results object.
  • startPos: Which index in the array of paths to start encoding at. Defaults to 0.
  • endPos: Which index in the array of paths to stop decoding before. Defaults to paths.length;
  • results: the results object to return, minus any changes to the results object made by encode. Defaults to {};

render(content, meme-type)

Returns the content encoded as a data-uri of meme-type

Change Log

0.0.1

  • Added encode endpoint.

0.0.2

  • simply bug fix

0.0.3

  • added in render endpoint

Keywords

data-uri

FAQs

Package last updated on 29 Mar 2013

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