h2non/apitance

View on GitHub
lib/store.js

Summary

Maintainability
A
0 mins
Test Coverage
const _ = require('lodash')

module.exports = Store

function Store() {
  this.init()
}

Store.prototype.set = function (key, value) {
  this.buf[key] = value
}

Store.prototype.remove = function (key) {
  this.buf[key] = undefined
}

Store.prototype.get = function (key) {
  return this.buf[key]
}

Store.prototype.all = function () {
  return _.cloneDeep(this.buf)
}

Store.prototype.has = function (key) {
  return this.buf[key] && this.buf[key] !== undefined
}

Store.prototype.init =
Store.prototype.flush = function () {
  this.buf = Object.create(null)
}