electrum-store
Advanced tools
Comparing version 3.2.0 to 3.3.0
'use strict'; | ||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
@@ -95,2 +97,7 @@ | ||
}, { | ||
key: 'getPojo', | ||
value: function getPojo() { | ||
return _extends({}, this._values); | ||
} | ||
}, { | ||
key: 'getInherited', | ||
@@ -97,0 +104,0 @@ value: function getInherited(id) { |
{ | ||
"name": "electrum-store", | ||
"version": "3.2.0", | ||
"version": "3.3.0", | ||
"description": "Electrum store provides a store implementation tailored for Electrum.", | ||
@@ -25,9 +25,9 @@ "main": "lib/index.js", | ||
"devDependencies": { | ||
"babel-env": "^1.3.0", | ||
"babel-env": "^1.3.1", | ||
"generic-js-env": "^1.6.1", | ||
"mai-chai": "^2.6.0", | ||
"react": "^15.1.0", | ||
"react": "^15.3.2", | ||
"require-self": "^0.1.0", | ||
"rimraf": "^2.5.2" | ||
"rimraf": "^2.5.4" | ||
} | ||
} |
@@ -284,2 +284,4 @@ # Electrum Store | ||
* `contains (name)` → `true` if a value exists for `name`, otherwise `false`. | ||
* `getPojo ()` → the values as a plain old JavaScript object (POJO); the | ||
object is a copy of the internal state values. | ||
@@ -286,0 +288,0 @@ ## States as arrays |
@@ -26,2 +26,18 @@ 'use strict'; | ||
describe ('getPojo()', () => { | ||
it ('returns a copy of the state values', () => { | ||
const state = State.create ('a', {x: 'X', y: 'Y'}); | ||
const pojo = state.getPojo (); | ||
expect (pojo).to.have.property ('x', 'X'); | ||
expect (pojo).to.have.property ('y', 'Y'); | ||
}); | ||
it ('returns a mutable object', () => { | ||
const state = State.create ('a', {x: 'X', y: 'Y'}); | ||
const pojo = state.getPojo (); | ||
pojo.x = 'foo'; | ||
expect (pojo).to.have.property ('x', 'foo'); | ||
}); | ||
}); | ||
describe ('contains()', () => { | ||
@@ -28,0 +44,0 @@ it ('returns true for existing id', () => { |
@@ -115,2 +115,6 @@ 'use strict'; | ||
getPojo () { | ||
return {...this._values}; | ||
} | ||
getInherited (id) { | ||
@@ -117,0 +121,0 @@ const value = this.get (id); |
116519
2566
462