Skip to content

Commit

Permalink
Extend API with has method
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacek Pietal committed Sep 21, 2019
1 parent 3421d5d commit 3019639
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ if (a !== b) {
methods

* getKey(...args) - creates string key from args
* has(...args) - check if has entry at key created from args
* get(...args) - get entry at key created from args, lazy instantiated by factory
* del(...args) - deletes entry from data at key created from args
* each(callback: Function) - performs callback on each entry in data
Expand Down
6 changes: 6 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ module.exports = class LaterMom {
return args.length > 1 ? args.join(',') : args[0]
}

// has entry at [args]
has(...args) {
const key = this.getKey(...args)
return this.data.has(key)
}

// get entry at [args]
get(...args) {
const key = this.getKey(...args)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "latermom",
"version": "1.0.2",
"version": "1.0.3",
"description": "Later Mom is a lazy es6 DataStructures factory also known as cache",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 3019639

Please sign in to comment.