Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

electrum-store

Package Overview
Dependencies
Maintainers
3
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 3.3.2 to 3.4.0

10

lib/store/state.js

@@ -71,7 +71,7 @@ 'use strict';

} else {
Object.freeze(values);
for (let key of Object.getOwnPropertyNames(values)) {
State.freezeTop(values[key]);
Object.freeze(values);
for (let key of Object.getOwnPropertyNames(values)) {
State.freezeTop(values[key]);
}
}
}

@@ -260,3 +260,3 @@ this._id = id;

value: function createRootState(store, values) {
let initialGeneration = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
let initialGeneration = arguments.length <= 2 || arguments[2] === undefined ? 0 : arguments[2];

@@ -263,0 +263,0 @@ return new State(secretKey, '', store, initialGeneration, values || emptyValues);

@@ -56,2 +56,12 @@ 'use strict';

function getNumber(x) {
if (x.startsWith('[') && x.endsWith(']')) {
const num = (0, _electrumUtils.parsePositiveInt)(x.substr(1, x.length - 2));
return { value: num, raw: x };
} else {
const num = (0, _electrumUtils.parsePositiveInt)(x);
return { value: num, raw: num };
}
}
const secretKey = {};

@@ -126,6 +136,6 @@

value: function getIndexKeys(startId) {
const nums = this.getIds(startId).map(id => (0, _electrumUtils.parsePositiveInt)(_state2.default.getLeafId(id))).filter(num => !isNaN(num));
const nums = this.getIds(startId).map(id => getNumber(_state2.default.getLeafId(id))).filter(num => !isNaN(num.value));
// Numeric sort required here
nums.sort((a, b) => a - b);
return nums;
nums.sort((a, b) => a.value - b.value);
return nums.map(num => num.raw);
}

@@ -194,3 +204,3 @@ }, {

value: function applyChanges(id, obj) {
let defaultKey = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
let defaultKey = arguments.length <= 2 || arguments[2] === undefined ? '' : arguments[2];

@@ -197,0 +207,0 @@ if (typeof obj === 'undefined') {

{
"name": "electrum-store",
"version": "3.3.2",
"version": "3.4.0",
"description": "Electrum store provides a store implementation tailored for Electrum.",

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

@@ -307,2 +307,5 @@ # Electrum Store

> Note: `indexKeys` also supports keys such as `[2]` and `[10]`, which will
> also be sorted based on the integer value (`['[2]', '[10]']`).
The state can also be used as a starting point for `find()` and `select()`.

@@ -309,0 +312,0 @@ Without any argument, they return the state itself.

@@ -297,2 +297,13 @@ 'use strict';

it ('returns sorted index keys, [n] notationt', () => {
const store = Store.create ();
store.select ('a.[1]');
store.select ('a.[10]');
store.select ('a.[2]');
store.select ('a.b.c');
const state = store.find ('a');
const arr = state.indexKeys;
expect (arr).to.deep.equal (['[1]', '[2]', '[10]']);
});
it ('returns an empty array for an empty state', () => {

@@ -299,0 +310,0 @@ const store = Store.create ();

@@ -10,3 +10,3 @@ 'use strict';

const store = Store.create ('x');
store.select ('a.1');
store.select ('a.[1]');
store.select ('a.z');

@@ -22,3 +22,3 @@ store.select ('a.10');

expect (arr).to.have.length (5);
expect (arr).to.deep.equal (['a.1', 'a.z', 'a.10', 'a.2', 'a.0']);
expect (arr).to.deep.equal (['a.[1]', 'a.z', 'a.10', 'a.2', 'a.0']);
});

@@ -43,3 +43,3 @@

expect (arr).to.have.length (4);
expect (arr).to.deep.equal ([0, 1, 2, 10]);
expect (arr).to.deep.equal ([0, '[1]', 2, 10]);
});

@@ -52,5 +52,5 @@ });

expect (arr).to.have.length (4);
expect (arr).to.deep.equal (['a.0', 'a.1', 'a.2', 'a.10']);
expect (arr).to.deep.equal (['a.0', 'a.[1]', 'a.2', 'a.10']);
});
});
});

@@ -47,2 +47,12 @@ 'use strict';

function getNumber (x) {
if (x.startsWith ('[') && x.endsWith (']')) {
const num = parsePositiveInt (x.substr (1, x.length - 2));
return {value: num, raw: x};
} else {
const num = parsePositiveInt (x);
return {value: num, raw: num};
}
}
const secretKey = {};

@@ -110,7 +120,7 @@

const nums = this.getIds (startId)
.map (id => parsePositiveInt (State.getLeafId (id)))
.filter (num => !isNaN (num));
.map (id => getNumber (State.getLeafId (id)))
.filter (num => !isNaN (num.value));
// Numeric sort required here
nums.sort ((a, b) => a - b);
return nums;
nums.sort ((a, b) => a.value - b.value);
return nums.map (num => num.raw);
}

@@ -117,0 +127,0 @@

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