1.2.0 • Published 6 years ago
aznummap v1.2.0
AZMapper
Maps numbers to letters, letters to numbers
I needed to make a basic caesar crypt, and the other node packages for num-letter matching didn't do the job, so I made my own.
const expect = require("chai").expect;
const azNumMap = require("../index");
describe("AZNumMapper", () => {
it("Maps correctly to a, g, and z", () => {
expect(azNumMap("a")).to.equal(0);
expect(azNumMap("g")).to.equal(6);
expect(azNumMap("z")).to.equal(25);
});
it("Maps correctly to 0, 7, 25", () => {
expect(azNumMap(0)).to.equal("a");
expect(azNumMap(6)).to.equal("g");
expect(azNumMap(25)).to.equal("z");
});
it("Maps correctly to A, G, and Z", () => {
expect(azNumMap("A")).to.equal(26);
expect(azNumMap("G")).to.equal(32);
expect(azNumMap("Z")).to.equal(51);
});
it("Maps correctly to 26, 32, 51", () => {
expect(azNumMap(26)).to.equal("A");
expect(azNumMap(32)).to.equal("G");
expect(azNumMap(51)).to.equal("Z");
});
});