Socket
Socket
Sign inDemoInstall

cdigit

Package Overview
Dependencies
Maintainers
1
Versions
54
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cdigit - npm Package Compare versions

Comparing version 2.6.3 to 2.6.4

21

.eslintrc.json
{
"root": true,
"extends": ["eslint:recommended"],

@@ -6,21 +7,13 @@ "overrides": [

"files": ["*.ts"],
"extends": [
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"prettier/@typescript-eslint",
"plugin:prettier/recommended"
],
"parserOptions": {
"project": "tsconfig.json"
}
"extends": ["plugin:@typescript-eslint/recommended"],
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"]
},
{
"files": ["*.js"],
"extends": ["plugin:prettier/recommended"],
"env": {
"node": true
},
"parserOptions": {
"ecmaVersion": 2015
},
"env": {
"node": true
}

@@ -27,0 +20,0 @@ },

#!/usr/bin/env node
const { EOL } = require("os");
const { program } = require("commander");

@@ -9,22 +10,25 @@ const cdigit = require("..");

.option("-a, --algo <name>", "specify check digit algorithm by name")
.on("--help", () => {
// custom help
console.log("");
console.log("Supported Algorithms:");
const maxlen = Math.max(...cdigit.names.map((ss) => ss.length));
console.log(` ${"NAME".padEnd(maxlen, " ")} ALGORITHM`);
cdigit.names.forEach((name) => {
console.log(` ${name.padEnd(maxlen, " ")} ${cdigit[name].longName}`);
});
console.log(
" (--algo defaults to 'luhn' or CDIGIT_CLI_DEFAULT_ALGO env var if set)"
);
});
.addHelpText(
"after",
(() => {
const lines = [""];
lines.push("Supported Algorithms:");
const maxlen = Math.max(...cdigit.names.map((ss) => ss.length));
lines.push(` ${"NAME".padEnd(maxlen, " ")} ALGORITHM`);
cdigit.names.forEach((name) => {
lines.push(` ${name.padEnd(maxlen, " ")} ${cdigit[name].longName}`);
});
lines.push(
" (--algo defaults to 'luhn' or CDIGIT_CLI_DEFAULT_ALGO env var if set)"
);
return lines.join(EOL);
})()
);
// handler for subcommands
const handler = (str, opts, cmd) => {
opts = program.opts(); // XXX
const topOpts = program.opts();
let algo = "luhn";
if (typeof opts.algo === "string") {
({ algo } = opts);
if (typeof topOpts.algo === "string") {
algo = topOpts.algo;
} else if (typeof process.env.CDIGIT_CLI_DEFAULT_ALGO === "string") {

@@ -31,0 +35,0 @@ algo = process.env.CDIGIT_CLI_DEFAULT_ALGO;

{
"name": "cdigit",
"version": "2.6.3",
"version": "2.6.4",
"description": "Collection of check digit algorithms implemented in JavaScript",

@@ -12,3 +12,4 @@ "main": "lib/index.js",

"build": "rm -rf lib && tsc",
"lint": "eslint --ext .js,.ts example.js bin src test",
"lint": "eslint example.js bin src test",
"prelint": "prettier -c README.md example.js bin src test",
"prepare": "npm run lint && npm run build && npm test",

@@ -73,4 +74,2 @@ "test": "mocha"

"eslint": "^7.20.0",
"eslint-config-prettier": "^7.2.0",
"eslint-plugin-prettier": "^3.3.1",
"mocha": "^8.3.0",

@@ -80,3 +79,6 @@ "prettier": "^2.2.1",

"typescript": "^4.2.2"
},
"prettier": {
"embeddedLanguageFormatting": "off"
}
}

@@ -37,5 +37,5 @@ # cdigit: Check Digit Algorithms in JS

[Luhn]: https://en.wikipedia.org/wiki/Luhn_algorithm
[Verhoeff]: https://en.wikipedia.org/wiki/Verhoeff_algorithm
[Damm]: https://en.wikipedia.org/wiki/Damm_algorithm
[luhn]: https://en.wikipedia.org/wiki/Luhn_algorithm
[verhoeff]: https://en.wikipedia.org/wiki/Verhoeff_algorithm
[damm]: https://en.wikipedia.org/wiki/Damm_algorithm

@@ -61,3 +61,3 @@ ### [ISO/IEC 7064] Family

[ISO/IEC 7064]: https://www.iso.org/standard/31531.html
[iso/iec 7064]: https://www.iso.org/standard/31531.html

@@ -80,8 +80,8 @@ ### [GTIN] (Global Trade Item Number) Family

[GTIN]: https://www.gs1.org/standards/id-keys/gtin
[UPC]: https://en.wikipedia.org/wiki/Universal_Product_Code
[EAN]: https://en.wikipedia.org/wiki/International_Article_Number
[ISBN]: https://en.wikipedia.org/wiki/International_Standard_Book_Number
[GS1 data structures]: https://www.gs1.org/standards/id-keys
[JAN]: https://en.wikipedia.org/wiki/International_Article_Number#Japanese_Article_Number
[gtin]: https://www.gs1.org/standards/id-keys/gtin
[upc]: https://en.wikipedia.org/wiki/Universal_Product_Code
[ean]: https://en.wikipedia.org/wiki/International_Article_Number
[isbn]: https://en.wikipedia.org/wiki/International_Standard_Book_Number
[gs1 data structures]: https://www.gs1.org/standards/id-keys
[jan]: https://en.wikipedia.org/wiki/International_Article_Number#Japanese_Article_Number

@@ -88,0 +88,0 @@ ## Usage - Node.js

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