Compare commits
4 Commits
1bb963caa5
...
da4bda03ee
Author | SHA1 | Date |
---|---|---|
Derrick Hammer | da4bda03ee | |
Derrick Hammer | cafa333041 | |
Derrick Hammer | ff6babc53c | |
Derrick Hammer | e54e7e536d |
|
@ -1,5 +1,7 @@
|
||||||
|
/// <reference types="node" />
|
||||||
import ProtomuxRPC from "protomux-rpc";
|
import ProtomuxRPC from "protomux-rpc";
|
||||||
export default class RPC extends ProtomuxRPC {
|
export default class RPC extends ProtomuxRPC {
|
||||||
constructor(stream: any, options?: {});
|
constructor(stream: any, options?: {});
|
||||||
|
request(method: any, value?: Buffer | Uint8Array | string, options?: {}): Promise<any>;
|
||||||
}
|
}
|
||||||
//# sourceMappingURL=index.d.ts.map
|
//# sourceMappingURL=index.d.ts.map
|
|
@ -1 +1 @@
|
||||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,WAAW,MAAM,cAAc,CAAA;AAOtC,MAAM,CAAC,OAAO,OAAO,GAAI,SAAQ,WAAW;gBAC5B,MAAM,EAAE,GAAG,EAAE,OAAO,KAAK;CASxC"}
|
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,WAAW,MAAM,cAAc,CAAC;AAOvC,MAAM,CAAC,OAAO,OAAO,GAAI,SAAQ,WAAW;gBAC9B,MAAM,EAAE,GAAG,EAAE,OAAO,KAAK;IAW/B,OAAO,CACX,MAAM,EAAE,GAAG,EACX,KAAK,GAAE,MAAM,GAAG,UAAU,GAAG,MAAqB,EAClD,OAAO,KAAK;CAQf"}
|
|
@ -9,9 +9,16 @@ export default class RPC extends ProtomuxRPC {
|
||||||
options = {
|
options = {
|
||||||
...{
|
...{
|
||||||
id: ID,
|
id: ID,
|
||||||
valueEncoding: c.json
|
valueEncoding: c.json,
|
||||||
}, ...options
|
},
|
||||||
|
...options,
|
||||||
};
|
};
|
||||||
super(stream, options);
|
super(stream, options);
|
||||||
}
|
}
|
||||||
|
async request(method, value = b4a.from(""), options = {}) {
|
||||||
|
if (!b4a.isBuffer(value)) {
|
||||||
|
value = b4a.from(value);
|
||||||
|
}
|
||||||
|
return super.request(method, value, options);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
"protomux-rpc": "^1.3.0"
|
"protomux-rpc": "^1.3.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/b4a": "^1.6.0"
|
"@types/b4a": "^1.6.0",
|
||||||
|
"prettier": "^2.8.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
25
src/index.ts
25
src/index.ts
|
@ -1,19 +1,32 @@
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import ProtomuxRPC from "protomux-rpc"
|
import ProtomuxRPC from "protomux-rpc";
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import c from "compact-encoding"
|
import c from "compact-encoding";
|
||||||
import b4a from "b4a"
|
import b4a from "b4a";
|
||||||
|
|
||||||
const ID = b4a.from("lumeweb")
|
const ID = b4a.from("lumeweb");
|
||||||
|
|
||||||
export default class RPC extends ProtomuxRPC {
|
export default class RPC extends ProtomuxRPC {
|
||||||
constructor(stream: any, options = {}) {
|
constructor(stream: any, options = {}) {
|
||||||
options = {
|
options = {
|
||||||
...{
|
...{
|
||||||
id: ID,
|
id: ID,
|
||||||
valueEncoding: c.json
|
valueEncoding: c.json,
|
||||||
}, ...options
|
},
|
||||||
|
...options,
|
||||||
};
|
};
|
||||||
super(stream, options);
|
super(stream, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async request(
|
||||||
|
method: any,
|
||||||
|
value: Buffer | Uint8Array | string = b4a.from(""),
|
||||||
|
options = {}
|
||||||
|
) {
|
||||||
|
if (!b4a.isBuffer(value)) {
|
||||||
|
value = b4a.from(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.request(method, value, options);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue