Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/stagas/alice-bob
transport agnostic strongly typed duplex rpc interfaces
https://github.com/stagas/alice-bob
duplex ipc message-passing networking remote-procedure-calls rpc strongly-typed transport-agnostic
Last synced: 13 days ago
JSON representation
transport agnostic strongly typed duplex rpc interfaces
- Host: GitHub
- URL: https://github.com/stagas/alice-bob
- Owner: stagas
- License: mit
- Created: 2021-11-07T19:13:44.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2022-07-30T15:05:58.000Z (over 2 years ago)
- Last Synced: 2024-09-18T16:55:41.676Z (about 2 months ago)
- Topics: duplex, ipc, message-passing, networking, remote-procedure-calls, rpc, strongly-typed, transport-agnostic
- Language: TypeScript
- Homepage:
- Size: 1.26 MB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
alice-bobtransport agnostic strongly typed duplex rpc interfaces
npm i alice-bob
pnpm add alice-bob
yarn add alice-bob
## API
#
Alice
– Alice class. src/alice-bob.ts#L292
# constructor
(send, target) – Creates an instance of Alice. src/alice-bob.ts#L297
# new Alice
() – Creates an instance of Alice.
local
– The local Agent. src/alice-bob.ts#L95 {
# debug
– Whether or not to log debugging information. src/alice-bob.ts#L32
boolean
name
– The name of the agent. Defaults to either 'alice' or 'bob' depending
on the constructor used, Alice or Bob. src/alice-bob.ts#L38
string
send
– The send method overriden by the user to any transport. src/alice-bob.ts#L43 PayloadMethod<Agent<B, A>>
deferredSend
() – Returns the send method. Used in contexts where it might
change between sessions, like browser refresh/hot/livereload. src/alice-bob.ts#L49
deferredSend() =>
PayloadMethod<Agent<B, A>>
deserializer
(data) src/alice-bob.ts#L57 # data
unknown
deserializer(data) =>
- any
log
(args) – Overridable logging function. Defaults to console.log()
and prepends agent.name
. src/alice-bob.ts#L63 # args
unknown []
log(args) =>
- void
serializer
(data) src/alice-bob.ts#L56 # data
unknown
serializer(data) =>
- any
# target
src/alice-bob.ts#L95
remote
– The remote Agent. src/alice-bob.ts#L99 # agents
(local, remote) – Returns the agents tuple [alice, bob]
. src/alice-bob.ts#L276
Example:
```ts
const [alice, bob] = new Alice().agents()
// to enable debugging on local (alice)
const [alice, bob] = new Alice().agents({ debug: true })
// use different names:
const [alice, bob] = new Alice().agents(
{ name: 'server', debug: true },
{ name: 'client' }
)
```
#
local
#
remote
agents(local, remote) =>
- [ {
# debug
– Whether or not to log debugging information. src/alice-bob.ts#L32
boolean
name
– The name of the agent. Defaults to either 'alice' or 'bob' depending
on the constructor used, Alice or Bob. src/alice-bob.ts#L38
string
send
– The send method overriden by the user to any transport. src/alice-bob.ts#L43 PayloadMethod<Agent<B, A>>
deferredSend
() – Returns the send method. Used in contexts where it might
change between sessions, like browser refresh/hot/livereload. src/alice-bob.ts#L49
deferredSend() =>
PayloadMethod<Agent<B, A>>
deserializer
(data) src/alice-bob.ts#L57 # data
unknown
deserializer(data) =>
- any
log
(args) – Overridable logging function. Defaults to console.log()
and prepends agent.name
. src/alice-bob.ts#L63 # args
unknown []
log(args) =>
- void
serializer
(data) src/alice-bob.ts#L56 # data
unknown
serializer(data) =>
- any
# target
src/alice-bob.ts#L95
deserializer
(data) src/alice-bob.ts#L108 # data
any
deserializer(data) =>
- any
serializer
(data) src/alice-bob.ts#L107 # data
any
serializer(data) =>
- any
AliceBob
– AliceBob class. src/alice-bob.ts#L82 # constructor
(send) – Creates an instance of AliceBob. src/alice-bob.ts#L114
# new AliceBob
() – Creates an instance of AliceBob.
local
– The local Agent. src/alice-bob.ts#L95 {
# debug
– Whether or not to log debugging information. src/alice-bob.ts#L32
boolean
name
– The name of the agent. Defaults to either 'alice' or 'bob' depending
on the constructor used, Alice or Bob. src/alice-bob.ts#L38
string
send
– The send method overriden by the user to any transport. src/alice-bob.ts#L43 PayloadMethod<Agent<B, A>>
deferredSend
() – Returns the send method. Used in contexts where it might
change between sessions, like browser refresh/hot/livereload. src/alice-bob.ts#L49
deferredSend() =>
PayloadMethod<Agent<B, A>>
deserializer
(data) src/alice-bob.ts#L57 # data
unknown
deserializer(data) =>
- any
log
(args) – Overridable logging function. Defaults to console.log()
and prepends agent.name
. src/alice-bob.ts#L63 # args
unknown []
log(args) =>
- void
serializer
(data) src/alice-bob.ts#L56 # data
unknown
serializer(data) =>
- any
# target
src/alice-bob.ts#L95
remote
– The remote Agent. src/alice-bob.ts#L99 # agents
(local, remote) – Returns the agents tuple [alice, bob]
. src/alice-bob.ts#L276
Example:
```ts
const [alice, bob] = new Alice().agents()
// to enable debugging on local (alice)
const [alice, bob] = new Alice().agents({ debug: true })
// use different names:
const [alice, bob] = new Alice().agents(
{ name: 'server', debug: true },
{ name: 'client' }
)
```
#
local
#
remote
agents(local, remote) =>
- [ {
# debug
– Whether or not to log debugging information. src/alice-bob.ts#L32
boolean
name
– The name of the agent. Defaults to either 'alice' or 'bob' depending
on the constructor used, Alice or Bob. src/alice-bob.ts#L38
string
send
– The send method overriden by the user to any transport. src/alice-bob.ts#L43 PayloadMethod<Agent<B, A>>
deferredSend
() – Returns the send method. Used in contexts where it might
change between sessions, like browser refresh/hot/livereload. src/alice-bob.ts#L49
deferredSend() =>
PayloadMethod<Agent<B, A>>
deserializer
(data) src/alice-bob.ts#L57 # data
unknown
deserializer(data) =>
- any
log
(args) – Overridable logging function. Defaults to console.log()
and prepends agent.name
. src/alice-bob.ts#L63 # args
unknown []
log(args) =>
- void
serializer
(data) src/alice-bob.ts#L56 # data
unknown
serializer(data) =>
- any
# target
src/alice-bob.ts#L95
deserializer
(data) src/alice-bob.ts#L108 # data
any
deserializer(data) =>
- any
serializer
(data) src/alice-bob.ts#L107 # data
any
serializer(data) =>
- any
Bob
– Bob class. src/alice-bob.ts#L313 # constructor
(send, target) – Creates an instance of Bob. src/alice-bob.ts#L318
local
– The local Agent. src/alice-bob.ts#L95 {
# debug
– Whether or not to log debugging information. src/alice-bob.ts#L32
boolean
name
– The name of the agent. Defaults to either 'alice' or 'bob' depending
on the constructor used, Alice or Bob. src/alice-bob.ts#L38
string
send
– The send method overriden by the user to any transport. src/alice-bob.ts#L43 PayloadMethod<Agent<B, A>>
deferredSend
() – Returns the send method. Used in contexts where it might
change between sessions, like browser refresh/hot/livereload. src/alice-bob.ts#L49
deferredSend() =>
PayloadMethod<Agent<B, A>>
deserializer
(data) src/alice-bob.ts#L57 # data
unknown
deserializer(data) =>
- any
log
(args) – Overridable logging function. Defaults to console.log()
and prepends agent.name
. src/alice-bob.ts#L63 # args
unknown []
log(args) =>
- void
serializer
(data) src/alice-bob.ts#L56 # data
unknown
serializer(data) =>
- any
# target
src/alice-bob.ts#L95
remote
– The remote Agent. src/alice-bob.ts#L99 # agents
(local, remote) – Returns the agents tuple [alice, bob]
. src/alice-bob.ts#L276
Example:
```ts
const [alice, bob] = new Alice().agents()
// to enable debugging on local (alice)
const [alice, bob] = new Alice().agents({ debug: true })
// use different names:
const [alice, bob] = new Alice().agents(
{ name: 'server', debug: true },
{ name: 'client' }
)
```
#
local
#
remote
agents(local, remote) =>
- [ {
# debug
– Whether or not to log debugging information. src/alice-bob.ts#L32
boolean
name
– The name of the agent. Defaults to either 'alice' or 'bob' depending
on the constructor used, Alice or Bob. src/alice-bob.ts#L38
string
send
– The send method overriden by the user to any transport. src/alice-bob.ts#L43 PayloadMethod<Agent<B, A>>
deferredSend
() – Returns the send method. Used in contexts where it might
change between sessions, like browser refresh/hot/livereload. src/alice-bob.ts#L49
deferredSend() =>
PayloadMethod<Agent<B, A>>
deserializer
(data) src/alice-bob.ts#L57 # data
unknown
deserializer(data) =>
- any
log
(args) – Overridable logging function. Defaults to console.log()
and prepends agent.name
. src/alice-bob.ts#L63 # args
unknown []
log(args) =>
- void
serializer
(data) src/alice-bob.ts#L56 # data
unknown
serializer(data) =>
- any
# target
src/alice-bob.ts#L95
deserializer
(data) src/alice-bob.ts#L108 # data
any
deserializer(data) =>
- any
serializer
(data) src/alice-bob.ts#L107 # data
any
serializer(data) =>
- any
Payload
– Payload. src/alice-bob.ts#L6 # args
– The arguments passed to the method. src/alice-bob.ts#L18
unknown []
id
– Payload id. src/alice-bob.ts#L10 number
method
– Method to call. src/alice-bob.ts#L14 keyof T
Agent
– Agent. src/alice-bob.ts#L28 {
# debug
– Whether or not to log debugging information. src/alice-bob.ts#L32
boolean
name
– The name of the agent. Defaults to either 'alice' or 'bob' depending
on the constructor used, Alice or Bob. src/alice-bob.ts#L38
string
send
– The send method overriden by the user to any transport. src/alice-bob.ts#L43 PayloadMethod<Agent<B, A>>
deferredSend
() – Returns the send method. Used in contexts where it might
change between sessions, like browser refresh/hot/livereload. src/alice-bob.ts#L49
deferredSend() =>
PayloadMethod<Agent<B, A>>
deserializer
(data) src/alice-bob.ts#L57 # data
unknown
deserializer(data) =>
- any
log
(args) – Overridable logging function. Defaults to console.log()
and prepends agent.name
. src/alice-bob.ts#L63 # args
unknown []
log(args) =>
- void
serializer
(data) src/alice-bob.ts#L56 # data
unknown
serializer(data) =>
- any
PayloadMethod
src/alice-bob.ts#L21
## Contributing
[Fork](https://github.com/stagas/alice-bob/fork) or [edit](https://github.dev/stagas/alice-bob) and submit a PR.
All contributions are welcome!
## License
MIT © 2022 [stagas](https://github.com/stagas)