New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@hart/modmap

Package Overview
Dependencies
Maintainers
9
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hart/modmap

modmap: easy access key/value store with tags

  • 0.1.4
  • latest
  • npm
  • Socket score

Version published
Maintainers
9
Created
Source

modmap

Travis npm package Coveralls

Install

npm install @hart/modmap

Usage

exported functions

import { set, get, all, byTag, getTags, unset, clear } from '@hart/modmap';

//default import is 'get'
import get from '@hart/modmap';

set - Set value with a key

const value = { ... };

set('key', value);

set - Set value with a key and tag(s)

const value = { ... };

set('key', value, 'tag1', 'tag2', 'tag3');

get - Get value by key

set('key1', { ... });

const value = get('key'); // { ... }
const noValue = get('badKey'); // null

all - Get all key/values

set('key1', { ... });
set('key2', { ... });

const allKeyValues = all(); // { key1: {}, key2: {} }

byTag - Get key/values by tag

set('key1', { ... }, 'tag1');
set('key2', { ... }, 'tag1', 'tag2');

const tag1Values = byTag('tag1'); // { key1: {}, key2: {} }
const tag2Values = byTag('tag2'); // { key2: {} }
const tag3Values = byTag('tag3'); // { }

getTags - Get all tags

set('key1', { ... }, 'tag1');
set('key2', { ... }, 'tag1', 'tag2');

const tags = getTags(); // [ "tag1", "tag2" ]

unset - Remove a key/value

set('key1', { ... }, 'tag1');
set('key2', { ... }, 'tag1');

unset('key1');

const value = get('key1'); // null
const valuesByTag = byTag('tag1'); // { key2: {} }

clear - Remove all key/values and clears all tags

set('key1', { ... }, 'tag1');
set('key2', { ... }, 'tag1', 'tag2');

clear();

const value = get('key1'); // null
const allKeyValues = all(); // { }
const allTags = getTags(); // [ ]

Author

Keywords

FAQs

Package last updated on 20 Jul 2018

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