Skip to content

Commit

Permalink
util: minimalistic-assert => tiny-invariant
Browse files Browse the repository at this point in the history
  • Loading branch information
yoursunny committed May 31, 2024
1 parent 9477e3c commit 307ee4d
Show file tree
Hide file tree
Showing 10 changed files with 11 additions and 13 deletions.
1 change: 0 additions & 1 deletion mk/build-post.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ const CJS_IMPORTS = new Set([
"event-iterator",
"fast-chunk-string",
"it-keepalive",
"minimalistic-assert",
"mnemonist",
"nodemailer",
"obliterator",
Expand Down
2 changes: 1 addition & 1 deletion pkg/fw/src/tap-face.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class TapRxController {
}

public add(src: FwFace, dst: TapFace) {
assert.equal(src.fw, this.fw);
assert(src.fw === this.fw);
this.taps.add(src, dst);
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/psync/src/iblt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export class IBLT {

private update2(ht: Hashtable, change: number, keyInput: number): void {
const { key, buf, checkHash } = this.key;
assert.equal(key, keyInput);
assert(key === keyInput);
for (let k = 0; k < this.p.nHash; ++k) {
const h = this.p.hash(k, buf);
const i = k * this.p.nBuckets + h % this.p.nBuckets;
Expand All @@ -105,7 +105,7 @@ export class IBLT {
const hts: Hashtable[] = [
this.ht,
...others.map((other) => {
assert.equal(this.p.nEntries, other.p.nEntries);
assert(this.p.nEntries === other.p.nEntries);
return other.ht;
}),
];
Expand Down
2 changes: 1 addition & 1 deletion pkg/repo/src/data-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ export class Transaction {
private async commitWithDiff() {
const requests = Array.from(this.diffs!);
const oldRecords = await this.db.getMany(requests.map(([name]) => name));
assert.equal(requests.length, oldRecords.length);
assert(requests.length === oldRecords.length);

await this.chain.write();

Expand Down
2 changes: 1 addition & 1 deletion pkg/repo/src/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const AbstractLevelOptions: AbstractDatabaseOptions<Name, Record> = {
const jBufCap = 3 * jText.length;
const jBuf = encoder.prependRoom(jBufCap);
const { read: jTextLen = 0, written: jBufLen = 0 } = textEncoder.encodeInto(jText, jBuf);
assert.equal(jTextLen, jText.length);
assert(jTextLen === jText.length);
encoder.encode(record.data);
return encoder.output.subarray(0, encoder.size - jBufCap + jBufLen);
},
Expand Down
3 changes: 1 addition & 2 deletions pkg/util/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@
},
"dependencies": {
"@shigen/polyfill-symbol-dispose": "^1.0.1",
"@types/minimalistic-assert": "^1.0.3",
"event-iterator": "^2.0.0",
"minimalistic-assert": "^1.0.1",
"streaming-iterables": "^8.0.1",
"tiny-invariant": "^1.3.3",
"tslib": "^2.6.2",
"type-fest": "^4.18.3",
"wait-your-turn": "^1.0.1"
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/src/event.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import assert from "minimalistic-assert";
import assert from "tiny-invariant";

/** @deprecated Use global `CustomEvent`. */
export const CustomEvent = globalThis.CustomEvent;
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/src/iter.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import EventIterator from "event-iterator";
import assert from "minimalistic-assert";
import type { AnyIterable } from "streaming-iterables";
import assert from "tiny-invariant";

/** An iterable that you can push values into. */
export interface Pushable<T> extends AsyncIterable<T> {
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/src/mod.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import "./polyfill_node";

import assert from "minimalistic-assert";
import assert from "tiny-invariant";

export { assert };
export { console, concatBuffers, crypto, delay } from "./platform_node";
Expand Down
4 changes: 2 additions & 2 deletions pkg/util/src/platform_browser.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import assert from "minimalistic-assert";
import assert from "tiny-invariant";

export function concatBuffers(list: readonly Uint8Array[], totalLength?: number): Uint8Array {
totalLength ??= list.reduce((l, { byteLength }) => l + byteLength, 0);
Expand All @@ -8,7 +8,7 @@ export function concatBuffers(list: readonly Uint8Array[], totalLength?: number)
c.set(part, offset);
offset += part.byteLength;
}
assert.equal(offset, totalLength);
assert(offset === totalLength);
return c;
}

Expand Down

0 comments on commit 307ee4d

Please sign in to comment.