
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
precedence-maps
Advanced tools
Utilities to define graphs for your apps and schedule the execution of operations, fast.
Graphing and ordered maps for scheduling execution of tasks, fast.
npm install precedence-maps
then in your code:
precedence = require('precedence-maps')
First we need to define a graph for our application.
var graphDefinitions = {
"man": { incoming: ["god"], outgoing: ["animal"]},
"god": { outgoing: ["animal","man"]}, // outgoing means things that come after
"animal": { incoming: ["god","man"]} // and incoming for things that come before
}
precedence.setGraph("mygraph", {
map: graphDefinitions
});
precedence.getOrder("mygraph"); // [ 'god', 'man', 'animal' ]
The order will be flagged for refresh whenever setGraph is called for the specific graph. You can make several changes in the graph definitions, setGraph with/or without options(setting options refresh the configuration), and calculation will only take place when getOrder() is called or internally in the stores as needed.
var store = precedence.newStore("mygraph", Array) // Create a store where keys match properties in graphDefinitions
store('man').push("mike") // We declared Array to be the default constructor so that's what we get on new symbols.
store('god').push("loki");
store('man').push("bill");
store('animal').push("rat");
store('animal').push("pig");
store('man').push("kate");
store('god').push("thor");
// Calling store with no arguments returns an array orders by the graph
store().forEach(function (v) { console.log(v); });
/*
[ 'loki', 'thor' ]
[ 'mike', 'bill', 'kate' ]
[ 'rat', 'pig' ]
*/
Parsing the graph definitions can also be customized by providing/overriding two methods. Enumerate(graph) which must return an unordered array of graph symbols and collect(graph, symbolName) which will run per symbol and must return either an object like
{
incoming: ["symbolNameBefore1","symbolNameBefore2",...],
outgoing: ["symbolNameAfter1",...]
}
or a false value to omit this symbol from sorting.
Returns: {Array} a list of names, sorted in the order of precedence
Run the tests with node test.js.
MIT License
FAQs
Utilities to define graphs for your apps and schedule the execution of operations, fast.
We found that precedence-maps demonstrated a not healthy version release cadence and project activity because the last version was released 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
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.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.