electrum-store
Advanced tools
Comparing version 2.1.0 to 2.2.0
@@ -201,4 +201,7 @@ 'use strict'; | ||
const value = obj[key]; | ||
this.select(id).set(key, value); | ||
this.applyCollection(_state2.default.join(id, key), value, defaultKey); | ||
if (key === defaultKey) { | ||
this.select(id).set(key, value); | ||
} else { | ||
this.applyCollection(_state2.default.join(id, key), value, defaultKey); | ||
} | ||
}); | ||
@@ -205,0 +208,0 @@ } else { |
{ | ||
"name": "electrum-store", | ||
"version": "2.1.0", | ||
"version": "2.2.0", | ||
"description": "Electrum store provides a store implementation tailored for Electrum.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -48,2 +48,14 @@ 'use strict'; | ||
it ('treats value named with default key as an entry value', () => { | ||
const store = Store.create (); | ||
const data = {a: {x: 'X'}, b: {value: 'Y'}}; | ||
store.applyCollection ('root', data, 'value'); // defaultKey is 'value' | ||
expect (store.find ('root.a').get ('x')).to.be.undefined (); | ||
expect (store.find ('root.a.x').get ('value')).to.equal ('X'); | ||
expect (store.find ('root.b').get ('value')).to.equal ('Y'); | ||
expect (store.find ('root.b.value')).to.not.exist (); | ||
}); | ||
it ('accepts empty values', () => { | ||
@@ -70,3 +82,19 @@ const store = Store.create (); | ||
}); | ||
it ('example from README works', () => { | ||
const store = Store.create (); | ||
const array = [ | ||
{offset: 10, id: 'x', value: {year: 2016, name: 'foo'}}, // children year and name | ||
{offset: 12, id: 'y', value: {year: 1984, name: 'bar'}}, // children year and name | ||
{offset: 13, id: 'z', value: 'none'} // no children, plain value only | ||
]; | ||
store.applyCollection ('root', array); | ||
expect (store.select ('root.10.year').get ()).to.equal (2016); | ||
expect (store.select ('root.12.name').get ()).to.equal ('bar'); | ||
expect (store.select ('root.10').get ('value')).to.deep.equal ({year: 2016, name: 'foo'}); | ||
expect (store.select ('root.13').get ('value')).to.equal ('none'); | ||
}); | ||
}); | ||
}); |
@@ -188,6 +188,9 @@ 'use strict'; | ||
const value = obj[key]; | ||
this | ||
.select (id) | ||
.set (key, value); | ||
this.applyCollection (State.join (id, key), value, defaultKey); | ||
if (key === defaultKey) { | ||
this | ||
.select (id) | ||
.set (key, value); | ||
} else { | ||
this.applyCollection (State.join (id, key), value, defaultKey); | ||
} | ||
}); | ||
@@ -194,0 +197,0 @@ } else { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
103070
2322