chilin
v0.8.0
Published
javascript interface for chilin
Readme
chilin
A javascript Node.js package to interface with chilin.
Quick Start
Connect to a chili Process
const { ChiliConnection } = require("chilin");
const chili = new ChiliConnection({ port: 1800 });
chili.connect((err) => {
if (err) throw err;
console.log("connected");
// send query from here
});Connect to a TLS-protected chili Process
const { ChiliConnection } = require("chilin");
const chili = new ChiliConnection({ port: 1800, useTLS: true });
chili.connect((err) => {
if (err) throw err;
console.log("connected");
// send query from here
});Connect to a chili Process with Credentials
const { ChiliConnection } = require("chilin");
const chili = new ChiliConnection({
port: 1800,
user: "user",
password: "password",
});
chili.connect((err) => {
if (err) throw err;
console.log("connected");
// send query from here
});Send a Sync Query
chili.sync("sum range 10", (err, res) => {
if (err) throw err;
console.log("result: ", res);
// result: 45
});Send a Sync Function Call
chili.sync(["+", 3, 8], (err, res) => {
if (err) throw err;
console.log("result: ", res);
// result: 11
});Send an Async Query
chili.asyn("show 99", (err) => {
if (err) throw err;
});Send an Async Function Call
chili.asyn(["show", 99], (err) => {
if (err) throw err;
});Subscribe
chili.on("upd", (table, data) => {
console.log(table, data);
});
chili.sync("sub[`trade`quote]", (err, _res) => {
if (err) throw err;
});Close chili Connection
chili.close(() => {
console.log("closed");
});Data Types
Deserialization
Deserialization of i64/u64 and timestamp can be controlled by ChiliConnection arguments useBigInt and includeNanosecond.
Atom
| chili type | javascript type | | ---------- | -------------------------------------------------- | | boolean | Boolean | | u8 | Number | | i16 | Number | | i32 | Number | | i64 | if useBigInt is true then BigInt else Number | | f32 | Number | | f64 | Number | | string | String | | symbol | String | | date | Date | | time | String | | datetime | Date | | timestamp | if includeNanosecond is true then String else Date | | duration | String | | function | String |
Series (Vector)
| chili type | javascript type | | ----------- | ------------------------------------------------------ | | boolean | boolean[] | | u8 | number[] | | i8 | number[] | | i16 | number[] | | u16 | number[] | | i32 | number[] | | u32 | number[] | | i64 | if useBigInt is true then bigint[] else number[] | | u64 | if useBigInt is true then bigint[] else number[] | | f32 | number[] | | f64 | number[] | | date | Date[] | | time | string[] | | datetime | Date[] | | timestamp | if includeNanosecond is true then string[] else Date[] | | duration | string[] | | string | string[] | | categorical | string[] |
Collection
| chili type | javascript type | | ---------- | --------------- | | list | Array | | dict | Map | | dataframe | Table |
Serialization
Atom
| javascript type | chili type | | --------------- | -------------------------------- | | Boolean | boolean | | BigInt | i64 | | Number | i64 if isInteger(value) else f64 | | String | string | | Date | datetime | | null | null |
Collection
| javascript type | chili type | | ------------------- | ---------- | | Array | list | | Table(apache-arrow) | dataframe | | Map or Object | dict |
