datamap-interface
Advanced tools
Comparing version 0.0.1 to 0.1.0
{ | ||
"name": "datamap-interface", | ||
"version": "0.0.1", | ||
"version": "0.1.0", | ||
"description": "Simple interface for a map functioning as a database", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
{ | ||
"name": "datamap-interface", | ||
"version": "0.0.1", | ||
"version": "0.1.0", | ||
"description": "Simple interface for a map functioning as a database", | ||
@@ -13,6 +13,6 @@ "license": "MIT", | ||
"devDependencies": { | ||
"eslint": "^0.7.4", | ||
"eslint": "^0.8.0", | ||
"istanbul": "^0.3.0", | ||
"jscs": "^1.5.3", | ||
"mocha": "^1.20.4" | ||
"jscs": "^1.5.0", | ||
"mocha": "^1.20.0" | ||
}, | ||
@@ -19,0 +19,0 @@ "repository": { |
@@ -26,33 +26,19 @@ # datamap-interface [![Build Status](https://travis-ci.org/wooorm/datamap-interface.svg?branch=master)](https://travis-ci.org/wooorm/datamap-interface) [![Coverage Status](https://img.shields.io/coveralls/wooorm/datamap-interface.svg)](https://coveralls.io/r/wooorm/datamap-interface?branch=master) | ||
var DatamapInterface = require('datamap-interface'), | ||
mammals; | ||
animals; | ||
mammals = new DatamapInterface([ | ||
'common vampire bat', | ||
'virginia opossum', | ||
'eastern grey kangaroo', | ||
'tasmanian devil', | ||
'human', | ||
'northern elephant seal', | ||
'fox squirrel', | ||
'tree pangolin', | ||
'african elephant', | ||
'platypus', | ||
'colugo', | ||
'reindeer', | ||
'humpback whale', | ||
'star-nosed mole', | ||
'giant panda', | ||
'giant armadillo', | ||
'plains zebra', | ||
'black and rufous elephant shrew' | ||
]); | ||
animals = new DatamapInterface({ | ||
'shark' : 'fish', | ||
'tuna' : 'fish', | ||
'colugo' : 'mammal', | ||
'human' : 'mammal' | ||
}); | ||
mammals.is('human'); // true | ||
mammals.is('unicorn'); // false | ||
animals.get('human'); // 'mammal' | ||
animals.get('unicorn'); // null | ||
mammals.add('unicorn'); | ||
mammals.is('unicorn'); // true | ||
animals.add('unicorn', 'mammal'); | ||
animals.get('unicorn'); // 'mammal' | ||
mammals.remove('unicorn'); | ||
mammals.is('unicorn'); // false | ||
animals.remove('unicorn'); | ||
animals.has('unicorn'); // false | ||
``` | ||
@@ -64,3 +50,3 @@ | ||
**datamap-interface** exports a constructor, which can be passed an array. | ||
**datamap-interface** exports a constructor, which can be passed an object. | ||
@@ -71,3 +57,9 @@ ```js | ||
fish = new DatamapInterface(['shark', 'tuna']); | ||
animals = new DatamapInterface({ | ||
'unicorn' : 'mystical creature', | ||
'shark' : 'fish', | ||
'tuna' : 'fish', | ||
'colugo' : 'mammal', | ||
'human' : 'mammal' | ||
}); | ||
``` | ||
@@ -77,27 +69,41 @@ | ||
### DatamapInterface#is(word) | ||
### DatamapInterface#has(key) | ||
```js | ||
fish.is('shark'); // true | ||
fish.is('human'); // false | ||
animals.has('unicorn'); // true | ||
animals.has('rainbow'); // false | ||
``` | ||
Returns whether (true) or not (false) a given word is a filler word. | ||
Returns whether (`true`) or not (`false`) a `key` is in the map. | ||
### DatamapInterface#add(word...) | ||
### DatamapInterface#get(key) | ||
```js | ||
fish.add('giant grouper', 'red lionfish'); | ||
animals.get('unicorn'); // 'mystical creature' | ||
animals.get('rainbow'); // null | ||
``` | ||
Adds all arguments to the internal database. | ||
Given values are **NOT** validated. | ||
Gets the value for `key` in map, or `null`. | ||
### DatamapInterface#remove(word...) | ||
### DatamapInterface#add(key, value) | ||
```js | ||
fish.remove('giant grouper', 'reindeer'); | ||
animals.add('giant grouper', 'fish'); | ||
animals.add({ | ||
'dragon' : 'mystical creature' | ||
}); | ||
``` | ||
Removes all arguments from the internal database. | ||
Either adds the key/value pair to the map, or every key/value pair in the first argument. | ||
### DatamapInterface#remove(keys) | ||
```js | ||
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. | ||
@@ -108,6 +114,13 @@ | ||
```js | ||
fish.all(); // ['shark', 'tuna', 'red lionfish'] | ||
animals.all(); | ||
/* { | ||
* 'shark' : 'fish', | ||
* 'tuna' : 'fish', | ||
* 'colugo' : 'mammal', | ||
* 'unicorn' : 'mystical creature' | ||
* } | ||
*/ | ||
``` | ||
Return the values (as an Array) in the internal database. | ||
Return the values (as an Object) in the internal database. | ||
@@ -114,0 +127,0 @@ ## License |
15895
125