added prettier
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
export const is_big_endian_system =
|
||||
new Uint8Array(new Uint32Array([ 0x12345678 ]).buffer)[0] === 0x12;
|
||||
new Uint8Array(new Uint32Array([0x12345678]).buffer)[0] === 0x12;
|
||||
|
||||
export const is_little_endian_system =
|
||||
new Uint8Array(new Uint32Array([ 0x12345678 ]).buffer)[0] === 0x78;
|
||||
new Uint8Array(new Uint32Array([0x12345678]).buffer)[0] === 0x78;
|
||||
|
||||
export const i8_to_ui8_array = num => {
|
||||
export const i8_to_ui8_array = (num) => {
|
||||
if (typeof num === 'string' || num instanceof String) {
|
||||
num = parseInt(num, 10);
|
||||
}
|
||||
@@ -21,7 +21,7 @@ export const ui8_array_to_i8 = (ar, offset) => {
|
||||
return buffer.readInt8(0);
|
||||
};
|
||||
|
||||
export const ui8_to_ui8_array = num => {
|
||||
export const ui8_to_ui8_array = (num) => {
|
||||
if (typeof num === 'string' || num instanceof String) {
|
||||
num = parseInt(num, 10);
|
||||
}
|
||||
@@ -38,7 +38,7 @@ export const ui8_array_to_ui8 = (ar, offset) => {
|
||||
return buffer.readUInt8(0);
|
||||
};
|
||||
|
||||
export const i16_to_be_ui8_array = num => {
|
||||
export const i16_to_be_ui8_array = (num) => {
|
||||
if (typeof num === 'string' || num instanceof String) {
|
||||
num = parseInt(num, 10);
|
||||
}
|
||||
@@ -56,7 +56,7 @@ export const be_ui8_array_to_i16 = (ar, offset) => {
|
||||
return buffer.readInt16BE(0);
|
||||
};
|
||||
|
||||
export const ui16_to_be_ui8_array = num => {
|
||||
export const ui16_to_be_ui8_array = (num) => {
|
||||
if (typeof num === 'string' || num instanceof String) {
|
||||
num = parseInt(num, 10);
|
||||
}
|
||||
@@ -74,7 +74,7 @@ export const be_ui8_array_to_ui16 = (ar, offset) => {
|
||||
return buffer.readUInt16BE(0);
|
||||
};
|
||||
|
||||
export const i32_to_be_ui8_array = num => {
|
||||
export const i32_to_be_ui8_array = (num) => {
|
||||
if (typeof num === 'string' || num instanceof String) {
|
||||
num = parseInt(num, 10);
|
||||
}
|
||||
@@ -92,7 +92,7 @@ export const be_ui8_array_to_i32 = (ar, offset) => {
|
||||
return buffer.readInt32BE(0);
|
||||
};
|
||||
|
||||
export const ui32_to_be_ui8_array = num => {
|
||||
export const ui32_to_be_ui8_array = (num) => {
|
||||
if (typeof num === 'string' || num instanceof String) {
|
||||
num = parseInt(num, 10);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
const {v4: uuidv4} = require('uuid');
|
||||
import _package_json from '../../package.json'
|
||||
const { v4: uuidv4 } = require('uuid');
|
||||
import _package_json from '../../package.json';
|
||||
|
||||
export const instance_id = uuidv4();
|
||||
export const package_json = _package_json;
|
||||
export const get_version = () => process.env.REPERTORY_JS_FORCE_VERSION || _package_json.version;
|
||||
export const get_version = () =>
|
||||
process.env.REPERTORY_JS_FORCE_VERSION || _package_json.version;
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
*
|
||||
* @constructor
|
||||
*/
|
||||
var JSChaCha20 = function(key, nonce, counter) {
|
||||
var JSChaCha20 = function (key, nonce, counter) {
|
||||
if (typeof counter === 'undefined') {
|
||||
counter = 0;
|
||||
}
|
||||
@@ -175,7 +175,7 @@ var JSChaCha20 = function(key, nonce, counter) {
|
||||
this._byteCounter = 0;
|
||||
};
|
||||
|
||||
JSChaCha20.prototype._chacha = function() {
|
||||
JSChaCha20.prototype._chacha = function () {
|
||||
var mix = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
|
||||
var i = 0;
|
||||
var b = 0;
|
||||
@@ -221,7 +221,7 @@ JSChaCha20.prototype._chacha = function() {
|
||||
* @param {number} d
|
||||
* @private
|
||||
*/
|
||||
JSChaCha20.prototype._quarterround = function(output, a, b, c, d) {
|
||||
JSChaCha20.prototype._quarterround = function (output, a, b, c, d) {
|
||||
output[d] = this._rotl(output[d] ^ (output[a] += output[b]), 16);
|
||||
output[b] = this._rotl(output[b] ^ (output[c] += output[d]), 12);
|
||||
output[d] = this._rotl(output[d] ^ (output[a] += output[b]), 8);
|
||||
@@ -242,7 +242,7 @@ JSChaCha20.prototype._quarterround = function(output, a, b, c, d) {
|
||||
* @return {number}
|
||||
* @private
|
||||
*/
|
||||
JSChaCha20.prototype._get32 = function(data, index) {
|
||||
JSChaCha20.prototype._get32 = function (data, index) {
|
||||
return (
|
||||
data[index++] ^
|
||||
(data[index++] << 8) ^
|
||||
@@ -259,7 +259,7 @@ JSChaCha20.prototype._get32 = function(data, index) {
|
||||
* @return {number}
|
||||
* @private
|
||||
*/
|
||||
JSChaCha20.prototype._rotl = function(data, shift) {
|
||||
JSChaCha20.prototype._rotl = function (data, shift) {
|
||||
return (data << shift) | (data >>> (32 - shift));
|
||||
};
|
||||
|
||||
@@ -269,7 +269,7 @@ JSChaCha20.prototype._rotl = function(data, shift) {
|
||||
* @param {Uint8Array} data
|
||||
* @return {Uint8Array}
|
||||
*/
|
||||
JSChaCha20.prototype.encrypt = function(data) {
|
||||
JSChaCha20.prototype.encrypt = function (data) {
|
||||
return this._update(data);
|
||||
};
|
||||
|
||||
@@ -279,7 +279,7 @@ JSChaCha20.prototype.encrypt = function(data) {
|
||||
* @param {Uint8Array} data
|
||||
* @return {Uint8Array}
|
||||
*/
|
||||
JSChaCha20.prototype.decrypt = function(data) {
|
||||
JSChaCha20.prototype.decrypt = function (data) {
|
||||
return this._update(data);
|
||||
};
|
||||
|
||||
@@ -290,7 +290,7 @@ JSChaCha20.prototype.decrypt = function(data) {
|
||||
* @return {Uint8Array}
|
||||
* @private
|
||||
*/
|
||||
JSChaCha20.prototype._update = function(data) {
|
||||
JSChaCha20.prototype._update = function (data) {
|
||||
if (!(data instanceof Uint8Array) || data.length === 0) {
|
||||
throw new Error('Data should be type of bytes (Uint8Array) and not empty!');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user