mirror of
https://github.com/logos-messaging/js-waku.git
synced 2026-01-04 06:43:12 +00:00
use loadash instead of custom function
This commit is contained in:
parent
c9389e3d07
commit
aa93a441d5
23
package-lock.json
generated
23
package-lock.json
generated
@ -3961,6 +3961,12 @@
|
|||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
|
"node_modules/@types/lodash": {
|
||||||
|
"version": "4.14.199",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.199.tgz",
|
||||||
|
"integrity": "sha512-Vrjz5N5Ia4SEzWWgIVwnHNEnb1UE1XMkvY5DGXrAeOGE9imk0hgTHh5GyDjLDJi9OTCn9oo9dXH1uToK1VRfrg==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"node_modules/@types/markdown-it": {
|
"node_modules/@types/markdown-it": {
|
||||||
"version": "12.2.3",
|
"version": "12.2.3",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
@ -13571,7 +13577,8 @@
|
|||||||
},
|
},
|
||||||
"node_modules/lodash": {
|
"node_modules/lodash": {
|
||||||
"version": "4.17.21",
|
"version": "4.17.21",
|
||||||
"license": "MIT"
|
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
|
||||||
|
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
|
||||||
},
|
},
|
||||||
"node_modules/lodash-es": {
|
"node_modules/lodash-es": {
|
||||||
"version": "4.17.21",
|
"version": "4.17.21",
|
||||||
@ -26134,6 +26141,7 @@
|
|||||||
"chai-as-promised": "^7.1.1",
|
"chai-as-promised": "^7.1.1",
|
||||||
"debug": "^4.3.4",
|
"debug": "^4.3.4",
|
||||||
"dockerode": "^3.3.5",
|
"dockerode": "^3.3.5",
|
||||||
|
"lodash": "^4.17.21",
|
||||||
"p-retry": "^6.1.0",
|
"p-retry": "^6.1.0",
|
||||||
"p-timeout": "^6.1.0",
|
"p-timeout": "^6.1.0",
|
||||||
"portfinder": "^1.0.32",
|
"portfinder": "^1.0.32",
|
||||||
@ -26144,6 +26152,7 @@
|
|||||||
"@libp2p/bootstrap": "^9.0.2",
|
"@libp2p/bootstrap": "^9.0.2",
|
||||||
"@types/chai": "^4.3.5",
|
"@types/chai": "^4.3.5",
|
||||||
"@types/dockerode": "^3.3.19",
|
"@types/dockerode": "^3.3.19",
|
||||||
|
"@types/lodash": "^4.14.199",
|
||||||
"@types/mocha": "^10.0.1",
|
"@types/mocha": "^10.0.1",
|
||||||
"@types/sinon": "^10.0.16",
|
"@types/sinon": "^10.0.16",
|
||||||
"@types/tail": "^2.2.1",
|
"@types/tail": "^2.2.1",
|
||||||
@ -28698,6 +28707,12 @@
|
|||||||
"version": "3.0.3",
|
"version": "3.0.3",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"@types/lodash": {
|
||||||
|
"version": "4.14.199",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.199.tgz",
|
||||||
|
"integrity": "sha512-Vrjz5N5Ia4SEzWWgIVwnHNEnb1UE1XMkvY5DGXrAeOGE9imk0hgTHh5GyDjLDJi9OTCn9oo9dXH1uToK1VRfrg==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"@types/markdown-it": {
|
"@types/markdown-it": {
|
||||||
"version": "12.2.3",
|
"version": "12.2.3",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
@ -29322,6 +29337,7 @@
|
|||||||
"@libp2p/peer-id": "^3.0.2",
|
"@libp2p/peer-id": "^3.0.2",
|
||||||
"@types/chai": "^4.3.5",
|
"@types/chai": "^4.3.5",
|
||||||
"@types/dockerode": "^3.3.19",
|
"@types/dockerode": "^3.3.19",
|
||||||
|
"@types/lodash": "^4.14.199",
|
||||||
"@types/mocha": "^10.0.1",
|
"@types/mocha": "^10.0.1",
|
||||||
"@types/sinon": "^10.0.16",
|
"@types/sinon": "^10.0.16",
|
||||||
"@types/tail": "^2.2.1",
|
"@types/tail": "^2.2.1",
|
||||||
@ -29342,6 +29358,7 @@
|
|||||||
"dockerode": "^3.3.5",
|
"dockerode": "^3.3.5",
|
||||||
"interface-datastore": "^8.2.5",
|
"interface-datastore": "^8.2.5",
|
||||||
"libp2p": "^0.46.12",
|
"libp2p": "^0.46.12",
|
||||||
|
"lodash": "^4.17.21",
|
||||||
"mocha": "^10.2.0",
|
"mocha": "^10.2.0",
|
||||||
"npm-run-all": "^4.1.5",
|
"npm-run-all": "^4.1.5",
|
||||||
"p-retry": "^6.1.0",
|
"p-retry": "^6.1.0",
|
||||||
@ -34746,7 +34763,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"lodash": {
|
"lodash": {
|
||||||
"version": "4.17.21"
|
"version": "4.17.21",
|
||||||
|
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
|
||||||
|
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
|
||||||
},
|
},
|
||||||
"lodash-es": {
|
"lodash-es": {
|
||||||
"version": "4.17.21"
|
"version": "4.17.21"
|
||||||
|
|||||||
@ -60,6 +60,7 @@
|
|||||||
"chai-as-promised": "^7.1.1",
|
"chai-as-promised": "^7.1.1",
|
||||||
"debug": "^4.3.4",
|
"debug": "^4.3.4",
|
||||||
"dockerode": "^3.3.5",
|
"dockerode": "^3.3.5",
|
||||||
|
"lodash": "^4.17.21",
|
||||||
"p-retry": "^6.1.0",
|
"p-retry": "^6.1.0",
|
||||||
"p-timeout": "^6.1.0",
|
"p-timeout": "^6.1.0",
|
||||||
"portfinder": "^1.0.32",
|
"portfinder": "^1.0.32",
|
||||||
@ -70,6 +71,7 @@
|
|||||||
"@libp2p/bootstrap": "^9.0.2",
|
"@libp2p/bootstrap": "^9.0.2",
|
||||||
"@types/chai": "^4.3.5",
|
"@types/chai": "^4.3.5",
|
||||||
"@types/dockerode": "^3.3.19",
|
"@types/dockerode": "^3.3.19",
|
||||||
|
"@types/lodash": "^4.14.199",
|
||||||
"@types/mocha": "^10.0.1",
|
"@types/mocha": "^10.0.1",
|
||||||
"@types/sinon": "^10.0.16",
|
"@types/sinon": "^10.0.16",
|
||||||
"@types/tail": "^2.2.1",
|
"@types/tail": "^2.2.1",
|
||||||
|
|||||||
@ -2,9 +2,9 @@ import { DecodedMessage, DefaultPubSubTopic } from "@waku/core";
|
|||||||
import { bytesToUtf8, utf8ToBytes } from "@waku/utils/bytes";
|
import { bytesToUtf8, utf8ToBytes } from "@waku/utils/bytes";
|
||||||
import { AssertionError, expect } from "chai";
|
import { AssertionError, expect } from "chai";
|
||||||
import debug from "debug";
|
import debug from "debug";
|
||||||
|
import isEqual from "lodash/isEqual";
|
||||||
|
|
||||||
import { MessageRpcResponse } from "./node/interfaces.js";
|
import { MessageRpcResponse } from "./node/interfaces.js";
|
||||||
import { areUint8ArraysEqual } from "./utils.js";
|
|
||||||
|
|
||||||
import { base64ToUtf8, delay, NimGoNode } from "./index.js";
|
import { base64ToUtf8, delay, NimGoNode } from "./index.js";
|
||||||
|
|
||||||
@ -44,7 +44,7 @@ export class MessageCollector {
|
|||||||
if (typeof message.payload === "string") {
|
if (typeof message.payload === "string") {
|
||||||
return message.payload === text;
|
return message.payload === text;
|
||||||
} else if (message.payload instanceof Uint8Array) {
|
} else if (message.payload instanceof Uint8Array) {
|
||||||
return areUint8ArraysEqual(message.payload, utf8ToBytes(text));
|
return isEqual(message.payload, utf8ToBytes(text));
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,7 +0,0 @@
|
|||||||
export function areUint8ArraysEqual(a: Uint8Array, b: Uint8Array): boolean {
|
|
||||||
if (a.length !== b.length) return false;
|
|
||||||
for (let i = 0; i < a.length; i++) {
|
|
||||||
if (a[i] !== b[i]) return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
@ -19,6 +19,7 @@ import {
|
|||||||
} from "@waku/message-encryption/symmetric";
|
} from "@waku/message-encryption/symmetric";
|
||||||
import { bytesToUtf8, utf8ToBytes } from "@waku/utils/bytes";
|
import { bytesToUtf8, utf8ToBytes } from "@waku/utils/bytes";
|
||||||
import { expect } from "chai";
|
import { expect } from "chai";
|
||||||
|
import isEqual from "lodash/isEqual";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
delay,
|
delay,
|
||||||
@ -28,7 +29,6 @@ import {
|
|||||||
tearDownNodes,
|
tearDownNodes,
|
||||||
TEST_STRING
|
TEST_STRING
|
||||||
} from "../../src/index.js";
|
} from "../../src/index.js";
|
||||||
import { areUint8ArraysEqual } from "../../src/utils.js";
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
customContentTopic,
|
customContentTopic,
|
||||||
@ -159,9 +159,7 @@ describe("Waku Store, general", function () {
|
|||||||
createDecoder(testItem["value"])
|
createDecoder(testItem["value"])
|
||||||
])) {
|
])) {
|
||||||
for await (const msg of query) {
|
for await (const msg of query) {
|
||||||
expect(
|
expect(isEqual(msg!.payload, utf8ToBytes(messageText))).to.eq(true);
|
||||||
areUint8ArraysEqual(msg!.payload, utf8ToBytes(messageText))
|
|
||||||
).to.eq(true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user