TypeScript library for OpenCPU
Forked from https://github.com/NextCenturyCorporation/opencpu.js to make use of ES6 and TypeScript.
Installation
npm install --save opencpu-ts
Usage
import { OpenCPU } from 'opencpu-ts' |
Import the library |
const opencpu = new OpenCPU() |
Instantiate a new object |
await opencpu.setUrl('https://cloud.opencpu.org/ocpu/library/MASS/') |
Set the URL to the base package on the public server |
const session = await opencpu.call('print', {x: [1,2,3]}) |
Call print(x=list(1,2,3))
|
const returnValue = await session.getObject() |
Get the return value (note that print also returns the value) |
const consoleOutput = await session.get('stdout').then(response => response.text()) |
Read the console output |