Socket
Socket
Sign inDemoInstall

extra-map

Package Overview
Dependencies
0
Maintainers
1
Versions
307
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    extra-map

A group of functions for working with Maps.


Version published
Weekly downloads
35
increased by66.67%
Maintainers
1
Install size
74.0 kB
Created
Weekly downloads
Ā 

Readme

Source

A group of functions for working with Maps.
šŸ“¦ Node.js, šŸŒ Web, šŸ“œ Files, šŸ“° Docs, šŸ“˜ Wiki.

A map is a collection of key-value pairs, with unique keys. All functions except from*() take Map as 1st parameter. Some names are borrowed from Haskell, Python, Java, Processing.

Methods look like:

  • swap(): doesn't modify the map itself (pure).
  • swap$(): modifies the map itself (update).

Methods as separate packages:

Stability: Experimental.


const map = require('extra-map');
// import * as map from "extra-map";
// import * as map from "https://unpkg.com/extra-map@2.1.0/index.mjs"; (deno)

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

var x = new Map([["a", 1], ["b", 2], ["c", 3], ["d", 4]]);
var y = new Map([["b", 20], ["c", 30], ["e", 50]]);
map.intersection(x, y);
// Map(2) { "b" => 2, "c" => 3 }

var x = new Map([["a", 1], ["b", 2], ["c", 3], ["d", -2]]);
map.searchAll(x, v => Math.abs(v) === 2);
// [ "b", "d" ]              ^                   ^

var x = new Map([["a", 1], ["b", 2], ["c", 3]]);
[...map.subsets(x)];
// [
//   Map(0) {},
//   Map(1) { "a" => 1 },
//   Map(1) { "b" => 2 },
//   Map(2) { "a" => 1, "b" => 2 },
//   Map(1) { "c" => 3 },
//   Map(2) { "a" => 1, "c" => 3 },
//   Map(2) { "b" => 2, "c" => 3 },
//   Map(3) { "a" => 1, "b" => 2, "c" => 3 }
// ]


Index

MethodAction
isChecks if value is map.
getGets value at key.
setSets value at key.
removeDeletes an entry.
swapExchanges two values.
sizeGets size of map.
headGets first entry.
takeKeeps first n entries only.
shiftRemoves first entry.
fromCreates map from entries.
concatAppends entries from maps, preferring last.
flatFlattens nested map to given depth.
chunkBreaks map into chunks of given size.
filterAtGets map with given keys.
mapUpdates values based on map function.
filterKeeps entries which pass a test.
reduceReduces values to a single value.
rangeFinds smallest and largest entries.
countCounts values which satisfy a test.
partitionSegregates values by test result.
cartesianProductLists cartesian product of maps.
someChecks if any value satisfies a test.
zipCombines matching entries from maps.
unionGives entries present in any map.
intersectionGives entries present in both maps.
differenceGives entries of map not present in another.
symmetricDifferenceGives entries not present in both maps.
isDisjointChecks if maps have no common keys.
keyPicks an arbitrary key.
valuePicks an arbitrary value.
entryPicks an arbitrary entry.
subsetPicks an arbitrary subset.
isEmptyChecks if map is empty.
isEqualChecks if two maps are equal.
compareCompares two maps.
findFinds a value passing a test.
searchFinds key of an entry passing a test.
scanWhileFinds key of first entry not passing a test.


Keywords

FAQs

Last updated on 05 Dec 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with āš”ļø by Socket Inc