import { find_repeated } from "https://deno.land/x/jssm@5.99.0/jssm_util.d.ts";
Lists all repeated items in an array along with their counts. Subject to
matching rules of Map. NaN
is manually removed because of conflict rules
around unique. Because these are compared with ===
and because
arrays and objects never match that way unless they're the same object,
arrays and objects are never considered repeats.
find_repeated<string>([ ]); // []
find_repeated<string>([ "one" ]); // []
find_repeated<string>([ "one", "two" ]); // []
find_repeated<string>([ "one", "one" ]); // [ ["one", 2] ]
find_repeated<string>([ "one", "two", "one" ]); // [ ["one", 2] ]
find_repeated<number>([ 0, NaN, 0, NaN ]); // [ [0, 2] ]
Parameters
arr: T[]