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

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
24
increased by84.62%
Maintainers
1
Weekly downloads
 
Created
Source

datamap-interface Build Status Coverage Status

A simple interface for a map functioning as a database.

Installation

npm:

$ npm install datamap-interface

Component.js:

$ component install wooorm/datamap-interface

Component.js:

$ bower install datamap-interface

Usage

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

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

animals.get('human'); // 'mammal'
animals.get('unicorn'); // null

animals.add('unicorn', 'mammal');
animals.get('unicorn'); // 'mammal'

animals.remove('unicorn');
animals.has('unicorn'); // false

API

DatamapInterface(values)

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

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

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

The following functions are available on the instance:

DatamapInterface#has(key)

animals.has('unicorn'); // true
animals.has('rainbow'); // false

Returns whether (true) or not (false) a key is in the map.

DatamapInterface#get(key)

animals.get('unicorn'); // 'mystical creature'
animals.get('rainbow'); // null

Gets the value for key in map, or null.

DatamapInterface#add(key, value)

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

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

Either adds the key/value pair to the map, or every key/value pair in the first argument.

DatamapInterface#remove(keys)

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

Removes keys or every key in keys.

Given values are NOT validated; no error is thrown when non-existent values are removed.

DatamapInterface#all()

animals.all();
/* {
 *    'shark' : 'fish',
 *    'tuna' : 'fish',
 *    'colugo' : 'mammal',
 *    'unicorn' : 'mystical creature'
 * }
 */

Return the values (as an Object) in the internal database.

License

MIT © Titus Wormer

Keywords

FAQs

Package last updated on 24 Sep 2014

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