npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

preview-utils

v1.0.3

Published

a preview utils for web

Downloads

9

Readme

preview-utils

web client preview utils

install

npm i preview-utils

base64 utils

parseBase64

const {content,contentType} = parseBase64(base64)

return base64 contentType and content

fileToBase64

const base64 =await  fileToBase64(file)

convert a file object to base64,this is a promise

imageToBase64

const base64 = imageToBase64(image)
// args (image, type = 'image/png', quality = .8)

convert a html image object to base64 ,use canvas,this is a sync function

imageToBlob

const file = imageToFile(image)

convert a html image object to blob

imageToFile

const blob = imageToBlob(image,"file.png")
//args (image, fileName, { lastModified = Date.now() } = {})

convert a html image object to File

imageUrlToBase64

const base64 = await imageUrlToBase64(url)

use a image url (the url allow cross domain ) from remote ,convert to base64

blobToFile

const file =  blobToFile(blob)
//args  (blob, fileName, { contentType, lastModified = Date.now() } = {}) 

convert a blob to File

base64ToBlob

const blob =  base64ToBlob(base64)

convert a base64 to Blob

base64ToFile

const file =  base64ToFile(base64,"file.txt")
//args (base64, fileName, { contentType, lastModified = Date.now() } = {}) 

convert a base64 to File

urlToBlob

const blob = await urlToBlob(url)
 

fetch a remote url as Blob

urlToFile

const file = await urlToFile(url,"image.png")
//args  (url, fileName, { contentType, lastModified = Date.now() } = {})

fetch a remote url as File

createThumb

const thumbBase64 = await createThumb(url,100,100)
//args   (file, width, height, { timeout = 2048, currentTime = 1, type = "image/png", quality = .8,toBlog=false } = {})
//file type:File,Image,HTMLVideoElement

create File | Image | Video 's thumb base64,

creatPreviewUrl

const url = await creatPreviewUrl(file)
//args  (file, timeout = 2048) 

use URL.createObjectURL(file) to create url,and use settimeout to revokeObjectURL