New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

electrum-store

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

electrum-store - npm Package Compare versions

Comparing version 1.3.0 to 1.4.0

17

lib/store/state.js

@@ -97,2 +97,14 @@ 'use strict';

}, {
key: 'getInherited',
value: function getInherited(id) {
var value = this.get(id);
if (value !== undefined) {
return value;
}
var parent = this.parentId;
if (parent !== undefined) {
return this.store.find(parent).getInherited(id);
}
}
}, {
key: 'set',

@@ -167,2 +179,7 @@ value: function set() {

}, {
key: 'parentId',
get: function get() {
return State.getParentId(this._id);
}
}, {
key: 'store',

@@ -169,0 +186,0 @@ get: function get() {

2

package.json
{
"name": "electrum-store",
"version": "1.3.0",
"version": "1.4.0",
"description": "Electrum store provides a store implementation tailored for Electrum.",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -106,2 +106,4 @@ # Electrum Store

exists, otherwise `undefined`.
* `getInherited (id)` → the value for `id` if it can be found on the state
or any of its parent nodes, otherwise `undefined`.
* `any (id)` or `any ()` → `true` if the state specified by `id` exists

@@ -111,2 +113,7 @@ and if it is non-empty.

The state can also be used as a staring point for `find()` and `select()`.
Without any argument, they return the state itself.
`select()` creates missing nodes whereas `find()` returns `undefined` if
it does not find the specified nodes.
## Create state

@@ -113,0 +120,0 @@

@@ -58,2 +58,6 @@ 'use strict';

get parentId () {
return State.getParentId (this._id);
}
get store () {

@@ -90,2 +94,13 @@ return this._store;

getInherited (id) {
const value = this.get (id);
if (value !== undefined) {
return value;
}
const parent = this.parentId;
if (parent !== undefined) {
return this.store.find (parent).getInherited (id);
}
}
set (...args) {

@@ -92,0 +107,0 @@ if (args.length === 1) {

@@ -205,2 +205,36 @@ 'use strict';

});
describe ('parentId', () => {
it ('returns the parent id', () => {
const store = Store.create ();
const state = store.select ('a.b.c');
expect (state.parentId).to.equal ('a.b');
expect (store.find ('a').parentId).to.equal ('');
});
it ('returns undefined for the root', () => {
const store = Store.create ();
store.select ('a.b.c');
expect (store.root.parentId).to.not.exist ();
});
});
describe ('getInherited', () => {
const store = Store.create ();
store.select ('a.b.c');
store.select ('a').set ('x', 1);
store.select ('a.b').set ('x', 2);
store.root.set ('y', 3);
store.select ('a').set ('z', 4);
it ('returns the first value found in the tree', () => {
expect (store.find ('a.b.c').getInherited ('x')).to.equal (2);
expect (store.find ('a.b').getInherited ('x')).to.equal (2);
expect (store.find ('a').getInherited ('x')).to.equal (1);
expect (store.root.getInherited ('x')).to.not.exist ();
expect (store.root.getInherited ('y')).to.equal (3);
expect (store.find ('a.b.c').getInherited ('z')).to.equal (4);
expect (store.find ('a.b.c').getInherited ('y')).to.equal (3);
});
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc