
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.
linked-chain
Advanced tools
A Temporal, Node-Based Graph Data Structure for TypeScript.
LinkedChain is a sophisticated data structure designed for scenarios where history, lineage, and version control are distinct first-class citizens of your runtime state.
Unlike a traditional Doubly Linked List, every LinkedChain node behaves like a "Git Repo" for its own data. It tracks every change, allows for instant time-travel (undo/redo) to any past state, and supports branching timelines where a single object can fork into multiple independent futures.
Install via your preferred package manager:
Bun
bun add linked-chain
NPM
npm install linked-chain
import LinkedChain from "linked-chain";
// 1. Create a chain node
const node = new LinkedChain({
data: { value: 100 },
metadata: { title: "Initial State" }
});
// 2. Update it (Automatic History Tracking)
node.update({
data: { value: 200 } // Changes are recorded as deltas
});
// 3. Time Travel
console.log(node.data()); // { value: 200 }
node.revert_to_history(0);
console.log(node.data()); // { value: 100 }
LinkedChain is fully typed. You can define your own interfaces to ensure type safety across history and branching.
// Define your state shape
interface UserProfile {
id: number;
username: string;
role: "admin" | "user";
}
// Pass the interface to the Generic
const userNode = new LinkedChain<UserProfile>({
data: { id: 1, username: "neo", role: "user" }
});
// TypeScript enforces the shape!
userNode.update({
// @ts-expect-error: 'god' is not assignable to type "admin" | "user"
data: { role: "god" }
});
We label this data structure "self-aware" because it satisfies three criteria of computational reflexivity that standard nodes lack:
LinkedChain node retains a memory of every state it has ever held.LinkedChainHistory)Every node has access to a LinkedChainHistory engine.
HistoryEntry objects.LinkedChain calculates the difference between the current state and the previous state. It stores only this delta.Just like Git, you can create a "Fork" of your data at any point in its history.
// Create a NEW, independent chain starting from History Index 2
const branch = node.branch_from_history(2);
The new branch is a separate object but retains the lineage of the original.
We have provided a suite of heavily commented examples to demonstrate the power of LinkedChain.
| Example | Complexity | Description |
|---|---|---|
| Basic Usage | ⭐ | Learn the basics: Creating nodes, updating data, and inspecting the auto-generated history timeline. |
| Branching Scenarios | ⭐⭐ | A "Git-like" document drafting system where you fork a draft from a previous version to explore an alternate ending. |
| The Multiverse Simulator | ⭐⭐⭐ | A complex sci-fi simulation tracking multiple parallel civilizations. Demonstrates deep lineage analysis and searching across divergent graph branches. |
| Chrono-Rogue (Game) | ⭐⭐⭐⭐ | A "Roguelike" game engine that detects player death, automatically scans history for the last safe save state, rewinds time, and alters player strategy to survive. |
LinkedChain<T>new LinkedChain<T>(ingredients: LinkedChainIngredients<T>)
data: Initial data payload.metadata: Initial metadata (title, id, description).parent / next / origin: Optional graph connections.update(ingredients): Updates data/metadata and records a history entry.data(): Returns the current data payload.metadata(): Returns the current metadata.toJSON(): Serializes the current state (excludes history).revert_to_history(index): Reverts the current state to a past point in time. This creates a new history entry representing the revert.branch_from_history(index): Returns a new LinkedChain instance starting from the state at index.history().timeline(): Returns the array of all history entries.ancestor_path(): Returns an array of all previous nodes (walking backwards).progeny_path(): Returns an array of all next nodes (walking forwards).iterate('next' | 'previous'): A Generator for lazy iteration.find(predicate): Searches the entire connected linear chain (up and down) for a node matching the predicate.has_circular_link(): Returns true if the chain loops on itself.While powerful, LinkedChain is currently in Alpha and has several known architectural limitations:
LinkedChainHistory timeline grows indefinitely. There is currently no "Garbage Collection" or "Squashing" mechanism to purge old history entries, so very long-running chains may consume significant memory..toJSON() method exports only the current node's state. It does not export the entire history timeline or the graph structure (relationships). You cannot yet JSON.stringify a chain and JSON.parse it back into a fully functional, time-traveling object..update() method (e.g., node.data().value = 5) breaks the history tracking.I am actively looking for contributors!
This project (and others in our portfolio) needs engineers who love graph theory, data structures, and TypeScript. If you're interested in:
Please open an issue or submit a PR. I am building a suite of advanced tools and would love your help.
Documentation Generated with AI
FAQs
A self-aware, time-traveling graph data structure for TypeScript.
We found that linked-chain 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.