Compare commits

...

2 Commits

3 changed files with 9 additions and 7 deletions

6
dist/index.js vendored
View File

@ -1,7 +1,7 @@
import { Client, factory } from "@lumeweb/libkernel-universal"; import { Client, factory } from "@lumeweb/libkernel-universal";
import { MODULE } from "@lumeweb/kernel-swarm-client"; import { MODULE } from "@lumeweb/kernel-swarm-client";
import defer from "p-defer"; import defer from "p-defer";
import b4a from "b4a"; import { Buffer } from "buffer";
export default class Protomux { export default class Protomux {
isProtomux = true; isProtomux = true;
constructor(stream) { constructor(stream) {
@ -137,13 +137,13 @@ class Message extends Client {
if (data.args) { if (data.args) {
data.args = data.args.filter((arg) => { data.args = data.args.filter((arg) => {
if (arg instanceof Uint8Array) { if (arg instanceof Uint8Array) {
return b4a.from(arg); return Buffer.from(arg);
} }
return arg; return arg;
}); });
} }
if (data?.args && data?.args[0]?.buffer instanceof Uint8Array) { if (data?.args && data?.args[0]?.buffer instanceof Uint8Array) {
data.args[0].buffer = b4a.from(data.args[0].buffer); data.args[0].buffer = Buffer.from(data.args[0].buffer);
} }
switch (data.action) { switch (data.action) {
case "encode": case "encode":

View File

@ -1,11 +1,12 @@
{ {
"name": "@lumeweb/kernel-protomux-client", "name": "@lumeweb/kernel-protomux-client",
"version": "0.1.0", "version": "0.1.0",
"main": "dist/index.js", "main": "dist/index.js",
"dependencies": { "dependencies": {
"@lumeweb/kernel-swarm-client": "git+https://git.lumeweb.com/LumeWeb/kernel-swarm-client.git", "@lumeweb/kernel-swarm-client": "git+https://git.lumeweb.com/LumeWeb/kernel-swarm-client.git",
"@lumeweb/libkernel-universal": "git+https://git.lumeweb.com/LumeWeb/libkernel-universal.git", "@lumeweb/libkernel-universal": "git+https://git.lumeweb.com/LumeWeb/libkernel-universal.git",
"b4a": "^1.6.3", "b4a": "^1.6.3",
"buffer": "^6.0.3",
"p-defer": "^4.0.0" "p-defer": "^4.0.0"
}, },
"devDependencies": { "devDependencies": {

View File

@ -4,6 +4,7 @@ import { MODULE } from "@lumeweb/kernel-swarm-client";
import defer from "p-defer"; import defer from "p-defer";
import b4a from "b4a"; import b4a from "b4a";
import { Buffer } from "buffer";
export default class Protomux { export default class Protomux {
private isProtomux = true; private isProtomux = true;
@ -219,7 +220,7 @@ class Message extends Client {
if (data.args) { if (data.args) {
data.args = data.args.filter((arg: any) => { data.args = data.args.filter((arg: any) => {
if (arg instanceof Uint8Array) { if (arg instanceof Uint8Array) {
return b4a.from(arg); return Buffer.from(arg);
} }
return arg; return arg;
@ -227,7 +228,7 @@ class Message extends Client {
} }
if (data?.args && data?.args[0]?.buffer instanceof Uint8Array) { if (data?.args && data?.args[0]?.buffer instanceof Uint8Array) {
data.args[0].buffer = b4a.from(data.args[0].buffer); data.args[0].buffer = Buffer.from(data.args[0].buffer);
} }
switch (data.action) { switch (data.action) {
case "encode": case "encode":