Skip to content

Fast Multi-Dimensional Counter of Array Values for JavaScript

License

Notifications You must be signed in to change notification settings

DanielJDufour/fast-counter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 }

About

Fast Multi-Dimensional Counter of Array Values for JavaScript

Resources

License

Stars

Watchers

Forks

Packages

No packages published