Skip to content
Subhajit Sahu edited this page Jun 13, 2020 · 14 revisions

Keeps first n entries only. 🏃 📼 📦 🌔 📒

Alternatives: take, take$.
Similar: take, drop.

map.take$(x, [n]);
// x: a map (updated)
// n: number of entries (1)
// --> x
const map = require('extra-map');

var x = new Map([['a', 1], ['b', 2], ['c', 3], ['d', 4]]);
map.take$(x, 2);
// Map(2) { 'a' => 1, 'b' => 2 }

x;
// Map(2) { 'a' => 1, 'b' => 2 }

var x = new Map([['a', 1], ['b', 2], ['c', 3], ['d', 4]]);
map.take$(x, 3);
// Map(3) { 'a' => 1, 'b' => 2, 'c' => 3 }

references

Clone this wiki locally