Skip to content

Commit

Permalink
Merge pull request #469 from jpmorganchase/remote-api-update
Browse files Browse the repository at this point in the history
Update remote API to accept a `perspective.table()`
  • Loading branch information
texodus authored Mar 6, 2019
2 parents 0b6523c + 5bbb2c7 commit 487068b
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
5 changes: 3 additions & 2 deletions docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,8 @@ In Node.js:

```javascript
const {
WebSocketHost
WebSocketHost,
table
} = require("@jpmorganchase/perspective/build/perspective.node.js");
const fs = require("fs");

Expand All @@ -434,7 +435,7 @@ const host = new WebSocketHost({ assets: [__dirname], port: 8080 });

// Read an arrow file from the file system and load it as a named data source.
const arr = fs.readFileSync(__dirname + "/superstore.arrow");
host.open("data_source_one", arr);
host.open("data_source_one", table(arr));
```

In the browser:
Expand Down
8 changes: 4 additions & 4 deletions examples/cli/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*
*/

const {WebSocketHost} = require("@jpmorganchase/perspective/build/perspective.node.js");
const {WebSocketHost, table} = require("@jpmorganchase/perspective/build/perspective.node.js");
const exec = require("child_process").exec;

const OPEN = `
Expand Down Expand Up @@ -45,16 +45,16 @@ process.stdin
.on("end", function() {
const buf = Buffer.concat(ret, len);
if (buf.slice(0, 6).toString() === "ARROW1") {
host.open("data_source_one", buf.buffer);
host.open("data_source_one", table(buf.buffer));
console.log("Loaded Arrow");
} else {
let text = buf.toString();
try {
let json = JSON.parse(text);
host.open("data_source_one", json);
host.open("data_source_one", table(json));
console.log("Loaded JSON");
} catch (e) {
host.open("data_source_one", text);
host.open("data_source_one", table(text));
console.log("Loaded CSV");
}
}
Expand Down
4 changes: 2 additions & 2 deletions examples/git_history/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*
*/

const {WebSocketHost} = require("@jpmorganchase/perspective");
const {WebSocketHost, table} = require("@jpmorganchase/perspective");
const exec = require("child_process").exec;

function execute(command, callback) {
Expand All @@ -18,5 +18,5 @@ function execute(command, callback) {

execute(`git log --date=iso --pretty=format:'"%h","%an","%aD","%s","%ae"'`, log => {
const host = new WebSocketHost({assets: [__dirname]});
host.open("data_source_one", "Hash,Name,Date,Message,Email\n" + log);
host.open("data_source_one", table("Hash,Name,Date,Message,Email\n" + log));
});
4 changes: 2 additions & 2 deletions packages/perspective/src/js/perspective.node.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ class WebSocketHost extends module.exports.Host {
delete this.REQS[msg.id];
}

open(name, data, options) {
this._tables[name] = module.exports.table(data, options);
open(name, table) {
this._tables[name] = table;
}

close() {
Expand Down

0 comments on commit 487068b

Please sign in to comment.