Socket
Socket
Sign inDemoInstall

@voiceflow/common

Package Overview
Dependencies
Maintainers
13
Versions
130
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@voiceflow/common - npm Package Compare versions

Comparing version 5.0.1 to 6.0.0

47

lib/maintenance.js
'use strict';
const _ = require('lodash');
const moment = require('moment');
// MAINTENANCE - TURN OFF WHEN NOT IN USE FOR PERFORMANCE
const MAINTENANCE = true;
// MAINTENANCE SETTINGS
// ISO standard time in GMT

@@ -15,4 +7,2 @@ const MAINTENANCE_START = '2019-04-19T00:00:00Z';

const MAINTENANCE_TIME = 120;
// how many minutes out to do warnings
const WARNING_INTERVALS = [60, 30, 10, 5, 1];

@@ -28,38 +18,1 @@ // MAINTENANCE OPERATIONS

};
// TODO: remove the rest of this file
// eslint-disable-next-line no-process-env
if (!MAINTENANCE || process.env.NODE_ENV !== 'production' || process.env.REACT_APP_BUILD_ENV === 'staging') {
module.exports.evaluateMaintenance = _.noop;
module.exports.underMaintenance = () => false;
} else {
const evaluateMaintenance = (action, first = true) => {
const far_out = Date.now() - MAINTENANCE_START_DATE;
if (far_out > 0 && far_out < MAINTENANCE_TIME_MS) {
action(null);
} else if (far_out < 0) {
let i;
let wait_time = far_out;
for (i = 0; i < WARNING_INTERVALS.length; i++) {
const interval = WARNING_INTERVALS[i] * 60 * 1000;
if (far_out * -1 > interval) {
wait_time = far_out * -1 - interval;
break;
}
}
if (i > 0 && !first) {
action(moment(MAINTENANCE_START).fromNow(true));
}
if (i === WARNING_INTERVALS.length) {
wait_time = far_out * -1;
}
setTimeout(() => evaluateMaintenance(action, false), wait_time + 1000);
}
};
module.exports.underMaintenance = (delay = 10000) => {
const far_out = Date.now() - MAINTENANCE_START_DATE;
return far_out > delay && far_out < MAINTENANCE_TIME_MS;
};
module.exports.evaluateMaintenance = evaluateMaintenance;
}

2

package.json
{
"name": "@voiceflow/common",
"description": "Junk drawer of utility functions",
"version": "5.0.1",
"version": "6.0.0",
"author": "Voiceflow",

@@ -6,0 +6,0 @@ "bugs": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc