WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit b7d509f

Browse files
committed
Migrate contents from monorepo
1 parent 373304e commit b7d509f

18 files changed

+826
-561
lines changed

.travis.yml

Lines changed: 0 additions & 15 deletions
This file was deleted.

README.md

Lines changed: 47 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
# enchannel-zmq-backend
2-
[![GitHub release](https://img.shields.io/badge/enchannel--zmq--backend-version--latest-blue.svg)](https://github.com/nteract/enchannel-zmq-backend/releases)
3-
[![enchannel spec version](https://img.shields.io/badge/enchannel%20spec-version%201.1-ff69b4.svg)](https://github.com/nteract/enchannel/releases)
4-
[![Greenkeeper badge](https://badges.greenkeeper.io/nteract/enchannel-zmq-backend.svg)](https://greenkeeper.io/)
5-
6-
:warning: :warning: Moved to the [nteract/nteract monorepo](https://github.com/nteract/nteract/tree/master/packages/enchannel-zmq-backend) :warning: :warning:
72

83
[**Installation**](#installation) | [**Usage**](#usage) |
94
[**Contributors and developers**](#contributors-and-developers) |
@@ -51,7 +46,13 @@ That's it. Functions for four channels; *simplicity in action*.
5146

5247
Prerequisite: [Node.js and npm](https://docs.npmjs.com/getting-started/installing-node)
5348

54-
`npm install enchannel-zmq-backend`
49+
You may use whichever package manager (`npm` or `yarn`) best suits your workflow. The `nteract` team internally uses `yarn`.
50+
51+
```bash
52+
npm install enchannel-zmq-backend
53+
# OR
54+
yarn add enchannel-zmq-backend
55+
```
5556

5657
## Usage
5758

@@ -100,6 +101,43 @@ const channels = createChannels(identity, runtimeConfig)
100101
const { shell, iopub, stdin, control } = channels;
101102
```
102103

104+
`enchannel-zmq-backend` also gives access to all of the `channels` via a
105+
single multipled channel exposed via `createMainChannel`.
106+
107+
```javascript
108+
import { createMainChannel } from 'enchannel-zmq-backend';
109+
```
110+
111+
Similar to the `createChannels` function, the `createMainChannel` function
112+
accepts both an identity and a runtime object.
113+
114+
```javascript
115+
const channel = createMainChannel(identity, runtimeConfig);
116+
```
117+
118+
Messages that are sent via the mutliplexed channel need to define a `type`
119+
property that outlines which channel they should be sent under.
120+
121+
```javascript
122+
const body = {
123+
header: {
124+
msg_id: `execute_9ed11a0f-707e-4f71-829c-a19b8ff8eed8`,
125+
username: "rgbkrk",
126+
session: "00000000-0000-0000-0000-000000000000",
127+
msg_type: "execute_request",
128+
version: "5.0"
129+
},
130+
content: {
131+
code: 'print("woo")',
132+
silent: false,
133+
store_history: true,
134+
user_expressions: {},
135+
allow_stdin: false
136+
}
137+
};
138+
const message = { type: "shell", body };
139+
```
140+
103141
`enchannel-zmq-backend` also offers four convenience functions to
104142
easily create the messaging channels for `control`, `stdin`, `iopub`,
105143
and `shell` :
@@ -220,17 +258,17 @@ Then, fork and clone this repo:
220258
```bash
221259
git clone https://github.com/nteract/enchannel-zmq-backend.git
222260
cd enchannel-zmq-backend
223-
npm install
261+
yarn
224262
```
225263
226264
Develop! We welcome new and first time contributors.
227265
228266
229267
## Learn more about nteract
230268
231-
- Visit our website http://nteract.io/.
269+
- Visit our website https://nteract.io/.
232270
- See our organization on GitHub https://github.com/nteract
233-
- Join us on [Slack](http://slack.nteract.in/) if you need help or have
271+
- Join us on [Slack](https://slack.nteract.io/) if you need help or have
234272
questions. If you have trouble creating an account, either
235273
email [email protected] or post an issue on GitHub.
236274

__mocks__/jmp.ts

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import { EventEmitter } from "events";
2+
import * as jmp from "jmp";
3+
4+
class Socket extends EventEmitter {
5+
throttle = false;
6+
7+
constructor(public type: any, public scheme: any, public key: any) {
8+
super();
9+
}
10+
11+
monitor() {}
12+
unmonitor() {}
13+
connect() {
14+
if (this.throttle) {
15+
setTimeout(() => this.emit("connect"), 0);
16+
} else {
17+
this.emit("connect");
18+
}
19+
}
20+
close() {}
21+
}
22+
23+
interface MessageProperties {
24+
idents: any[];
25+
header: object;
26+
parent_header: object;
27+
metadata: object;
28+
content: object;
29+
buffers: Uint8Array | null;
30+
}
31+
32+
class Message {
33+
idents: any[];
34+
header: object;
35+
parent_header: object;
36+
metadata: object;
37+
content: object;
38+
buffers: Uint8Array | null;
39+
40+
constructor(properties: Partial<MessageProperties>) {
41+
this.idents = (properties && properties.idents) || [];
42+
this.header = (properties && properties.header) || {};
43+
this.parent_header = (properties && properties.parent_header) || {};
44+
this.metadata = (properties && properties.metadata) || {};
45+
this.content = (properties && properties.content) || {};
46+
this.buffers = (properties && properties.buffers) || new Uint8Array();
47+
}
48+
}
49+
50+
export { Message, Socket };

0 commit comments

Comments
 (0)