Skip to content

Latest commit

 

History

History
45 lines (39 loc) · 941 Bytes

README.md

File metadata and controls

45 lines (39 loc) · 941 Bytes

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 }