New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

hash-set-map

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hash-set-map

Set and Map extension to prove a custom key derivation function

latest
Source
npmnpm
Version
2.0.0
Version published
Weekly downloads
3.3K
-7.54%
Maintainers
1
Weekly downloads
 
Created
Source

NPM version Build Status Coverage Status

hash-set-map

Set and Map extension to prove a custom key derivation function. It also supports JSON serialization and de-serialization

The original Set and Map object are not modified, so can still be used.

This library does not provides polyfills for Set and Map.

Install

npm i hash-set-map

The current version supports node v10+ and modern browsers.

Usage

  • Typescript and es6
import { Set, Map } from 'hash-set-map'
  • Nodejs
var Set = require('hash-set-map').Set;
var Map = require('hash-set-map').Map;

The unmodified Set and Map class can still be used:

import { Set as hSet, Map as hMap } from 'hash-set-map'
let originalMap = new Map()
let originalSet = new Set()
let hashMap = new hMap()
let hashSet = new hSet()

Example

export function dateToKey(d: Date) {
  return d.valueOf();
}
const set = new Set([new Date(1), new Date(1)], dateToKey);
set.size // size is 1
set.has(new Date(1)) // returns true
export function stringIgnoreCase(s: string) {
  return s.toLowerCase();
}
const map = new Map([['a', 1], ['b', 3], ['C', 3]], stringIgnoreCase);
map.get('c') // returns 3
map.set('c', 42);
map.get('C') // returns 42

For further documentation on toJSON and fromJSON methods refer to json-set-map.

Refer to the JSDoc documentation on the files for mode details.

Keywords

Set

FAQs

Package last updated on 09 May 2020

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