1
0
Fork 0
freesewing/packages/core/src/store.js

21 lines
428 B
JavaScript
Raw Normal View History

function Store() {
2019-08-03 15:03:33 +02:00
this.data = new Map()
2018-08-05 16:32:38 +02:00
}
/** Sets a value under index key */
Store.prototype.set = function(key, value) {
2019-08-03 15:03:33 +02:00
this.data.set(key, value)
}
2018-08-05 16:32:38 +02:00
/** Sets a value under index key */
Store.prototype.setIfUnset = function(key, value) {
2019-08-03 15:03:33 +02:00
if (!this.data.has(key)) this.data.set(key, value)
}
2018-08-05 16:32:38 +02:00
/** Gets a value under index key */
Store.prototype.get = function(key) {
2019-08-03 15:03:33 +02:00
return this.data.get(key)
}
2018-08-05 16:32:38 +02:00
2019-08-03 15:03:33 +02:00
export default Store