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

choose-typed-array

v0.0.1

Published

Chooses the Best Typed Array to use for an Array of Number. Supports Big Integers!

Downloads

10

Readme

choose-typed-array

Chooses the Best Typed Array to Hold an Array of Numbers. Supports Big Integers!

install

npm install choose-typed-array

usage

The function takes in 4 variables:

  • all_numbers_are_integers: whether all the numbers in the array are integers
  • min: the lowest number in the array
  • max: the highest number in the array
  • max_significant_digits: the largest instance of significant digits found in the array (you don't need to specify this if all the numbers are integers)
const chooseTypedArray = require("choose-typed-array");

// for an array of 1s and 0s like [0, 1, 0, 1, 1, 1, 0]
const TypedArray = chooseTypedArray({
    min: 0,
    max: 1,
    all_numbers_are_integers: true
});
// TypedArray is Uint8Array

// for an array of pixel values like [0, 255, 128, 123, 32, 94]
const TypedArray = chooseTypedArray({
    min: 0,
    max: 255,
    all_numbers_are_integers: true
});
// TypedArray is Uint8Array

// for an array of larger values like [-1273, 1238, -1243, 322, -945]
const TypedArray = chooseTypedArray({
    min: -1273,
    max: 1238,
    all_numbers_are_integers: true
});
// TypedArray is Uint16Array

// for an array of random numbers [0.6133360105966696, 0.9000317453847548, 0.20715335681564762, 0.4200819399746838, ...]
const TypedArray = chooseTypedArray({
    min: -1273,
    max: 1238,
    all_numbers_are_integers: true
    max_significant_digits: 16
});
// TypedArray is Float64Array