Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"message": "Use `globalThis` instead"
}
],
"prefer-rest-params": 0,
"require-yield": 0,
"eqeqeq": ["error", "smart"],
"spaced-comment": [
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ npm install
# build the dist
npm run build
# run the repl (this allows you to import from ./src)
npm run ts-node
npm run tsx
# run the tests
npm run test
# lint the source code
Expand Down
13 changes: 8 additions & 5 deletions benches/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,25 @@

import fs from 'fs';
import path from 'path';
import url from 'url';
import si from 'systeminformation';

const dirname = url.fileURLToPath(new URL('.', import.meta.url));

async function main(): Promise<void> {
await fs.promises.mkdir(path.join(__dirname, 'results'), { recursive: true });
await fs.promises.mkdir(path.join(dirname, 'results'), { recursive: true });
const resultFilenames = await fs.promises.readdir(
path.join(__dirname, 'results'),
path.join(dirname, 'results'),
);
const metricsFile = await fs.promises.open(
path.join(__dirname, 'results', 'metrics.txt'),
path.join(dirname, 'results', 'metrics.txt'),
'w',
);
let concatenating = false;
for (const resultFilename of resultFilenames) {
if (/.+_metrics\.txt$/.test(resultFilename)) {
const metricsData = await fs.promises.readFile(
path.join(__dirname, 'results', resultFilename),
path.join(dirname, 'results', resultFilename),
);
if (concatenating) {
await metricsFile.write('\n');
Expand All @@ -33,7 +36,7 @@ async function main(): Promise<void> {
system: 'model, manufacturer',
});
await fs.promises.writeFile(
path.join(__dirname, 'results', 'system.json'),
path.join(dirname, 'results', 'system.json'),
JSON.stringify(systemData, null, 2),
);
}
Expand Down
2 changes: 1 addition & 1 deletion benches/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from './utils';
export * from './utils.js';
9 changes: 6 additions & 3 deletions benches/utils/utils.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,30 @@
import fs from 'fs';
import path from 'path';
import url from 'url';
import b from 'benny';
import { codeBlock } from 'common-tags';
import packageJson from '../../package.json';

const dirname = url.fileURLToPath(new URL('.', import.meta.url));

const suiteCommon = [
b.cycle(),
b.complete(),
b.save({
file: (summary) => summary.name,
folder: path.join(__dirname, '../results'),
folder: path.join(dirname, '../results'),
version: packageJson.version,
details: true,
}),
b.save({
file: (summary) => summary.name,
folder: path.join(__dirname, '../results'),
folder: path.join(dirname, '../results'),
version: packageJson.version,
format: 'chart.html',
}),
b.complete((summary) => {
const filePath = path.join(
__dirname,
dirname,
'../results',
summary.name + '_metrics.txt',
);
Expand Down
2 changes: 1 addition & 1 deletion docs/assets/search.js

Large diffs are not rendered by default.

77 changes: 25 additions & 52 deletions docs/classes/RPCClient.html

Large diffs are not rendered by default.

104 changes: 41 additions & 63 deletions docs/classes/RPCServer.html

Large diffs are not rendered by default.

13 changes: 7 additions & 6 deletions docs/classes/errors.ErrorHandlerAborted.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ <h4>Hierarchy</h4>
<ul class="tsd-hierarchy">
<li><span class="target">ErrorHandlerAborted</span></li></ul></li></ul></section><aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/MatrixAI/js-rpc/blob/master/src/errors.ts#L111">src/errors.ts:111</a></li></ul></aside>
<li>Defined in <a href="https://github.com/MatrixAI/js-rpc/blob/master/src/errors.ts#L115">src/errors.ts:115</a></li></ul></aside>
<section class="tsd-panel-group tsd-index-group">
<section class="tsd-panel tsd-index-panel">
<details class="tsd-index-content tsd-index-accordion" open><summary class="tsd-accordion-summary tsd-index-summary">
Expand Down Expand Up @@ -109,7 +109,7 @@ <h3 class="tsd-anchor-link"><span>code</span><a href="#code" aria-label="Permali
<div class="tsd-signature"><span class="tsd-kind-property">code</span><span class="tsd-signature-symbol">:</span> <a href="../enums/errors.JSONRPCResponseErrorCode.html" class="tsd-signature-type tsd-kind-enum">JSONRPCResponseErrorCode</a><span class="tsd-signature-symbol"> = JSONRPCResponseErrorCode.HandlerAborted</span></div><aside class="tsd-sources">
<p>Overrides <a href="errors.ErrorRPCProtocol.html">ErrorRPCProtocol</a>.<a href="errors.ErrorRPCProtocol.html#code">code</a></p>
<ul>
<li>Defined in <a href="https://github.com/MatrixAI/js-rpc/blob/master/src/errors.ts#L113">src/errors.ts:113</a></li></ul></aside></section>
<li>Defined in <a href="https://github.com/MatrixAI/js-rpc/blob/master/src/errors.ts#L117">src/errors.ts:117</a></li></ul></aside></section>
<section class="tsd-panel tsd-member tsd-is-inherited tsd-is-external"><a id="data" class="tsd-anchor"></a>
<h3 class="tsd-anchor-link"><span>data</span><a href="#data" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="#icon-anchor"></use></svg></a></h3>
<div class="tsd-signature"><span class="tsd-kind-property">data</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type ">POJO</span></div>
Expand Down Expand Up @@ -152,13 +152,13 @@ <h3 class="tsd-anchor-link"><code class="tsd-tag ts-flagStatic">Static</code> <s
<div class="tsd-signature"><span class="tsd-kind-property">description</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> = &#39;Handler Aborted Stream&#39;</span></div><aside class="tsd-sources">
<p>Overrides <a href="errors.ErrorRPCProtocol.html">ErrorRPCProtocol</a>.<a href="errors.ErrorRPCProtocol.html#description">description</a></p>
<ul>
<li>Defined in <a href="https://github.com/MatrixAI/js-rpc/blob/master/src/errors.ts#L112">src/errors.ts:112</a></li></ul></aside></section>
<li>Defined in <a href="https://github.com/MatrixAI/js-rpc/blob/master/src/errors.ts#L116">src/errors.ts:116</a></li></ul></aside></section>
<section class="tsd-panel tsd-member tsd-is-inherited"><a id="error" class="tsd-anchor"></a>
<h3 class="tsd-anchor-link"><code class="tsd-tag ts-flagStatic">Static</code> <span>error</span><a href="#error" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="#icon-anchor"></use></svg></a></h3>
<div class="tsd-signature"><span class="tsd-kind-property">error</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> = &#39;RPC Protocol Error&#39;</span></div><aside class="tsd-sources">
<p>Inherited from <a href="errors.ErrorRPCProtocol.html">ErrorRPCProtocol</a>.<a href="errors.ErrorRPCProtocol.html#error">error</a></p>
<ul>
<li>Defined in <a href="https://github.com/MatrixAI/js-rpc/blob/master/src/errors.ts#L39">src/errors.ts:39</a></li></ul></aside></section>
<li>Defined in <a href="https://github.com/MatrixAI/js-rpc/blob/master/src/errors.ts#L43">src/errors.ts:43</a></li></ul></aside></section>
<section class="tsd-panel tsd-member tsd-is-inherited tsd-is-external"><a id="prepareStackTrace" class="tsd-anchor"></a>
<h3 class="tsd-anchor-link"><code class="tsd-tag ts-flagStatic">Static</code> <code class="tsd-tag ts-flagOptional">Optional</code> <span>prepare<wbr/>Stack<wbr/>Trace</span><a href="#prepareStackTrace" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="#icon-anchor"></use></svg></a></h3>
<div class="tsd-signature"><span class="tsd-kind-property">prepare<wbr/>Stack<wbr/>Trace</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">err</span>, <span class="tsd-kind-parameter">stackTraces</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol"> =&gt; </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">)</span></div>
Expand Down Expand Up @@ -215,7 +215,7 @@ <h4 class="tsd-returns-title">Returns <a href="../types/JSONRPCResponseError.htm
<div class="tsd-comment tsd-typography"></div><aside class="tsd-sources">
<p>Inherited from <a href="errors.ErrorRPCProtocol.html">ErrorRPCProtocol</a>.<a href="errors.ErrorRPCProtocol.html#toJSON">toJSON</a></p>
<ul>
<li>Defined in <a href="https://github.com/MatrixAI/js-rpc/blob/master/src/errors.ts#L74">src/errors.ts:74</a></li></ul></aside></li></ul></section>
<li>Defined in <a href="https://github.com/MatrixAI/js-rpc/blob/master/src/errors.ts#L78">src/errors.ts:78</a></li></ul></aside></li></ul></section>
<section class="tsd-panel tsd-member tsd-is-inherited tsd-is-external"><a id="captureStackTrace" class="tsd-anchor"></a>
<h3 class="tsd-anchor-link"><code class="tsd-tag ts-flagStatic">Static</code> <span>capture<wbr/>Stack<wbr/>Trace</span><a href="#captureStackTrace" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="#icon-anchor"></use></svg></a></h3>
<ul class="tsd-signatures tsd-is-inherited tsd-is-external">
Expand Down Expand Up @@ -260,7 +260,7 @@ <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type ">Instance
<div class="tsd-comment tsd-typography"></div><aside class="tsd-sources">
<p>Inherited from <a href="errors.ErrorRPCProtocol.html">ErrorRPCProtocol</a>.<a href="errors.ErrorRPCProtocol.html#fromJSON">fromJSON</a></p>
<ul>
<li>Defined in <a href="https://github.com/MatrixAI/js-rpc/blob/master/src/errors.ts#L42">src/errors.ts:42</a></li></ul></aside></li></ul></section></section></div>
<li>Defined in <a href="https://github.com/MatrixAI/js-rpc/blob/master/src/errors.ts#L46">src/errors.ts:46</a></li></ul></aside></li></ul></section></section></div>
<div class="col-sidebar">
<div class="page-menu">
<div class="tsd-navigation settings">
Expand Down Expand Up @@ -329,6 +329,7 @@ <h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="#icon
<li><a href="errors.ErrorRPCStopping.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-128"></use></svg><span>ErrorRPCStopping</span></a></li>
<li><a href="errors.ErrorRPCStreamEnded.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-128"></use></svg><span>ErrorRPCStream<wbr/>Ended</span></a></li>
<li><a href="errors.ErrorRPCTimedOut.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-128"></use></svg><span>ErrorRPCTimed<wbr/>Out</span></a></li>
<li><a href="errors.ErrorRPCUndefinedBehaviour.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-128"></use></svg><span>ErrorRPCUndefined<wbr/>Behaviour</span></a></li>
<li><a href="errors.ErrorRPCUnknown.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-128"></use></svg><span>ErrorRPCUnknown</span></a></li>
<li><a href="errors.ErrorUtilsUndefinedBehaviour.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-128"></use></svg><span>Error<wbr/>Utils<wbr/>Undefined<wbr/>Behaviour</span></a></li>
<li><a href="../variables/errors.rpcProtocolErrors.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><g id="icon-32"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-variable)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6"></rect><path d="M11.106 16L8.85 7.24H9.966L11.454 13.192C11.558 13.608 11.646 13.996 11.718 14.356C11.79 14.708 11.842 14.976 11.874 15.16C11.906 14.976 11.954 14.708 12.018 14.356C12.09 13.996 12.178 13.608 12.282 13.192L13.758 7.24H14.85L12.582 16H11.106Z" fill="var(--color-text)"></path></g></svg><span>rpc<wbr/>Protocol<wbr/>Errors</span></a></li></ul></div></details></li>
Expand Down
13 changes: 7 additions & 6 deletions docs/classes/errors.ErrorMissingCaller.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ <h4>Hierarchy</h4>
<ul class="tsd-hierarchy">
<li><span class="target">ErrorMissingCaller</span></li></ul></li></ul></section><aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/MatrixAI/js-rpc/blob/master/src/errors.ts#L102">src/errors.ts:102</a></li></ul></aside>
<li>Defined in <a href="https://github.com/MatrixAI/js-rpc/blob/master/src/errors.ts#L106">src/errors.ts:106</a></li></ul></aside>
<section class="tsd-panel-group tsd-index-group">
<section class="tsd-panel tsd-index-panel">
<details class="tsd-index-content tsd-index-accordion" open><summary class="tsd-accordion-summary tsd-index-summary">
Expand Down Expand Up @@ -109,7 +109,7 @@ <h3 class="tsd-anchor-link"><span>code</span><a href="#code" aria-label="Permali
<div class="tsd-signature"><span class="tsd-kind-property">code</span><span class="tsd-signature-symbol">:</span> <a href="../enums/errors.JSONRPCResponseErrorCode.html" class="tsd-signature-type tsd-kind-enum">JSONRPCResponseErrorCode</a><span class="tsd-signature-symbol"> = JSONRPCResponseErrorCode.MissingCaller</span></div><aside class="tsd-sources">
<p>Overrides <a href="errors.ErrorRPCProtocol.html">ErrorRPCProtocol</a>.<a href="errors.ErrorRPCProtocol.html#code">code</a></p>
<ul>
<li>Defined in <a href="https://github.com/MatrixAI/js-rpc/blob/master/src/errors.ts#L104">src/errors.ts:104</a></li></ul></aside></section>
<li>Defined in <a href="https://github.com/MatrixAI/js-rpc/blob/master/src/errors.ts#L108">src/errors.ts:108</a></li></ul></aside></section>
<section class="tsd-panel tsd-member tsd-is-inherited tsd-is-external"><a id="data" class="tsd-anchor"></a>
<h3 class="tsd-anchor-link"><span>data</span><a href="#data" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="#icon-anchor"></use></svg></a></h3>
<div class="tsd-signature"><span class="tsd-kind-property">data</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type ">POJO</span></div>
Expand Down Expand Up @@ -152,13 +152,13 @@ <h3 class="tsd-anchor-link"><code class="tsd-tag ts-flagStatic">Static</code> <s
<div class="tsd-signature"><span class="tsd-kind-property">description</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> = &#39;Caller is missing&#39;</span></div><aside class="tsd-sources">
<p>Overrides <a href="errors.ErrorRPCProtocol.html">ErrorRPCProtocol</a>.<a href="errors.ErrorRPCProtocol.html#description">description</a></p>
<ul>
<li>Defined in <a href="https://github.com/MatrixAI/js-rpc/blob/master/src/errors.ts#L103">src/errors.ts:103</a></li></ul></aside></section>
<li>Defined in <a href="https://github.com/MatrixAI/js-rpc/blob/master/src/errors.ts#L107">src/errors.ts:107</a></li></ul></aside></section>
<section class="tsd-panel tsd-member tsd-is-inherited"><a id="error" class="tsd-anchor"></a>
<h3 class="tsd-anchor-link"><code class="tsd-tag ts-flagStatic">Static</code> <span>error</span><a href="#error" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="#icon-anchor"></use></svg></a></h3>
<div class="tsd-signature"><span class="tsd-kind-property">error</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> = &#39;RPC Protocol Error&#39;</span></div><aside class="tsd-sources">
<p>Inherited from <a href="errors.ErrorRPCProtocol.html">ErrorRPCProtocol</a>.<a href="errors.ErrorRPCProtocol.html#error">error</a></p>
<ul>
<li>Defined in <a href="https://github.com/MatrixAI/js-rpc/blob/master/src/errors.ts#L39">src/errors.ts:39</a></li></ul></aside></section>
<li>Defined in <a href="https://github.com/MatrixAI/js-rpc/blob/master/src/errors.ts#L43">src/errors.ts:43</a></li></ul></aside></section>
<section class="tsd-panel tsd-member tsd-is-inherited tsd-is-external"><a id="prepareStackTrace" class="tsd-anchor"></a>
<h3 class="tsd-anchor-link"><code class="tsd-tag ts-flagStatic">Static</code> <code class="tsd-tag ts-flagOptional">Optional</code> <span>prepare<wbr/>Stack<wbr/>Trace</span><a href="#prepareStackTrace" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="#icon-anchor"></use></svg></a></h3>
<div class="tsd-signature"><span class="tsd-kind-property">prepare<wbr/>Stack<wbr/>Trace</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">err</span>, <span class="tsd-kind-parameter">stackTraces</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol"> =&gt; </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">)</span></div>
Expand Down Expand Up @@ -215,7 +215,7 @@ <h4 class="tsd-returns-title">Returns <a href="../types/JSONRPCResponseError.htm
<div class="tsd-comment tsd-typography"></div><aside class="tsd-sources">
<p>Inherited from <a href="errors.ErrorRPCProtocol.html">ErrorRPCProtocol</a>.<a href="errors.ErrorRPCProtocol.html#toJSON">toJSON</a></p>
<ul>
<li>Defined in <a href="https://github.com/MatrixAI/js-rpc/blob/master/src/errors.ts#L74">src/errors.ts:74</a></li></ul></aside></li></ul></section>
<li>Defined in <a href="https://github.com/MatrixAI/js-rpc/blob/master/src/errors.ts#L78">src/errors.ts:78</a></li></ul></aside></li></ul></section>
<section class="tsd-panel tsd-member tsd-is-inherited tsd-is-external"><a id="captureStackTrace" class="tsd-anchor"></a>
<h3 class="tsd-anchor-link"><code class="tsd-tag ts-flagStatic">Static</code> <span>capture<wbr/>Stack<wbr/>Trace</span><a href="#captureStackTrace" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="#icon-anchor"></use></svg></a></h3>
<ul class="tsd-signatures tsd-is-inherited tsd-is-external">
Expand Down Expand Up @@ -260,7 +260,7 @@ <h4 class="tsd-returns-title">Returns <span class="tsd-signature-type ">Instance
<div class="tsd-comment tsd-typography"></div><aside class="tsd-sources">
<p>Inherited from <a href="errors.ErrorRPCProtocol.html">ErrorRPCProtocol</a>.<a href="errors.ErrorRPCProtocol.html#fromJSON">fromJSON</a></p>
<ul>
<li>Defined in <a href="https://github.com/MatrixAI/js-rpc/blob/master/src/errors.ts#L42">src/errors.ts:42</a></li></ul></aside></li></ul></section></section></div>
<li>Defined in <a href="https://github.com/MatrixAI/js-rpc/blob/master/src/errors.ts#L46">src/errors.ts:46</a></li></ul></aside></li></ul></section></section></div>
<div class="col-sidebar">
<div class="page-menu">
<div class="tsd-navigation settings">
Expand Down Expand Up @@ -329,6 +329,7 @@ <h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="#icon
<li><a href="errors.ErrorRPCStopping.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-128"></use></svg><span>ErrorRPCStopping</span></a></li>
<li><a href="errors.ErrorRPCStreamEnded.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-128"></use></svg><span>ErrorRPCStream<wbr/>Ended</span></a></li>
<li><a href="errors.ErrorRPCTimedOut.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-128"></use></svg><span>ErrorRPCTimed<wbr/>Out</span></a></li>
<li><a href="errors.ErrorRPCUndefinedBehaviour.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-128"></use></svg><span>ErrorRPCUndefined<wbr/>Behaviour</span></a></li>
<li><a href="errors.ErrorRPCUnknown.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-128"></use></svg><span>ErrorRPCUnknown</span></a></li>
<li><a href="errors.ErrorUtilsUndefinedBehaviour.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-128"></use></svg><span>Error<wbr/>Utils<wbr/>Undefined<wbr/>Behaviour</span></a></li>
<li><a href="../variables/errors.rpcProtocolErrors.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><g id="icon-32"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-variable)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6"></rect><path d="M11.106 16L8.85 7.24H9.966L11.454 13.192C11.558 13.608 11.646 13.996 11.718 14.356C11.79 14.708 11.842 14.976 11.874 15.16C11.906 14.976 11.954 14.708 12.018 14.356C12.09 13.996 12.178 13.608 12.282 13.192L13.758 7.24H14.85L12.582 16H11.106Z" fill="var(--color-text)"></path></g></svg><span>rpc<wbr/>Protocol<wbr/>Errors</span></a></li></ul></div></details></li>
Expand Down
Loading
Loading