Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modernize dependencies #1

Merged
merged 1 commit into from
Dec 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"presets": ["es2015"]
"presets": ["@babel/preset-env"],
"plugins": ["istanbul"]
}
4 changes: 3 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module.exports = {
extends: 'airbnb',
extends: 'airbnb-base',
plugins: ['babel'],
parser: "@babel/eslint-parser",
rules: {
indent: ['error', 4, {SwitchCase: 1}], // 4 is more readable than 2
quotes: [2, 'single', 'avoid-escape'],
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ docs/gen
coverage
npm-debug.log
coverage
.nyc_output
.vscode
3 changes: 3 additions & 0 deletions .nycrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "@istanbuljs/nyc-config-babel"
}
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ node_js:
- '5'
- '6'
- '7'
before_install:
- npm install -g gulp
- 'lts/*'
script:
- npm run lint
- npm run test
Expand Down
97 changes: 0 additions & 97 deletions gulpfile.js

This file was deleted.

1 change: 0 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

'use strict';


Object.defineProperty(exports, '__esModule', {
value: true
});
Expand Down
24 changes: 24 additions & 0 deletions jsdocConfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"tags": {
"allowUnknownTags": true
},
"opts": {
"destination": "./docs/gen"
},
"plugins": [
"plugins/markdown"
],
"templates": {
"systemName": "latency-monitor",
"cleverLinks": false,
"monospaceLinks": false,
"default": {
"outputSourceFiles": true
},
"path": "ink-docstrap",
"theme": "cerulean",
"navType": "vertical",
"linenums": true,
"dateFormat": "MMMM Do YYYY, h:mm:ss a"
}
}
63 changes: 31 additions & 32 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,17 @@
},
"homepage": "https://github.com/mlucool/latency-monitor#readme",
"scripts": {
"lint": "gulp lint",
"test": "gulp test",
"build": "npm run build-src && npm run build-web && npm run build-doc",
"build-src": "babel -d dist src",
"build-web": "webpack",
"build-doc": "jsdoc -c jsdocConfig.json -P package.json -R README.md src/",
"lint": "eslint src/**/*.js *.js test/**/*.js",
"test": "nyc mocha -r @babel/register test/**/*_spec.js",
"preversion": "echo \"Another version! Keep up the good work!\"",
"version": "",
"postversion": "git push && git push --tags",
"prepublish": "gulp default",
"coveralls": "gulp test && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js"
"prepublish": "npm run build",
"coveralls": "nyc report --reporter=text-lcov | coveralls"
},
"keywords": [
"javascript",
Expand All @@ -43,35 +47,30 @@
],
"license": "Apache-2.0",
"dependencies": {
"debug": "^2.6.0",
"lodash": "^4.17.4"
"debug": "^4.3.1",
"lodash": "^4.17.20"
},
"devDependencies": {
"babel-cli": "^6.3.15",
"babel-core": "^6.3.15",
"babel-eslint": "^7.1.1",
"babel-loader": "^6.2.10",
"babel-preset-es2015": "^6.22.0",
"chai": "^3.4.1",
"coveralls": "^2.11.6",
"eslint": "^3.15.0",
"eslint-config-airbnb": "^14.1.0",
"eslint-plugin-babel": "^4.0.1",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-jsx-a11y": "^4.0.0",
"eslint-plugin-react": "^6.10.0",
"gulp": "^3.9.0",
"gulp-babel": "^6.1.1",
"gulp-eslint": "^3.0.1",
"gulp-istanbul": "^1.1.1",
"gulp-jsdoc3": "^1.0.1",
"gulp-mocha": "^3.0.1",
"gulp-sourcemaps": "^2.4.0",
"gulp-util": "^3.0.8",
"isparta": "^4.0.0",
"mocha": "^3.2.0",
"pre-commit": "^1.1.2",
"run-sequence": "^1.1.5",
"webpack": "^2.2.1"
"@babel/cli": "^7.12.8",
"@babel/core": "^7.12.9",
"@babel/eslint-parser": "^7.12.1",
"@babel/eslint-plugin": "^7.12.1",
"@babel/preset-env": "^7.12.7",
"@babel/register": "^7.12.1",
"@istanbuljs/nyc-config-babel": "^3.0.0",
"babel-loader": "^8.2.2",
"babel-plugin-istanbul": "^6.0.0",
"chai": "^4.2.0",
"coveralls": "^3.1.0",
"eslint": "^7.15.0",
"eslint-config-airbnb-base": "14.2.1",
"eslint-plugin-babel": "^5.3.1",
"eslint-plugin-import": "^2.22.1",
"jsdoc": "^3.6.6",
"mocha": "^8.2.1",
"nyc": "^15.1.0",
"pre-commit": "^1.2.2",
"webpack": "^5.10.0",
"webpack-cli": "^4.2.0"
}
}
7 changes: 4 additions & 3 deletions src/LatencyMonitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ class LatencyMonitor extends EventEmitter {
* @param {function} [asyncTestFn] What cb-style async function to use
* @param {Number} [latencyRandomPercentage=5] What percent (+/-) of latencyCheckIntervalMs should we randomly use? This helps avoid alignment to other events.
*/
constructor({latencyCheckIntervalMs, dataEmitIntervalMs, asyncTestFn, latencyRandomPercentage} = {}) {
constructor({
latencyCheckIntervalMs, dataEmitIntervalMs, asyncTestFn, latencyRandomPercentage
} = {}) {
super();
const that = this;

Expand Down Expand Up @@ -179,7 +181,6 @@ class LatencyMonitor extends EventEmitter {
// Randomness is needed to avoid alignment by accident to regular things in the event loop
const randomness = (Math.random() * that._latecyCheckMultiply) - that._latecyCheckSubtract;


// We use this to ensure that in case some overlap somehow, we don't take the wrong startTime/offset
const localData = {
deltaOffset: Math.ceil(that.latencyCheckIntervalMs + randomness),
Expand All @@ -192,7 +193,7 @@ class LatencyMonitor extends EventEmitter {
return;
}
const deltaMS = that.getDeltaMS(localData.startTime) - localData.deltaOffset;
that._checkLatency(); // Start again ASAP
that._checkLatency(); // Start again ASAP

// Add the data point. If this gets complex, refactor it
that._latencyData.events++;
Expand Down
5 changes: 2 additions & 3 deletions src/VisibilityChangeEmitter.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ const debug = require('debug')('latency-monitor:VisibilityChangeEmitter');
* @class VisibilityChangeEmitter
*/
export default class VisibilityChangeEmitter extends EventEmitter {

/**
* Creates a VisibilityChangeEmitter
*/
Expand Down Expand Up @@ -77,8 +76,8 @@ export default class VisibilityChangeEmitter extends EventEmitter {
* @private
*/
_addVisibilityChangeListener() {
if (typeof document.addEventListener === 'undefined' ||
typeof document[this._hidden] === 'undefined') {
if (typeof document.addEventListener === 'undefined'
|| typeof document[this._hidden] === 'undefined') {
debug('Checking page visibility requires a browser that supports the Page Visibility API.');
} else {
// Handle page visibility change
Expand Down
1 change: 0 additions & 1 deletion test/VisibilityChangeEmitter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ describe('VisibilityChangeEmitter', () => {
};
global.document[hiddenName] = false;


const vce = new VisibilityChangeEmitter();
expect(name).to.eql(visibilityName); // Registers right callback name
let first = true;
Expand Down
38 changes: 12 additions & 26 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
// Based very loosely on https://www.reactstarterkit.com/

import path from 'path';
import webpack from 'webpack';
const path = require('path');
const webpack = require('webpack');

const isDebug = process.env.NODE_ENV === 'production';

const config = {
module.exports = {
mode: isDebug ? 'development' : 'production',
context: path.resolve(__dirname, 'src'),

entry: path.resolve(__dirname, 'src/EventLoopPrinter.js'),
Expand All @@ -19,20 +20,19 @@ const config = {
rules: [
{
test: /\.js$/,
loader: 'babel-loader',
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env']
}
},
include: [
path.resolve(__dirname, './src')
],
exclude: [/node_modules/],
query: {
presets: ['es2015']
}
exclude: [/node_modules/]
}
]
},
resolve: {
modules: [path.resolve(__dirname, 'src'), 'node_modules']
},
// Don't attempt to continue if there are any errors.
bail: !isDebug,
cache: isDebug,
Expand All @@ -42,19 +42,7 @@ const config = {
'process.env.NODE_ENV': isDebug ? '"development"' : '"production"',
'process.env.BROWSER': true,
__DEV__: isDebug
}),

...isDebug ? [] : [
// Minimize all JavaScript output of chunks
// https://github.com/mishoo/UglifyJS2#compressor-options
new webpack.optimize.UglifyJsPlugin({
sourceMap: true,
compress: {
screw_ie8: true, // eslint-disable-line
warnings: false
}
})
]
})
],

devtool: isDebug ? 'inline-source-map' : 'source-map',
Expand All @@ -65,5 +53,3 @@ const config = {
timings: true
}
};

export default config;