New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

javascript-commitment

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

javascript-commitment - npm Package Compare versions

Comparing version 0.1.3 to 0.1.4

lib.js

51

index.js
"use strict";
var messages = require("./commit_messages");
var lib = require("./lib");
var names = [

@@ -10,45 +11,5 @@ "Nick", "Steve", "Andy", "Qi", "Fanny", "Sarah", "Cord", "Todd",

];
// Behaves *kinda like* Python"s `random.choice()`.
var random_choice = function (keys) {
return keys[Math.floor(Math.random() * keys.length)];
};
// Returns a random integer between start (included) and end (included).
var random_integer = function (start, end) {
return Math.floor(Math.random() * (end - start + 1)) + start;
};
// Returns a Number, e.g. "10" => 10
var to_number = function (string) {
return parseInt(string, 10);
};
// Replaces `match` XNUM5,10X with `random_integer(5,10).toString`.
var replace_xnumx = function (match, value) {
var start = 1;
var end = 999;
if (value.length === 0) { // value = ''
value = end.toString();
}
var position = value.indexOf(",");
if (position > -1) {
if (position === 0) { // XNUM,5X
end = to_number(value.substring(1));
} else {
if (position === value.length - 1) { // XNUM5,X
start = to_number(value.substring(0, value.length - position));
} else { // XNUM1,5X
start = to_number(value.substring(0, value.length - position));
end = to_number(value.substring(position + 1));
}
}
} else {
end = to_number(value);
}
if (start > end) {
end = start * 2;
}
return random_integer(start, end).toString();
};
exports.whatThe = function () {
var hash = random_choice(Object.keys(messages));
var hash = lib.random_choice(Object.keys(messages));
var message = messages[hash];

@@ -58,6 +19,6 @@ var url = "http://whatthecommit.com/" + hash;

message = message
.replace(/XNAMEX/g, random_choice(names))
.replace(/XUPPERNAMEX/g, random_choice(names).toUpperCase())
.replace(/XLOWERNAMEX/g, random_choice(names).toLowerCase())
.replace(/XNUM([0-9,]*)X/g, replace_xnumx);
.replace(/XNAMEX/g, lib.random_choice(names))
.replace(/XUPPERNAMEX/g, lib.random_choice(names).toUpperCase())
.replace(/XLOWERNAMEX/g, lib.random_choice(names).toLowerCase())
.replace(/XNUM([0-9,]*)X/g, lib.replace_xnumx);

@@ -64,0 +25,0 @@ return {

{
"name": "javascript-commitment",
"version": "0.1.3",
"version": "0.1.4",
"description": "A commit message generator for JavaScript",

@@ -8,3 +8,4 @@ "main": "index.js",

"commit_messages.js",
"index.js"
"index.js",
"lib.js"
],

@@ -11,0 +12,0 @@ "scripts": {

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