Skip to content

Commit

Permalink
prettier: reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmillr committed Dec 10, 2023
1 parent 70fc075 commit ee2282e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
3 changes: 2 additions & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"printWidth": 100,
"singleQuote": true
"singleQuote": true,
"trailingComma": "es5"
}
16 changes: 7 additions & 9 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,7 @@ function radix(num: number): Coder<Uint8Array, number[]> {
assertNumber(num);
return {
encode: (bytes: Uint8Array) => {
if (!isBytes(bytes))
throw new Error('radix.encode input should be Uint8Array');
if (!isBytes(bytes)) throw new Error('radix.encode input should be Uint8Array');
return convertRadix(Array.from(bytes), 2 ** 8, num);
},
decode: (digits: number[]) => {
Expand All @@ -260,8 +259,7 @@ function radix2(bits: number, revPadding = false): Coder<Uint8Array, number[]> {
throw new Error('radix2: carry overflow');
return {
encode: (bytes: Uint8Array) => {
if (!isBytes(bytes))
throw new Error('radix2.encode input should be Uint8Array');
if (!isBytes(bytes)) throw new Error('radix2.encode input should be Uint8Array');
return convertRadix2(Array.from(bytes), 8, bits, !revPadding);
},
decode: (digits: number[]) => {
Expand Down Expand Up @@ -296,17 +294,15 @@ function checksum(
if (typeof fn !== 'function') throw new Error('checksum fn should be function');
return {
encode(data: Uint8Array) {
if (!isBytes(data))
throw new Error('checksum.encode: input should be Uint8Array');
if (!isBytes(data)) throw new Error('checksum.encode: input should be Uint8Array');
const checksum = fn(data).slice(0, len);
const res = new Uint8Array(data.length + len);
res.set(data);
res.set(checksum, data.length);
return res;
},
decode(data: Uint8Array) {
if (!isBytes(data))
throw new Error('checksum.decode: input should be Uint8Array');
if (!isBytes(data)) throw new Error('checksum.decode: input should be Uint8Array');
const payload = data.slice(0, -len);
const newChecksum = fn(payload).slice(0, len);
const oldChecksum = data.slice(-len);
Expand Down Expand Up @@ -404,7 +400,9 @@ export const base58xmr: BytesCoder = {
},
};

export const createBase58check = /* @__PURE__ */ (sha256: (data: Uint8Array) => Uint8Array): BytesCoder =>
export const createBase58check = /* @__PURE__ */ (
sha256: (data: Uint8Array) => Uint8Array
): BytesCoder =>
chain(
checksum(4, (data) => sha256(sha256(data))),
base58
Expand Down

0 comments on commit ee2282e

Please sign in to comment.