Skip to content

Commit

Permalink
chore: update devdependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
wkillerud committed Mar 7, 2024
1 parent 856ff53 commit dafb96f
Show file tree
Hide file tree
Showing 12 changed files with 675 additions and 669 deletions.
25 changes: 7 additions & 18 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,21 +1,10 @@
{
"env": {
"es6": true,
"node": true
},
"extends": "airbnb-base",
"rules": {
"strict": [0, "global"],
"prefer-const": 1,
"indent": [1, 4],
"class-methods-use-this": [0],
"import/no-extraneous-dependencies": [0],
"arrow-body-style": [0, "always"],
"no-multiple-empty-lines": [0],
"no-underscore-dangle": [0],
"comma-dangle": [0],
"no-plusplus": [0],
"no-console": [0],
"new-cap": [0]
"extends": ["eslint:recommended", "plugin:prettier/recommended"],
"plugins": ["prettier"],
"env": { "es6": true, "node": true },
"parserOptions": {
"requireConfigFile": false,
"ecmaVersion": 2020,
"sourceType": "module"
}
}
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 20

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
node-version: [10.x, 18.x, 20.x]
node-version: [18.x, 20.x]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ tmp/**/*
*.log
package-lock.json
.nyc_output
.tap
16 changes: 13 additions & 3 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
{
"singleQuote": true,
"trailingComma": "all",
"tabWidth": 4
"singleQuote": false,
"trailingComma": "all",
"useTabs": true,
"printWidth": 120,
"overrides": [
{
"files": ["*.yml"],
"options": {
"tabWidth": 2,
"useTabs": false
}
}
]
}
46 changes: 23 additions & 23 deletions benchmark/benchmark.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
'use strict';
"use strict";

/* eslint no-unused-vars: "off", import/no-extraneous-dependencies: "off", no-console: "off" */
/* eslint no-unused-vars: "off" */

const benchmark = require('benchmark');
const Metric = require('..');
const benchmark = require("benchmark");
const Metric = require("..");

const suite = new benchmark.Suite();

const add = (name, fn) => {
suite.add(name, fn);
suite.add(name, fn);
};

/**
Expand All @@ -17,26 +17,26 @@ const add = (name, fn) => {

const now = Date.now();

add('new Metric() - Cached timestamp', () => {
const m = new Metric({
name: 'foo',
description: 'foo_bar',
timestamp: now,
});
add("new Metric() - Cached timestamp", () => {
const m = new Metric({
name: "foo",
description: "foo_bar",
timestamp: now,
});
});

add('new Metric() - Create timestamp', () => {
const m = new Metric({
name: 'foo',
description: 'foo_bar',
});
add("new Metric() - Create timestamp", () => {
const m = new Metric({
name: "foo",
description: "foo_bar",
});
});

suite
.on('cycle', (ev) => {
console.log(ev.target.toString());
if (ev.target.error) {
console.error(ev.target.error);
}
})
.run();
.on("cycle", (ev) => {
console.log(ev.target.toString());
if (ev.target.error) {
console.error(ev.target.error);
}
})
.run();
89 changes: 40 additions & 49 deletions lib/is.js
Original file line number Diff line number Diff line change
@@ -1,109 +1,100 @@
'use strict';
"use strict";

// Ref; https://github.com/OpenObservability/OpenMetrics/blob/9a6db2a94dcf8dd84dd08a221e1b323e2b279f08/proto/openmetrics_data_model.proto#L42
const REGEX_NAME = /^[a-zA-Z_:][a-zA-Z0-9_:]*$/;

const isString = (value) => {
return (typeof value === 'string');
return typeof value === "string";
};
module.exports.isString = isString;


const isEmptyString = (value) => {
return (value.trim().length === 0);
return value.trim().length === 0;
};
module.exports.isEmptyString = isEmptyString;


const notEmpty = (value) => {
if (value === undefined) {
return false;
}
if (value === undefined) {
return false;
}

if (value === null) {
return false;
}
if (value === null) {
return false;
}

if (isString(value) && isEmptyString(value)) {
return false;
}
if (isString(value) && isEmptyString(value)) {
return false;
}

return true;
return true;
};
module.exports.notEmpty = notEmpty;


const validName = (value) => {
return REGEX_NAME.test(value);
return REGEX_NAME.test(value);
};
module.exports.validName = validName;


const validType = (value) => {
return (value >= 0 && value <= 7);
return value >= 0 && value <= 7;
};
module.exports.validType = validType;


const validDescription = (value) => {
return isString(value) || value === null || value === undefined;
return isString(value) || value === null || value === undefined;
};
module.exports.validDescription = validDescription;


const validSource = (value) => {
return isString(value) || value === null || value === undefined;
return isString(value) || value === null || value === undefined;
};
module.exports.validSource = validSource;


const validTimestamp = (value) => {
return Number.isFinite(value) || value === null || value === undefined;
return Number.isFinite(value) || value === null || value === undefined;
};
module.exports.validTimestamp = validTimestamp;


const validValue = (value) => {
return Number.isFinite(value) || value === null || value === undefined;
return Number.isFinite(value) || value === null || value === undefined;
};
module.exports.validValue = validValue;


const validLabelValue = (value) => {
return typeof value === 'boolean' || Number.isFinite(value) || isString(value) || value === null || value === undefined;
return (
typeof value === "boolean" || Number.isFinite(value) || isString(value) || value === null || value === undefined
);
};
module.exports.validLabelValue = validLabelValue;


const validLabel = (value) => {
if (typeof value !== 'object') {
return false;
}
if (typeof value !== "object") {
return false;
}

if (!('name' in value) || !('value' in value)) {
return false;
}
if (!("name" in value) || !("value" in value)) {
return false;
}

if (!REGEX_NAME.test(value.name)) {
return false;
}
if (!REGEX_NAME.test(value.name)) {
return false;
}

return validLabelValue(value.value);
return validLabelValue(value.value);
};
module.exports.validLabel = validLabel;


const validLabels = (value) => {
if (!Array.isArray(value)) {
return false;
}
if (!Array.isArray(value)) {
return false;
}

if (value.length === 0) {
return true;
}
if (value.length === 0) {
return true;
}

const valid = value.filter(validLabel);
const valid = value.filter(validLabel);

return (value.length === valid.length);
return value.length === valid.length;
};
module.exports.validLabels = validLabels;
Loading

0 comments on commit dafb96f

Please sign in to comment.