First pass formatting with Prettier

* Added .prettierrc.json
* Added .prettierignore
* Formatted
This commit is contained in:
Bryan Ashby
2022-06-05 14:04:25 -06:00
parent eecfb33ad5
commit 4881c2123a
172 changed files with 23696 additions and 18029 deletions

View File

@@ -3,36 +3,39 @@
const { Errors } = require('./enig_error.js');
const _ = require('lodash');
const _ = require('lodash');
// FNV-1a based on work here: https://github.com/wiedi/node-fnv
module.exports = class FNV1a {
constructor(data) {
this.hash = 0x811c9dc5;
if(!_.isUndefined(data)) {
if (!_.isUndefined(data)) {
this.update(data);
}
}
update(data) {
if(_.isNumber(data)) {
if (_.isNumber(data)) {
data = data.toString();
}
if(_.isString(data)) {
if (_.isString(data)) {
data = Buffer.from(data);
}
if(!Buffer.isBuffer(data)) {
if (!Buffer.isBuffer(data)) {
throw Errors.Invalid('data must be String or Buffer!');
}
for(let b of data) {
for (let b of data) {
this.hash = this.hash ^ b;
this.hash +=
(this.hash << 24) + (this.hash << 8) + (this.hash << 7) +
(this.hash << 4) + (this.hash << 1);
(this.hash << 24) +
(this.hash << 8) +
(this.hash << 7) +
(this.hash << 4) +
(this.hash << 1);
}
return this;
@@ -49,4 +52,3 @@ module.exports = class FNV1a {
return this.hash & 0xffffffff;
}
};