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

datamap-interface

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

datamap-interface

Simple interface for a map functioning as a database

  • 2.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
24
increased by60%
Maintainers
1
Weekly downloads
 
Created
Source

datamap-interface

Build Coverage Downloads Size

A basic interface for a map.

Install

This package is ESM only: Node 12+ is needed to use it and it must be imported instead of required.

npm:

npm install datamap-interface

Use

import {DatamapInterface} from 'datamap-interface'

var animals = new DatamapInterface({
  shark: 'fish',
  tuna: 'fish',
  colugo: 'mammal',
  human: 'mammal'
})

animals.get('human') // => 'mammal'
animals.get('unicorn') // => null

animals.add('unicorn', 'mammal').get('unicorn') // => 'mammal'

animals.remove('unicorn').has('unicorn') // => false

API

This package exports the following identifiers: DatamapInterface. There is no default export.

DatamapInterface(values)

DatamapInterface is a constructor, which can be passed an object.

import {DatamapInterface} from 'datamap-interface'

var animals = new DatamapInterface({
  unicorn: 'mystical creature',
  shark: 'fish',
  tuna: 'fish',
  colugo: 'mammal',
  human: 'mammal'
})

DatamapInterface([values])

Create a new instance. Values are passed to #add().

Example
import {DatamapInterface} from 'datamap-interface'

var animals = new DatamapInterface({
  unicorn: 'mystical creature',
  shark: 'fish',
  tuna: 'fish',
  colugo: 'mammal',
  human: 'mammal'
})

DatamapInterface#has(value)

DatamapInterface#is(value)

Check if value is in the map.

Example
animals.has('unicorn') // => true
animals.has('rainbow') // => false

DatamapInterface#get(key)

Get the value of key, or null.

Example
animals.get('unicorn') // => 'mystical creature'
animals.get('rainbow') // => null

DatamapInterface#add(values)

Add each value, or one pair.

Example
animals.add('giant grouper', 'fish')

animals.add({dragon: 'mystical creature'})

DatamapInterface#remove([values])

Remove each value.

Example
animals.remove(['giant grouper', 'human'])
animals.remove('dragon')

DatamapInterface#keys()

Get each key in the map.

Example
animals.keys() // => ['shark', 'tuna', 'colugo', 'unicorn']

DatamapInterface#all()

DatamapInterface#valueOf()

DatamapInterface#toJSON()

Return the list as an Object.

Example
animals.all()

Yields:

{
  shark: 'fish',
  tuna: 'fish',
  colugo: 'mammal',
  unicorn: 'mystical creature'
}
  • datalist-interface — Basic interface for a list functioning as a database

License

MIT © Titus Wormer

Keywords

FAQs

Package last updated on 11 Mar 2021

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