fast-counter
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

fast-counter

Fast Multi-Dimensional Counter of Array Values for JavaScript

install

npm install fast-counter

usage

simple array of numbers

const count = require("fast-counter");
const nums = [0, 2, 2, 5, 6, 2];
const counts = count(nums);
// { 0: 1, 2: 3, 5: 1, 6: 1 }

table of values

const count = require("fast-counter");
const nums = [
    [0, 1, 2],
    [0, 1, 2],
    [0, 1, 2] 
];
const counts = count(nums);
// { 0: 3, 1: 3, 2: 3 }

multi-band interleaved RGB pixels for satellite imagery

const count = require("fast-counter");
const pixels = [
    [255, 0, 123], // first pixel
    [255, 0, 123], // second pixel
    [255, 0, 87], // third pixel
    [82, 13, 94] // fourth pixel
];

// counting RGB pixels
// you can specify the depth to count at
const counts = count(pixels, { depth: 1 });
// counts is { '255,0,123': 2, '255,0,87': 1, '82,13,94': 1 }

Package Sidebar

Install

npm i fast-counter

Weekly Downloads

4

Version

0.1.0

License

CC0-1.0

Unpacked Size

9.96 kB

Total Files

5

Last publish

Collaborators

  • danieljdufour