Use more consistent spacing in objects literals

This commit is contained in:
Hornwitser committed 2020-06-17 20:53:18 +02:00
1 parent 29f066a191
commit b254e4189d
17 files changed
+66 -66

No files matched your search

+1 -1
View File
@@ -6,7 +6,7 @@ const jwt = require("jsonwebtoken");
const fs = require("fs-extra"); const fs = require("fs-extra");
const yargs = require("yargs"); const yargs = require("yargs");
const version = require("./package").version; const version = require("./package").version;
const asTable = require("as-table").configure({delimiter: " | "}); const asTable = require("as-table").configure({ delimiter: " | " });
const chalk = require("chalk"); const chalk = require("chalk");
const events = require("events"); const events = require("events");
+2 -2
View File
@@ -248,7 +248,7 @@ async function exportItems(server, modVersions, items) {
iconSheet.crop(0, 0, width, Math.ceil(pos / (width / size)) * size); iconSheet.crop(0, 0, width, Math.ceil(pos / (width / size)) * size);
return {iconSheet, itemData}; return { iconSheet, itemData };
} }
/** /**
@@ -338,7 +338,7 @@ async function exportData(server) {
throw new Error("No items got exported"); throw new Error("No items got exported");
} }
let {iconSheet, itemData} = await exportItems(server, modVersions, items); let { iconSheet, itemData } = await exportItems(server, modVersions, items);
let locale = await exportLocale(server, modVersions, modOrder, "en"); let locale = await exportLocale(server, modVersions, modOrder, "en");
// Free up the memory used by zip files loaded during the export. // Free up the memory used by zip files loaded during the export.
+1 -1
View File
@@ -282,7 +282,7 @@ async function patch(savePath, modules) {
root.file("clusterio.json", JSON.stringify(patchInfo, null, 4)); root.file("clusterio.json", JSON.stringify(patchInfo, null, 4));
// Write back the save // Write back the save
let stream = zip.generateNodeStream({compression: "DEFLATE"}); let stream = zip.generateNodeStream({ compression: "DEFLATE" });
let pipe = stream.pipe(fs.createWriteStream(savePath)); let pipe = stream.pipe(fs.createWriteStream(savePath));
await events.once(pipe, "finish"); await events.once(pipe, "finish");
} }
+1 -1
View File
@@ -17,7 +17,7 @@ module.exports = async function({
log("Generating SSL certificate with "+bits+" bits at "+sslCertPath); log("Generating SSL certificate with "+bits+" bits at "+sslCertPath);
let startNs = hrtime(); let startNs = hrtime();
let keypair = await util.promisify(forge.pki.rsa.generateKeyPair)({bits: bits, e: 0x10001}); let keypair = await util.promisify(forge.pki.rsa.generateKeyPair)({ bits: bits, e: 0x10001 });
log("Generated 2048bit keypair in: "+(Number(hrtime()-startNs) / 1e6)+" ms"); log("Generated 2048bit keypair in: "+(Number(hrtime()-startNs) / 1e6)+" ms");
startNs = hrtime(); startNs = hrtime();
+5 -5
View File
@@ -79,7 +79,7 @@ class Request extends Message {
if (forwardTo === "instance") { if (forwardTo === "instance") {
requestProperties = Object.assign( requestProperties = Object.assign(
{"instance_id": { type: "integer" }}, requestProperties { "instance_id": { type: "integer" }}, requestProperties
); );
} else if (forwardTo !== "master" && forwardTo !== null) { } else if (forwardTo !== "master" && forwardTo !== null) {
@@ -185,7 +185,7 @@ class Request extends Message {
response = {}; response = {};
} }
if (!this._responseValidator({ seq: 0, type: this.responseType, response})) { if (!this._responseValidator({ seq: 0, type: this.responseType, response })) {
console.error(this._responseValidator.errors); console.error(this._responseValidator.errors);
throw new Error(`Validation failed responding to ${this.requestType}`); throw new Error(`Validation failed responding to ${this.requestType}`);
} }
@@ -212,7 +212,7 @@ class Request extends Message {
*/ */
async send(link, data = {}) { async send(link, data = {}) {
// XXX validate link target/source? // XXX validate link target/source?
if (!this._requestValidator({ seq: 0, type: this.requestType, data})) { if (!this._requestValidator({ seq: 0, type: this.requestType, data })) {
console.error(this._requestValidator.errors); console.error(this._requestValidator.errors);
throw new Error(`Validation failed sending ${this.requestType}`); throw new Error(`Validation failed sending ${this.requestType}`);
} }
@@ -634,7 +634,7 @@ class Event extends Message {
if (forwardTo === "instance") { if (forwardTo === "instance") {
eventProperties = Object.assign( eventProperties = Object.assign(
{"instance_id": { type: "integer" }}, eventProperties { "instance_id": { type: "integer" }}, eventProperties
); );
} else if (forwardTo !== "master" && forwardTo !== null) { } else if (forwardTo !== "master" && forwardTo !== null) {
@@ -728,7 +728,7 @@ class Event extends Message {
* Sends the given event data over the link. * Sends the given event data over the link.
*/ */
send(link, data = {}) { send(link, data = {}) {
if (!this._eventValidator({ seq: 0, type: this.eventType, data})) { if (!this._eventValidator({ seq: 0, type: this.eventType, data })) {
console.error(this._eventValidator.errors); console.error(this._eventValidator.errors);
throw new Error(`Validation failed sending ${this.eventType}`); throw new Error(`Validation failed sending ${this.eventType}`);
} }
+3 -3
View File
@@ -685,7 +685,7 @@ class ControlConnection extends BaseConnection {
throw new errors.RequestError(`Instance with ID ${message.data.instance_id} does not exist`); throw new errors.RequestError(`Instance with ID ${message.data.instance_id} does not exist`);
} }
let {field, prop, value} = message.data; let { field, prop, value } = message.data;
instance.config.setProp(field, prop, value); instance.config.setProp(field, prop, value);
await this.updateInstanceConfig(instance); await this.updateInstanceConfig(instance);
} }
@@ -750,7 +750,7 @@ class ControlConnection extends BaseConnection {
// Start at 5 to leave space for future default roles // Start at 5 to leave space for future default roles
let id = Math.max(5, lastId+1); let id = Math.max(5, lastId+1);
db.roles.set(id, new users.Role({ id, ...message.data})); db.roles.set(id, new users.Role({ id, ...message.data }));
return { id }; return { id };
} }
@@ -951,7 +951,7 @@ class SlaveConnection extends BaseConnection {
} }
async playerEventEventHandler(message) { async playerEventEventHandler(message) {
let {instance_id, name, type} = message.data; let { instance_id, name, type } = message.data;
let user = db.users.get(name); let user = db.users.get(name);
if (!user) { if (!user) {
user = createUser(name); user = createUser(name);
+1 -1
View File
@@ -49,7 +49,7 @@ class neuralDole {
this.getRequestStats(name,5) this.getRequestStats(name,5)
); );
this.stats[name]=this.stats[name] || []; this.stats[name]=this.stats[name] || [];
this.stats[name].unshift({req:0,given:0});//stats[name][0] is the one we currently collect this.stats[name].unshift({ req:0,given:0 });//stats[name][0] is the one we currently collect
if (this.stats[name].length>10) this.stats[name].pop();//remove if too many samples in stats if (this.stats[name].length>10) this.stats[name].pop();//remove if too many samples in stats
this.dole[name] = magicData[0]; this.dole[name] = magicData[0];
+1 -1
View File
@@ -116,4 +116,4 @@ outputs[1]=sigmoid3(outputs[1]);
return [sigmoid0(outputs[0]),avg]; return [sigmoid0(outputs[0]),avg];
} }
module.exports = {Dose,Tick}; module.exports = { Dose,Tick };
+1 -1
View File
@@ -136,7 +136,7 @@ class MasterPlugin extends plugin.BaseMasterPlugin {
} else if (method === "dole") { } else if (method === "dole") {
for (let item of message.data.items) { for (let item of message.data.items) {
let count = dole.doleDivider({ let count = dole.doleDivider({
object: { name: item[0], count: item[1], instanceId, instanceName}, object: { name: item[0], count: item[1], instanceId, instanceName },
items: this.items, items: this.items,
logItemTransfers: this.master.config.get("subspace_storage.log_item_transfers"), logItemTransfers: this.master.config.get("subspace_storage.log_item_transfers"),
}); });
+1 -1
View File
@@ -1253,7 +1253,7 @@ function hashMods(instance, callback) {
return null; return null;
} else { } else {
return hashFile(instance.path("mods", name)).then(hash => ( return hashFile(instance.path("mods", name)).then(hash => (
{modName: name, hash: hash} { modName: name, hash: hash }
)); ));
} }
} }
+2 -2
View File
@@ -202,7 +202,7 @@ describe("Integration of Clusterio", function() {
await exec(`node clusterctl --config ${controlConfigPath} create-role --name temp --description "A temp role" --permissions core.control.connect`); await exec(`node clusterctl --config ${controlConfigPath} create-role --name temp --description "A temp role" --permissions core.control.connect`);
let result = await link.messages.listRoles.send(getControl()); let result = await link.messages.listRoles.send(getControl());
let role = result.list.find(role => role.name === "temp"); let role = result.list.find(role => role.name === "temp");
assert.deepEqual(role, { id: 5, name: "temp", description: "A temp role", permissions: ["core.control.connect"]}); assert.deepEqual(role, { id: 5, name: "temp", description: "A temp role", permissions: ["core.control.connect"] });
}); });
}); });
@@ -211,7 +211,7 @@ describe("Integration of Clusterio", function() {
await exec(`node clusterctl --config ${controlConfigPath} edit-role --role temp --name new --description "A new role" --permissions`); await exec(`node clusterctl --config ${controlConfigPath} edit-role --role temp --name new --description "A new role" --permissions`);
let result = await link.messages.listRoles.send(getControl()); let result = await link.messages.listRoles.send(getControl());
let role = result.list.find(role => role.name === "new"); let role = result.list.find(role => role.name === "new");
assert.deepEqual(role, { id: 5, name: "new", description: "A new role", permissions: []}); assert.deepEqual(role, { id: 5, name: "new", description: "A new role", permissions: [] });
}); });
}); });
+2 -2
View File
@@ -253,11 +253,11 @@ describe("lib/config/classes", function() {
new Error("Expected fields to be an object, not undefined") new Error("Expected fields to be an object, not undefined")
); );
assert.throws( assert.throws(
() => testInstance.update({ name: "test_group", fields: []}, false), () => testInstance.update({ name: "test_group", fields: [] }, false),
new Error("Expected fields to be an object, not array") new Error("Expected fields to be an object, not array")
); );
assert.throws( assert.throws(
() => testInstance.update({ name: "test_group", fields: null}, false), () => testInstance.update({ name: "test_group", fields: null }, false),
new Error("Expected fields to be an object, not null") new Error("Expected fields to be an object, not null")
); );
}); });
+15 -15
View File
@@ -20,7 +20,7 @@ describe("lib/database", function() {
it("should throw convert a map to an object", function() { it("should throw convert a map to an object", function() {
assert.deepEqual( assert.deepEqual(
database.mapToObject(new Map([["a", 1], ["b", true]])), database.mapToObject(new Map([["a", 1], ["b", true]])),
{"a": 1, "b": true} { "a": 1, "b": true }
); );
}); });
}); });
@@ -79,7 +79,7 @@ describe("lib/database", function() {
); );
assert.equal( assert.equal(
await fs.readFile(testFile, {encoding: "utf-8"}), await fs.readFile(testFile, { encoding: "utf-8" }),
'{\n "c": {},\n "d": "foo"\n}' '{\n "c": {},\n "d": "foo"\n}'
); );
}); });
@@ -121,7 +121,7 @@ describe("lib/database", function() {
it("should work on array JSON", async function() { it("should work on array JSON", async function() {
assert.deepEqual( assert.deepEqual(
await database.loadJsonArrayAsMap(path.join("test", "file", "json", "load_array_map.json")), await database.loadJsonArrayAsMap(path.join("test", "file", "json", "load_array_map.json")),
new Map([["a", {id: "a"}], ["b", {id: "b"}]]) new Map([["a", { id: "a" }], ["b", { id: "b" }]])
); );
}); });
@@ -149,11 +149,11 @@ describe("lib/database", function() {
await deleteTestFile(); await deleteTestFile();
await database.saveMapAsJsonArray( await database.saveMapAsJsonArray(
testFile, new Map([["c", {id: "c"}], ["d", {id: "d"}]]) testFile, new Map([["c", { id: "c" }], ["d", { id: "d" }]])
); );
assert.equal( assert.equal(
await fs.readFile(testFile, {encoding: "utf-8"}), await fs.readFile(testFile, { encoding: "utf-8" }),
'[\n {\n "id": "c"\n },\n {\n "id": "d"\n }\n]' '[\n {\n "id": "c"\n },\n {\n "id": "d"\n }\n]'
); );
}); });
@@ -167,18 +167,18 @@ describe("lib/database", function() {
}); });
it("should restore the passed serialized database", function() { it("should restore the passed serialized database", function() {
let items = new database.ItemDatabase({"a": 1, "b": 2}); let items = new database.ItemDatabase({ "a": 1, "b": 2 });
assert.deepEqual(items._items, new Map([["a", 1], ["b", 2]])); assert.deepEqual(items._items, new Map([["a", 1], ["b", 2]]));
}); });
it("should throw on invalid serialized database", function() { it("should throw on invalid serialized database", function() {
assert.throws( assert.throws(
() => new database.ItemDatabase({"a": NaN}), () => new database.ItemDatabase({ "a": NaN }),
new Error("count must be a number") new Error("count must be a number")
); );
assert.throws( assert.throws(
() => new database.ItemDatabase({"a": "a"}), () => new database.ItemDatabase({ "a": "a" }),
new Error("count must be a number") new Error("count must be a number")
); );
}); });
@@ -186,26 +186,26 @@ describe("lib/database", function() {
describe(".serialize()", function() { describe(".serialize()", function() {
it("should return a serialized database", function() { it("should return a serialized database", function() {
let items = new database.ItemDatabase({"a": 10}); let items = new database.ItemDatabase({ "a": 10 });
assert.deepEqual(items.serialize(), {"a": 10}); assert.deepEqual(items.serialize(), { "a": 10 });
}); });
it("should remove zero count entries", function() { it("should remove zero count entries", function() {
let items = new database.ItemDatabase({"a": 0}); let items = new database.ItemDatabase({ "a": 0 });
assert.deepEqual(items.serialize(), {}); assert.deepEqual(items.serialize(), {});
}); });
}); });
describe(".size", function() { describe(".size", function() {
it("should give an approximate size of the database", function() { it("should give an approximate size of the database", function() {
let items = new database.ItemDatabase({"a": 10}); let items = new database.ItemDatabase({ "a": 10 });
assert.equal(items.size, 1); assert.equal(items.size, 1);
}); });
}); });
describe(".getItemCount()", function() { describe(".getItemCount()", function() {
it("should return the count of the given item", function() { it("should return the count of the given item", function() {
let items = new database.ItemDatabase({"a": 10}); let items = new database.ItemDatabase({ "a": 10 });
assert.equal(items.getItemCount("a"), 10); assert.equal(items.getItemCount("a"), 10);
}); });
@@ -231,7 +231,7 @@ describe("lib/database", function() {
}); });
it("should add an existing item", function() { it("should add an existing item", function() {
let items = new database.ItemDatabase({"a": 10}); let items = new database.ItemDatabase({ "a": 10 });
items.addItem("a", 10); items.addItem("a", 10);
assert.deepEqual(items._items, new Map([["a", 20]])); assert.deepEqual(items._items, new Map([["a", 20]]));
}); });
@@ -259,7 +259,7 @@ describe("lib/database", function() {
describe(".removeItem()", function() { describe(".removeItem()", function() {
it("should remove an existing item", function() { it("should remove an existing item", function() {
let items = new database.ItemDatabase({"a": 20}); let items = new database.ItemDatabase({ "a": 20 });
items.removeItem("a", 10); items.removeItem("a", 10);
assert.deepEqual(items._items, new Map([["a", 10]])); assert.deepEqual(items._items, new Map([["a", 10]]));
}); });
+1 -1
View File
@@ -213,7 +213,7 @@ describe("lib/factorio", function() {
let zip = new jszip(); let zip = new jszip();
zip.file("world/control.lua", "-- unknown\n"); zip.file("world/control.lua", "-- unknown\n");
let zipPath = path.join("temp", "test", "patch.zip"); let zipPath = path.join("temp", "test", "patch.zip");
await fs.outputFile(zipPath, await zip.generateAsync({type: "nodebuffer"})); await fs.outputFile(zipPath, await zip.generateAsync({ type: "nodebuffer" }));
await assert.rejects( await assert.rejects(
factorio.patch(zipPath, []), factorio.patch(zipPath, []),
+4 -4
View File
@@ -24,7 +24,7 @@ describe("lib/link/messages", function() {
describe("constructor", function() { describe("constructor", function() {
it("should throw on invalid forwardTo", function() { it("should throw on invalid forwardTo", function() {
assert.throws( assert.throws(
() => new link.Request({ links: [], forwardTo: "invalid"}), () => new link.Request({ links: [], forwardTo: "invalid" }),
new Error("Invalid forwardTo value invalid") new Error("Invalid forwardTo value invalid")
); );
}); });
@@ -87,7 +87,7 @@ describe("lib/link/messages", function() {
}; };
assert.deepEqual( assert.deepEqual(
await testRequest.send(testSourceLink, { test: "request" }), await testRequest.send(testSourceLink, { test: "request" }),
{ type: "test_response", request: { type: "test_request", data: {test: "request" }}} { type: "test_response", request: { type: "test_request", data: { test: "request" }}}
); );
delete testSourceLink.connector.send; delete testSourceLink.connector.send;
delete testSourceLink.waitFor; delete testSourceLink.waitFor;
@@ -117,13 +117,13 @@ describe("lib/link/messages", function() {
describe("constructor", function() { describe("constructor", function() {
it("should throw on invalid forwardTo", function() { it("should throw on invalid forwardTo", function() {
assert.throws( assert.throws(
() => new link.Event({ forwardTo: "invalid"}), () => new link.Event({ forwardTo: "invalid" }),
new Error("Invalid forwardTo value invalid") new Error("Invalid forwardTo value invalid")
); );
}); });
it("should throw on invalid broadcastTo", function() { it("should throw on invalid broadcastTo", function() {
assert.throws( assert.throws(
() => new link.Event({ broadcastTo: "invalid"}), () => new link.Event({ broadcastTo: "invalid" }),
new Error("Invalid broadcastTo value invalid") new Error("Invalid broadcastTo value invalid")
); );
}); });
+1 -1
View File
@@ -23,7 +23,7 @@ describe("objectOps.js", function(){
});*/ });*/
describe("objectOps.deepclone()", function(){ describe("objectOps.deepclone()", function(){
it("deep clones javascript objects", function(){ it("deep clones javascript objects", function(){
var obj1 = {hello:"world", cat:{legs:4, name:"Kitty", colors:["brown", "yellow", "purple"]}}; var obj1 = { hello:"world", cat:{ legs:4, name:"Kitty", colors:["brown", "yellow", "purple"] }};
var obj2 = {}; var obj2 = {};
obj2 = objectOps.deepclone(obj1); obj2 = objectOps.deepclone(obj1);
+24 -24
View File
@@ -258,15 +258,15 @@ describe("lib/prometheus", function() {
}); });
it("should require all labels set at creation", function() { it("should require all labels set at creation", function() {
assert.throws( assert.throws(
() => gauge.labels({a: "1"}), () => gauge.labels({ a: "1" }),
new Error("Missing label 'b'") new Error("Missing label 'b'")
); );
assert.throws( assert.throws(
() => gauge.labels({b: "1"}), () => gauge.labels({ b: "1" }),
new Error("Missing label 'a'") new Error("Missing label 'a'")
); );
assert.throws( assert.throws(
() => gauge.labels({a: "1", b: "2", c: "3"}), () => gauge.labels({ a: "1", b: "2", c: "3" }),
new Error("Extra label 'c'") new Error("Extra label 'c'")
); );
assert.throws( assert.throws(
@@ -280,7 +280,7 @@ describe("lib/prometheus", function() {
}); });
it("should throw if label value is not a string", function() { it("should throw if label value is not a string", function() {
assert.throws( assert.throws(
() => gauge.labels({a: "1", b: 2}), () => gauge.labels({ a: "1", b: 2 }),
new Error("Expected value for label 'b' to be a string") new Error("Expected value for label 'b' to be a string")
); );
assert.throws( assert.throws(
@@ -289,13 +289,13 @@ describe("lib/prometheus", function() {
); );
}); });
it("should initialize a value for the label set", function() { it("should initialize a value for the label set", function() {
gauge.labels({ a: "1", b: "2"}); gauge.labels({ a: "1", b: "2" });
assert(gauge._values.has('a="1",b="2"'), "value was not set"); assert(gauge._values.has('a="1",b="2"'), "value was not set");
gauge.labels("4", "5"); gauge.labels("4", "5");
assert(gauge._values.has('a="4",b="5"'), "value was not set"); assert(gauge._values.has('a="4",b="5"'), "value was not set");
}); });
it("should return a child supporting the usual methods", function() { it("should return a child supporting the usual methods", function() {
let child = gauge.labels({ a: "1", b: "2"}); let child = gauge.labels({ a: "1", b: "2" });
child.get(); child.get();
child.inc(); child.inc();
child.dec(); child.dec();
@@ -316,8 +316,8 @@ describe("lib/prometheus", function() {
let gauge = new prometheus.Gauge( let gauge = new prometheus.Gauge(
"test", "Help", { register: false, labels: ["a", "b"] } "test", "Help", { register: false, labels: ["a", "b"] }
); );
gauge.labels({ a: "1", b: "2"}); gauge.labels({ a: "1", b: "2" });
gauge.remove({ a: "1", b: "2"}); gauge.remove({ a: "1", b: "2" });
assert(!gauge._values.has('a="1",b="2"'), "value was not removed"); assert(!gauge._values.has('a="1",b="2"'), "value was not removed");
}); });
it("should throw when removing the empty label set", function() { it("should throw when removing the empty label set", function() {
@@ -335,7 +335,7 @@ describe("lib/prometheus", function() {
gauge.labels("1", "2"); gauge.labels("1", "2");
gauge.labels("1", "3"); gauge.labels("1", "3");
gauge.labels("4", "6"); gauge.labels("4", "6");
gauge.removeAll({a: "1"}); gauge.removeAll({ a: "1" });
assert(gauge._values.size <= 1, "Matching labels remained"); assert(gauge._values.size <= 1, "Matching labels remained");
assert( assert(
gauge._values.has('a="4",b="6"'), gauge._values.has('a="4",b="6"'),
@@ -353,7 +353,7 @@ describe("lib/prometheus", function() {
"test", "Help", { register: false, labels: ["a", "b"] } "test", "Help", { register: false, labels: ["a", "b"] }
); );
gauge.labels('x\\\\\n\"\"\n\\', "2"); gauge.labels('x\\\\\n\"\"\n\\', "2");
gauge.removeAll({a: 'x\\\\\n\"\"\n\\'}); gauge.removeAll({ a: 'x\\\\\n\"\"\n\\' });
assert(gauge._values.size === 0, "Matching labels remained"); assert(gauge._values.size === 0, "Matching labels remained");
}); });
}); });
@@ -362,9 +362,9 @@ describe("lib/prometheus", function() {
let gauge = new prometheus.Gauge( let gauge = new prometheus.Gauge(
"test", "Help", { register: false, labels: ["a", "b"] } "test", "Help", { register: false, labels: ["a", "b"] }
); );
gauge.labels({ a: "1", b: "2"}); gauge.labels({ a: "1", b: "2" });
gauge.labels({ a: "3", b: "4"}); gauge.labels({ a: "3", b: "4" });
gauge.labels({ a: "5", b: "6"}); gauge.labels({ a: "5", b: "6" });
gauge.clear(); gauge.clear();
assert(gauge._values.size == 0, "values was not cleared"); assert(gauge._values.size == 0, "values was not cleared");
}); });
@@ -485,10 +485,10 @@ describe("lib/prometheus", function() {
it("should format labeled metrics", async function() { it("should format labeled metrics", async function() {
let registry = new prometheus.CollectorRegistry(); let registry = new prometheus.CollectorRegistry();
let gauge = new prometheus.Gauge( let gauge = new prometheus.Gauge(
"test", "Help", { register: false, labels: ["a", "b"]} "test", "Help", { register: false, labels: ["a", "b"] }
); );
gauge.labels({a: "1", b: "2"}); gauge.labels({ a: "1", b: "2" });
gauge.labels({b: "y", a: "x"}); gauge.labels({ b: "y", a: "x" });
registry.register(gauge); registry.register(gauge);
let exposition = await prometheus.exposition(registry.collect()); let exposition = await prometheus.exposition(registry.collect());
assert.equal( assert.equal(
@@ -502,11 +502,11 @@ describe("lib/prometheus", function() {
it("should format Infinity and NaN", async function() { it("should format Infinity and NaN", async function() {
let registry = new prometheus.CollectorRegistry(); let registry = new prometheus.CollectorRegistry();
let gauge = new prometheus.Gauge( let gauge = new prometheus.Gauge(
"test", "Help", { register: false, labels: ["n"]} "test", "Help", { register: false, labels: ["n"] }
); );
gauge.labels({n: "1"}).set(Infinity); gauge.labels({ n: "1" }).set(Infinity);
gauge.labels({n: "2"}).set(-Infinity); gauge.labels({ n: "2" }).set(-Infinity);
gauge.labels({n: "3"}).set(NaN); gauge.labels({ n: "3" }).set(NaN);
registry.register(gauge); registry.register(gauge);
let exposition = await prometheus.exposition(registry.collect()); let exposition = await prometheus.exposition(registry.collect());
assert.equal( assert.equal(
@@ -542,7 +542,7 @@ describe("lib/prometheus", function() {
samples: new Map([["", 2]]), samples: new Map([["", 2]]),
}, { addLabels: { c: "8" }}), }, { addLabels: { c: "8" }}),
{ {
metric: {type: "type", name: "name", help: "Help", labels: ["c"]}, metric: { type: "type", name: "name", help: "Help", labels: ["c"] },
samples: [['c="8"', 2]], samples: [['c="8"', 2]],
} }
); );
@@ -552,7 +552,7 @@ describe("lib/prometheus", function() {
samples: new Map([['a="4"', 3]]), samples: new Map([['a="4"', 3]]),
}, { addLabels: { c: "8" }}), }, { addLabels: { c: "8" }}),
{ {
metric: {type: "type", name: "name", help: "Help", labels: ["a", "c"]}, metric: { type: "type", name: "name", help: "Help", labels: ["a", "c"] },
samples: [['a="4",c="8"', 3]], samples: [['a="4",c="8"', 3]],
} }
); );
@@ -564,7 +564,7 @@ describe("lib/prometheus", function() {
samples: new Map([["", 2]]), samples: new Map([["", 2]]),
}, { metricName: "new", }), }, { metricName: "new", }),
{ {
metric: {type: "type", name: "new", help: "Help", labels: []}, metric: { type: "type", name: "new", help: "Help", labels: [] },
samples: [["", 2]], samples: [["", 2]],
} }
); );
@@ -574,7 +574,7 @@ describe("lib/prometheus", function() {
samples: new Map([["", 2]]), samples: new Map([["", 2]]),
}, { metricHelp: "old", }), }, { metricHelp: "old", }),
{ {
metric: {type: "type", name: "name", help: "old", labels: []}, metric: { type: "type", name: "name", help: "old", labels: [] },
samples: [["", 2]], samples: [["", 2]],
} }
); );