
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
Q interfacing with Node.js. Supports decompression. Can deserialize all q data types (including guid) to JavaScript. Can serialize all JavaScript data types to q.
npm install node-q
var nodeq = require("node-q");
nodeq.connect({host: "localhost", port: 5000}, function(err, con) {
if (err) throw err;
console.log("connected");
// interact with con like demonstrated below
});
var nodeq = require("node-q");
nodeq.connect({host: "localhost", port: 5000, user: "user", password: "password"}, function(err, con) {
if (err) throw err;
console.log("connected");
// interact with con like demonstrated below
});
con.k("sum 1 2 3", function(err, res) {
if (err) throw err;
console.log("result", res); // 6
});
con.k("sum", [1, 2, 3], function(err, res) {
if (err) throw err;
console.log("result", res); // 6
});
con.k("cor", [1, 2, 3], [4, 5, 6], function(err, res) {
if (err) throw err;
console.log("result", res); // 1
});
con.ks("show 1 2 3", function(err) {
if (err) throw err;
});
con.ks("show", [1, 2, 3], function(err) {
if (err) throw err;
});
con.k(function(err, res) {
if (err) throw err;
console.log("result", res);
});
con.on("upd", function(table, data) {
console.log(table, data);
});
con.ks(".u.sub[`;`]", function(err) { // subscribe to all tables and all symbols
if (err) throw err;
});
con.close(function() {
console.log("con closed");
});
q has more data types than JavaScript. Therefore you need to know how types are converted.
| q type | JavaScript type | Null | +Infinity | -Infinity |
|---|---|---|---|---|
| boolean | Boolean | |||
| guid | String | Null | ||
| byte | Number | |||
| short | Number | Null | Infinity | -Infinity |
| int | Number | Null | Infinity | -Infinity |
| long | Number 5 | Null | Infinity | -Infinity |
| real | Number | Null | Infinity | -Infinity |
| float | Number | Null | Infinity | -Infinity |
| char | String | Null 4 | ||
| symbol | String | Null | ||
| timestamp | Date 1, 2 | Null | ||
| month | Date 2 | Null | ||
| date | Date 2 | Null | ||
| datetime | Date 2 | Null | ||
| timespan | Date 1, 2, 3 | Null | ||
| minute | Date 2, 3 | Null | ||
| second | Date 2, 3 | Null | ||
| time | Date 2, 3 | Null |
nanos2date deserialization during connect(params, cb) to get the nanoseconds timestamp as a plain Number.TZ=UTC node ... to run in UTC timezone. q doesn't know timezones.2000-01-01 in the Date object. Only evaluate the time part.emptyChar2null deserialization during connect(params, cb) to keep the empty char.long2number deserialization during connect(params, cb) to represent longs as long.js.q) (`a`b`c)!(1 2 3i)
becomes Object
{
a: 1,
b: 2,
c: 3
}
q) 1 2 3i
becomes Array
[1, 2, 3]
q) ([] sym:`a`b`c; size:(1 2 3i))
becomes Array of Object per row.
[
{sym: "a", size: 1},
{sym: "b", size: 2},
{sym: "c", size: 3}
]
You can disable flipTables during connect(params, cb) to get a table as an Object with an Array per column.
{
sym: ["a", "b", "c"],
size: [1, 2, 3]
}
| JavaScript type | q type |
|---|---|
| Boolean | boolean |
| String starting with ` | symbol |
| String | list[char] |
| Number | float |
| Date | datetime |
| Object | dict |
| Array[*] | list[*] |
| Null | unary primitive |
| Infinity | float |
| -Infinity | float |
If you want to explicitly serialize a JavaScript type as a q type you need to use the typed API.
Let's start with two examples:
con.k("type", nodeq.short(1), function(err, res) {
if (err) throw err;
console.log("result", res); // -5
});
con.k("type", nodeq.shorts([1, 2, 3]), function(err, res) {
if (err) throw err;
console.log("result", res); // 5
});
For every primitive type in q, this module exports a method to wrap the JavaScript value. You can also wrap a JavaScript array into a q type by appending an s to the primitive wrapper's name.
| q type | primitive wrapper | array wrapper |
|---|---|---|
| boolean | boolean(Boolean) | booleans(Array[Boolean]) |
| guid | guid(String) | guids(Array[String]) |
| byte | byte(Number) | bytes(Array[Number]) |
| short | short(Number) | shorts(Array[Number]) |
| int | int(Number) | ints(Array[Number]) |
| long | long(long) 1 | longs(Array[long]) 1 |
| real | real(Number) | reals(Array[Number]) |
| float | float(Number) | floats(Array[Number]) |
| char | char(String) | chars(Array[String]) |
| symbol | symbol(String) | symbols(Array[String]) |
| timestamp | timestamp(Date) | timestamps(Array[Date]) |
| month | month(Date) | months(Array[Date]) |
| date | date(Date) | dates(Array[Date]) |
| datetime | datetime(Date) | datetimes(Array[Date]) |
| timespan | timespan(Date) | timespans(Array[Date]) |
| minute | minute(Date) | minutes(Array[Date]) |
| second | second(Date) | seconds(Array[Date]) |
| time | time(Date) | times(Array[Date]) |
params: Object
host: String (e. g. "localhost")port: Number (e. g. 5000)user: String (optional)password: String (optional)socketNoDelay : Boolean (optional, see http://nodejs.org/api/net.html#net_socket_setnodelay_nodelay)socketTimeout: Number (optional, see http://nodejs.org/api/net.html#net_socket_settimeout_timeout_callback)nanos2date: Boolean (optional, default: true)flipTables: Boolean (optional, default: true)emptyChar2null: Boolean (optional, default: true)long2number: Boolean (optional, default: true)cb: Function(err, con)
err: Error or undefinedconn: Connection or undefinedThis is deprecated. Please use the new, mor flexible API above!
host: String (e. g. "localhost")port: Number (e. g. 5000)user: String (optional)password: String (optional)Is an EventEmitter.
Sync request/response.
s: Stringx: Object (optional)y: Object (optional)z: Object (optional)...: Object (optional)cb: Function(err, res)
err: Error or undefinedres: Object or undefinedAsync request.
s: Stringx: Object (optional)y: Object (optional)z: Object (optional)...: Object (optional)cb: Function(err)
err: Error or undefinedcb: Function(err) (optional)
err: Error or undefinedIf you use kdb+tick and subscribe like con.ks(".u.sub[;]", function(err) { throw err; }) you will receive all Updates via upd Event.
If the socket emit an error event.
err: ErrorIf the socket emit an end event.
If the socket emit a timeout event.
If the socket emit a close event.
had_error: Boolean (true if the socket had a transmission error)If you want to create a Pull-Request please make sure that make test runs without failures.
If you have a kdb+tick setup please also run make mochait.
make jshint
make mocha
Assumes a running q process on port 5000 with kdb+tick available in QHOME (QHOME=~/q ~/q/m32/q -p 5000)
make mochait
make circular
FAQs
Q interfacing with Node.js
The npm package node-q receives a total of 90 weekly downloads. As such, node-q popularity was classified as not popular.
We found that node-q demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.