Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

extra-map

Package Overview
Dependencies
Maintainers
1
Versions
308
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

extra-map

A map is a collection of key-value pairs, with unique keys.

  • 3.0.62
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
18
Maintainers
1
Weekly downloads
 
Created
Source

A map is a collection of key-value pairs, with unique keys.
:package: NPM, :smiley_cat: GitHub, :running: RunKit, :vhs: Asciinema, :moon: Minified, :scroll: Files, :newspaper: JSDoc, :blue_book: Wiki.

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

Package last updated on 05 Dec 2022

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc