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

  • 1.0.1
  • Source
  • npm
  • Socket score

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

datamap-interface Build Status Coverage Status

A simple interface for a map.

Installation

npm:

npm install datamap-interface

Usage

var DatamapInterface = require('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

DatamapInterface(values)

datamap-interface exports a constructor, which can be passed an object.

var DatamapInterface = require('datamap-interface');

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

API

datamapInterface([values])

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

Example
var DatamapInterface = require('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 — Simple interface for a list functioning as a database

License

MIT © Titus Wormer

Keywords

FAQs

Package last updated on 09 Jul 2017

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