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 🙏

© 2026 – Pkg Stats / Ryan Hefner

whichever-data

v1.1.0

Published

An ES module with some functions making it easier to accept a wide range of binary-data holding objects like Array, TypedArray, DataView, ArrayBuffer and Node.js's Buffer as input without having to actually know which of them were used as the input.

Readme

whichever-data

Description

An ES module with some functions making it easier to accept a wide range of binary-data holding objects like Array, TypedArray, DataView, ArrayBuffer and Node.js's Buffer as input without having to actually know which of them were used as the input.

Example

import {dataToTypedArray} from 'whichever-data'

function giveMeAnyData(data) {
  const uint32array = dataToTypedArray(data, Uint32Array)
  // do something amazing here
}

Supported platforms

How to use

Install using NPM

npm i whichever-data

Import the ES module into Node.js

import {
  dataToArrayBuffer,
  dataToTypedArray,
  dataToDataView,
  compareData
} from 'whichever-data'

Got problems using ES modules? Click here or read this.

Import the ES module into the browser or Deno

import {
  dataToArrayBuffer,
  dataToTypedArray,
  dataToDataView,
  compareData
} from '/node_modules/whichever-data/source/whicheverData.js'

Cumbersome? Consider using import maps so you can import it just like in Node.js. Also see the Deno specific documentation for import maps if using Deno.

Funding

If you find this useful then please consider helping me out (I'm jobless and sick). For more information visit my GitHub sponsors page, my profile or my simple website.

Auto-generated API documentation (from JSDoc)

whichever-data

An ES module with some functions making it easier to accept a wide range of binary-data holding objects like Array, TypedArray, DataView, ArrayBuffer and Node.js's Buffer as input without having to actually know which of them were used as the input.

whichever.dataToArrayBuffer(data) ⇒ ArrayBuffer

Copies the viewed part of the underlying ArrayBuffer from the supplied object (e.g. DataView, TypedArray or Node.js Buffer). Or if supplied an array it treats it like unsigned bytes and creates the ArrayBuffer from it. If supplied an ArrayBuffer it creates a copy of it.

Kind: static method of whichever-data
Returns: ArrayBuffer - A new ArrayBuffer.
Params

  • data ArrayBuffer | ArrayBufferView | Buffer | Array.<number>

whichever.dataToTypedArray(data, TypedArray) ⇒ TypedArray

Creates a TypedArray of the chosen type from an Array, another TypedArray, DataView, ArrayBuffer or Node.js Buffer. When not created from an Array it doesn't copy any data, instead it will create a view into the underlying ArrayBuffer (hence changes in the viewed data will also affect the content of this TypedArray).

Kind: static method of whichever-data
Returns: TypedArray - A new TypedArray.
Params

  • data ArrayBuffer | ArrayBufferView | Buffer | Array.<number>
  • TypedArray TypedArray - The TypedArray constructor to use, e.g. Uint8Array.

whichever.dataToDataView(data) ⇒ DataView

Creates a DataView from a TypedArray, DataView, ArrayBuffer, Node.js Buffer or an Array (of unsigned bytes). When not created from an Array it doesn't copy any data, instead it will create a view into the underlying ArrayBuffer (hence changes in the viewed data will also affect the content of this DataView).

Kind: static method of whichever-data
Returns: DataView - A new DataView.
Params

  • data ArrayBuffer | ArrayBufferView | Buffer | Array.<number>

whichever.compareData(a, b) ⇒ Boolean

Checks if the data given to it is the same binary data. Accepts Array, TypedArray, DataView, ArrayBuffer or Node.js Buffer as input. If comparing two Arrays then normal array comparison is done, but if comparing one Array against data of another type then the array is treated as an array of unsigned bytes.

Kind: static method of whichever-data
Returns: Boolean - true or false
Params

  • a ArrayBuffer | ArrayBufferView | Buffer | Array.<number>
  • b ArrayBuffer | ArrayBufferView | Buffer | Array.<number>

The bottom

You reached the bottom, good. Most people just skim the top... But I guess that you have an attention to detail and a higher intelligence than the average person. I like you! 😃

To get back up click here or find your own way.