
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
codelist-diff
Advanced tools
Library for creating small for making small diffs between CodeList arrays fast.
Library for diffing CodeList tables which are defined like this:
interface CodeItem {
code: number | string;
category: string;
}
type CodeList = CodeItem[];
Each code-value must be unique within a CodeList.
Install the current version (and save it as a dependency):
$ npm install codelist-diff --save
const CodelistDiff = require("codelist-diff");
const arr1 = [
{
code: 2,
category: "Category 2"
},
{
code: 1,
category: "Category 1"
}
]
const arr2 = [
{
code: 1,
category: "Category 1"
},
{
code: 2,
category: "Category 2"
}
{
code: 3,
category: "Category 2"
}
]
const delta = CodeListDiff.diff(arr1, arr2);
const arr = CodeListDiff.patch(arr1, delta); // arr is now equal to arr2
It is also possible to add a metadata prop as the 3rd parameter to the diff function. The metadata object will be part of the error thrown if duplicate code-values are detected.
interface Metadata {
prev: {
name: string;
index: number;
},
current: {
name: string;
index: number;
}
}
export function diff(prev: CodeItem[], current: CodeItem[], metadata?: Metadata): Delta
export function patch(prev: CodeItem[], delta: Delta)
// Operations should be performed in the order shown in this interface
export interface Delta {
/**
* Remove items at these index positions
*/
remove: number[];
/**
* For each index position replace the value with the specified CodeItem
*/
replace: { [index: number]: CodeItem };
/**
* Reorder by replacing values. Every 2 items are a pair: [v1a, v1b, v2a, v2b, ...]
* v1a: The index in the current array that needs to be replaced
* v1b: The index in the unmodified prev array to get the new item from
*/
reorder: number[];
/**
* For each index position the specified CodeItem should be inserted
*/
insert: { [index: number]: CodeItem };
}
FAQs
Library for creating small for making small diffs between CodeList arrays fast.
We found that codelist-diff demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.