highest-averages
Version:
Zero-dependency and extensible set of highest averages methods for allocating seats in a parliament. ### Install ```shell npm i highest-averages ``` ### Pure Example - Define the candidates with their vote ```typescript const a = new Candidate('A', 200) c
25 lines (24 loc) • 843 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const pair_1 = require("../utilities/pair");
Map.prototype.getOrElse = function getOrElse(key, item) {
return this.get(key) ?? item;
};
Map.prototype.mappableKeys = function mappableKeys() {
return Array.from(this.keys());
};
Map.prototype.mappableValues = function mappableValues() {
return Array.from(this.values());
};
Map.prototype.mappableEntries = function mappableEntries() {
return Array.from(this.entries()).map(entry => new pair_1.Pair(entry[0], entry[1]));
};
Map.prototype.mapKeys = function mapKeys(f) {
return this.mappableKeys().map(f);
};
Map.prototype.mapValues = function mapValues(f) {
return this.mappableValues().map(f);
};
Map.prototype.mapEntries = function mapEntries(f) {
return this.mappableEntries().map(f);
};