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

chia-changelist-generator

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chia-changelist-generator - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

44

index.js

@@ -27,3 +27,3 @@ const Datalayer = require("chia-datalayer");

const generateChange = async (storeId, key, value) => {
const generateChange = async (storeId, action, key, value) => {
if (!isValidHexadecimal(key)) {

@@ -39,6 +39,16 @@ throw new Error(`Key ${key} is not a valid hexadecimal string`);

const existingKeys = await datalayer.getKeys({ id: storeId });
if (action === "insert") {
return await generateInsertChange(storeId, existingKeys, key, value);
} else if (action === "delete") {
return await generateDeleteChange(storeId, existingKeys, key);
} else {
throw new Error(`Action ${action} is not supported`);
}
};
const generateInsertChange = async (existingKeys, key, value) => {
const change = [];
const existingKeys = await datalayer.getKeys({ id: storeId });
if (existingKeys.includes(key)) {

@@ -60,3 +70,21 @@ change.push({

const generateChangeList = async (storeId, keyValueArray, options = {}) => {
const generateDeleteChange = async (key) => {
const change = [];
if (existingKeys.includes(key)) {
change.push({
action: "delete",
key: key,
});
}
return change;
};
const generateChangeList = async (
storeId,
action,
keyValueArray,
options = {}
) => {
if (!options.chunkChangeList) {

@@ -69,4 +97,4 @@ options.chunkChangeList = false;

for (const keyValue of keyValueArray) {
const {key, value} = keyValue;
const change = await generateChange(storeId, key, value);
const { key, value } = keyValue;
const change = await generateChange(storeId, action, key, value);
changeList.push(...change);

@@ -85,3 +113,3 @@ }

decodeHex,
generateChangeList
};
generateChangeList,
};

2

package.json
{
"name": "chia-changelist-generator",
"version": "1.0.0",
"version": "1.0.1",
"description": "Easily Generate a ChangeList for Chia DataLayer",

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

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