* Refactor index.ts and package.json to use the Buffer module instead of b4a module for buffer operations.

This commit is contained in:
Derrick Hammer 2023-04-09 00:35:28 -04:00
parent 47a0fed27e
commit fbaf4314f3
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
2 changed files with 6 additions and 4 deletions

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":