Skip to content

Commit

Permalink
style: 💄 run Prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
streamich committed Mar 11, 2024
1 parent 84bd051 commit c836f8a
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/web3/adl/hamt-crdt/Hamt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class Hamt implements types.HamtApi {
const future = new Defer<void>();
this._loading = future.promise;
try {
const [prev, seq, ops, data] = await this.deps.cas.get(cid) as types.HamtRootFrameDto;
const [prev, seq, ops, data] = (await this.deps.cas.get(cid)) as types.HamtRootFrameDto;
this.prev = prev;
this.seq = seq;
this._root.loadDto(data, null);
Expand Down
9 changes: 6 additions & 3 deletions src/web3/adl/hamt-crdt/HamtFrame.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ export class HamtFrame {
/** Maybe instead of `_dirty`, just consider `id` === `null` to mean there are unsaved changes. */
protected _dirty: boolean = false;

constructor(protected readonly cas: CidCasStruct, public cid: Cid | null) {}
constructor(
protected readonly cas: CidCasStruct,
public cid: Cid | null,
) {}

protected async ensureLoaded(): Promise<void> {
if (this._loading) return this._loading.promise;
Expand All @@ -34,7 +37,7 @@ export class HamtFrame {
const id = this.cid;
if (!id) throw new Error('ID_NOT_SET');
this._loading = new Defer<void>();
const data = await this.cas.get(id) as types.HamtFrameDto;
const data = (await this.cas.get(id)) as types.HamtFrameDto;
this.loadDto(data, id);
this._loading.resolve();
this._loading = null;
Expand Down Expand Up @@ -207,7 +210,7 @@ export class HamtFrame {
}

public toDto(): types.HamtFrameDto {
const children = this._children.map((child) => child ? child.cid : null);
const children = this._children.map((child) => (child ? child.cid : null));
const dto: types.HamtFrameDto = [this._entries, children];
return dto;
}
Expand Down
2 changes: 1 addition & 1 deletion src/web3/adl/hamt-crdt/__tests__/HamtCrdt.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ describe('HamtCrdt', () => {
const [cid] = await hamt.save();
expect(cas._map.size).toBe(size + 1);
const blob = await cas.get(cid);
const found = toArr(blob).findIndex(octet => octet === data);
const found = toArr(blob).findIndex((octet) => octet === data);
expect(found > -1).toBe(true);
});

Expand Down
4 changes: 2 additions & 2 deletions src/web3/codec/Codecs.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {MulticodecIpld} from "../multiformats";
import type {IpldCodec} from "./types";
import {MulticodecIpld} from '../multiformats';
import type {IpldCodec} from './types';

export class Codecs {
protected readonly map = new Map<MulticodecIpld, IpldCodec>();
Expand Down
4 changes: 2 additions & 2 deletions src/web3/codec/codecs/cbor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ const encoder = new (class extends CborEncoderDag {
}
})(writer);

const decoder = new class extends CborDecoderDag {
const decoder = new (class extends CborDecoderDag {
public readTagRaw(tag: number): Cid | unknown {
const value = this.val();
if (tag === 42) return Cid.fromBinary(value as Uint8Array);
throw new Error('UNKNOWN_TAG');
}
}
})();

export const cbor: IpldCodec = {
name: 'DAG-CBOR',
Expand Down
2 changes: 1 addition & 1 deletion src/web3/codec/codecs/writer.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import {Writer} from "../../../util/buffers/Writer";
import {Writer} from '../../../util/buffers/Writer';

export const writer = new Writer();
8 changes: 4 additions & 4 deletions src/web3/codec/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {MulticodecIpld} from "../multiformats";
import {Codecs} from "./Codecs";
import {raw} from "./codecs/raw";
import {cbor} from "./codecs/cbor";
import {MulticodecIpld} from '../multiformats';
import {Codecs} from './Codecs';
import {raw} from './codecs/raw';
import {cbor} from './codecs/cbor';

export * from './types';
export * from './Codecs';
Expand Down
2 changes: 1 addition & 1 deletion src/web3/codec/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type {BinaryJsonDecoder, BinaryJsonEncoder} from "../../json-pack/types";
import type {BinaryJsonDecoder, BinaryJsonEncoder} from '../../json-pack/types';

export interface IpldCodec {
name: string;
Expand Down

0 comments on commit c836f8a

Please sign in to comment.