Research
Security News
Threat Actor Exposes Playbook for Exploiting npm to Build Blockchain-Powered Botnets
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
Ever find yourself handling complex data structures in JavaScript? With cmd.js, one can assemble small blocks of logic, and easily pass data through them for processing. Here's a sample task, and how it's made clearer with cmd.js:
Sort the users by increasing age, and display the name and id of each user.
var users = [
{name: 'John', id: 1, age: 37},
{name: 'Kimberly', id: 2, age: 35},
{name: 'Janine', id: 3, age: 33},
{name: 'Justin', id: 4, age: 31},
];
users.sort(function (a, b) {
return a.age > b.age;
});
users.forEach(function (user) {
console.log(user.name, user.id);
});
// The output:
// Justin 4
// Janine 3
// Kimberly 2
// John 1
Pretty simple, right?
var pluck = cmd.pluck;
var sortAndPrint = cmd.sort(pluck('age')).
and.logger(pluck('name'), pluck('id'));
sortAndPrint(users);
// The output:
// Justin 4
// Janine 3
// Kimberly 2
// John 1
The benefits of this style include reusability, clear logical flow, and less code in general. By composing commands you keep your functionality completely isolated from your data.
This project uses gulp. Make all changes/additions in lib/*.js
while running gulp
from the command line.
cmd.name(... args ...)(... vals ...);
Some commands do not accept args, and you are given the command with empty args already provided.
cmd.sum(... vals ...);
cmd.alert(val1, ...)
name | all or each? | accepts args? | return value |
---|---|---|---|
alert | each | no | [undefined, ...] |
The following example displays two alerts in sequence.
cmd.alert('Hello World!', 'Will Smith here.');
cmd.compare(val1, val2)
name | all or each? | accepts args? | return value |
---|---|---|---|
compare | all | no | -1 or 0 or 1 |
Compare is a unique command in that it only accepts 2 values. Any further values will be ignored.
The following example compares two values.
console.log(cmd.compare(8, 5)); // logs 3
cmd.exists(val1, ...)
name | all or each? | accepts args? | return value |
---|---|---|---|
exists | each | no | [true or false, ...] |
The following example checks the existence of the values. Only null and undefined count as not existing.
cmd.exists(null, undefined, false, '', 0, true);
// [false, false, true, true, true, true]
cmd.extend(arg1, ...)(val1, ...)
name | all or each? | accepts args? | return value |
---|---|---|---|
extend | each | yes | [{...}, ...] |
Extends each value with each argument, in order.
cmd.extend({color: 'red'})({item: 'wrench'}, {item: 'apple'});
// [{item: 'wrench', color: 'red'}, {item: 'apple', color: 'red'}]
FAQs
A chainable utility toolkit for JavaScript.
The npm package cmd.js receives a total of 0 weekly downloads. As such, cmd.js popularity was classified as not popular.
We found that cmd.js 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.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.