trepo-webworker

0.10.0 • Public • Published

trepo-webworker-js

Starts a Trepo Server in a Web Worker.

Example

var worker = new Worker('/trepo-webworker.js');
 
worker.onmessage = function(e) {
  console.log(e.data);
  // Data will have 2 fields, id and payload.
}
 
// To start Trepo
worker.postMessage({
  id: '1234',
  cmd: 'start',
  payload: {
    repo: 'my-repo',
    vgraph: {
      //engine: 'level',
      name: 'testing'
    },
    xsearch: {
      prefix: 'testing'
    }
  }
});
 
// To make a request
worker.postMessage({
  id: '1234',
  cmd: 'request',
  payload: {
    method: 'GET',
    path: '/graph/info'
  }
});
 
// To Stop Trepo
worker.postMessage({
  id: '1234',
  cmd: 'stop',
  payload: {}
});

Usage

Each request sends an id, cmd, and payload. Each response includes an id and a payload.

Request

  • id - Used to match requests with responses (each response will include the id of the request).
  • cmd - One of start, stop, and request.
  • payload - The request payload.

Response

  • id - Used to match requests with responses.
  • payload - The response payload.

Package Sidebar

Install

npm i trepo-webworker

Weekly Downloads

1

Version

0.10.0

License

MIT

Last publish

Collaborators

  • jonnymbgood
  • justincy