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 🙏

© 2025 – Pkg Stats / Ryan Hefner

promisify-file

v5.0.0

Published

Promise File Read.

Readme

Promisify File

Usage

Basic syntax

import PromisifyFile from 'promisify-file'

;(async () => {
  const testFile = new File(
    ['hello from promisify-file.txt'],
    'promisify-file.txt',
    {
      type: 'text/plain',
      lastModified: Date.now()
    }
  )

  const promisifyFile = new PromisifyFile(file)

  try {
    console.log(await promisifyFile.text()) // print `hello from promisify-file.txt`
  } catch (err) {
    console.error(err)
  }
})()

options

{
  name: fileName,
  type: fileMimeType,
  encoding: textFileEncoding,
  quality: imageFileQuality,
  lastModified: fileLastModified
}

constructor

syntax:

let promisifyFile = new PromisifyFile(data, options)

data must be a Blob(include File), for more data type support see PromisifyFile.from

static methods

PromisifyFile.from

returns a Promise that resolves with a PromisifyFile Object

syntax:

let promisifyFile = await PromisifyFile.from(data, options)

supported data types:

methods

PromisifyFile.prototype.{arrayBuffer, text, dataURL, binaryString}

returns a Promise that resolves with the result FileReader.readAs{ArrayBuffer, Text, DataURL, BinaryString}

syntax:

promisifyFile.arrayBuffer()

// optional `encoding` use in `FileReader.readAsText`
promisifyFile.text([encoding])

promisifyFile.dataURL()

promisifyFile.binaryString()

Notice: result of arrayBuffer / text / dataURL / binaryString is cached

PromisifyFile.prototype.{int8Array, uint8Array, uint8ClampedArray, int16Array, uint16Array, int32Array, uint32Array, float32Array, float64Array}

returns a Promise that resolves with a TypedArray created with blob arrayBuffer

optional arguments byteOffset and length same as TypedArray syntax

syntax:

promisifyFile.int8Array([byteOffset [, length]])

promisifyFile.uint8Array([byteOffset [, length]])

promisifyFile.uint8ClampedArray([byteOffset [, length]])

promisifyFile.int16Array([byteOffset [, length]])

promisifyFile.uint16Array([byteOffset [, length]])

promisifyFile.uint32Array([byteOffset [, length]])

promisifyFile.float32Array([byteOffset [, length]])

promisifyFile.float64Array([byteOffset [, length]])

links:

PromisifyFile.prototype.dataView

returns a Promise that resolves with a DataView created with blob arrayBuffer

optional arguments byteOffset and length same as DataView syntax

syntax:

promisifyFile.dataView([byteOffset [, length]])

links:

PromisifyFile.prototype.blob

returns a Promise that resolves with a new Blob created with orignal blob

optional argument options same as Blob syntax

syntax:

promisifyFile.blob([options]])

links:

PromisifyFile.prototype.file

returns a Promise that resolves with a new File created with orignal blob

optional arguments name and options same as File syntax

syntax:

promisifyFile.file([name [, options]])

Notice: if name is omitted, and the orignal Blob don't has a name. a TypeError throws

links:

PromisifyFile.prototype.json

returns a Promise that resolves with the result of parsing blob text as JSON

syntax:

promisifyFile.json([encoding [, reviver]])

links:

PromisifyFile.prototype.url

returns a Promise that resolves with the result of URL.createObjectURL create with blob

syntax:

promisifyFile.url()

links:

PromisifyFile.prototype.image

returns a Promise that resolves with loaded HTMLImageElement create with blob

syntax:

promisifyFile.image()

links:

PromisifyFile.prototype.imageBitmap

returns a Promise that resolves with ImageBitmap that createImageBitmap returns

syntax:

promisifyFile.imageBitmap([options])

promisifyFile.imageBitmap(sx, sy, sw, sh[, options])

links:

PromisifyFile.prototype.imageData

returns a Promise that resolves with ImageData containing the image data of orignal image blob

syntax:

promisifyFile.imageData([sx = 0[, sy = 0[, sw = image.width [, sh = image.height]]]])

links:

PromisifyFile.prototype.{document, xml, svg, html}

returns a Promise that resolves with DOMParser.parseFromString parsing blob text

syntax:

promisifyFile.document([encoding [, overrideMimeType]])
promisifyFile.xml([encoding]) // shortcut for promisifyFile.document(encoding, 'application/xml')
promisifyFile.svg([encoding]) // shortcut for promisifyFile.document(encoding, 'image/svg+xml')
promisifyFile.html([encoding]) // shortcut for promisifyFile.document(encoding, 'text/html')

Notice: Note that if the parsing process fails, the DOMParser does not throw an exception, but PromisifyFile.document throws an Error

links:

relative projects