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

get-certain

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

get-certain

Assert a Map has a given key and return the value for it.

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

sole-entry

Assert a Map has a given key and return the value for it.

Pretty much just map.get(key), but throws if key isn't there.

Install

$ yarn add get-certain

Usage

const getCertain = require('get-certain');

const map = new Map();

map.set('foo', 1);

// Returns 1.
getCertain(map, 'foo');

// This throws.
getCertain(map, 'bar');

// This throws with a custom message.
getCertain(map, 'bar', 'This map is barless.');

API

getCertain(map, key, [message])

Returns the value from map for key, or throws if it is not there.

map

  • Type: Map

A Map. I hope you know what you're putting in there.

key

  • Type: any

A key that is hopefully in map.

message

  • Type: string

An optional message to throw. Defaults to '"map" does not have an entry for "key".', which isn't terribly descriptive.

License

MIT © Matthew Fernando Garcia

FAQs

Package last updated on 10 Jun 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