From fc14f60a4b206b841766e302e65957610193ba61 Mon Sep 17 00:00:00 2001 From: muxator Date: Wed, 15 Aug 2018 22:34:05 +0200 Subject: [PATCH] runtime: polyfill Object.values() Minimum supported Node version is 6.9.0, but Object.values() was introduced in Node < 7. Let's use a polyfill if needed. This will be removed when minimum supported Node version is raised to 8.9.0. Fixes #3459 --- src/node/stats.js | 16 ++++++++++++++++ src/package.json | 1 + 2 files changed, 17 insertions(+) diff --git a/src/node/stats.js b/src/node/stats.js index ff1752fe9..5ffa8a07b 100644 --- a/src/node/stats.js +++ b/src/node/stats.js @@ -1,3 +1,19 @@ +/* + * TODO: this polyfill is needed for Node 6.9 support. + * + * Once minimum supported Node version is raised to 8.9.0, it will be removed. + */ +if (!Object.values) { + var log4js = require('log4js'); + var statsLogger = log4js.getLogger("stats"); + + statsLogger.warn(`Enabling a polyfill to run on this Node version (${process.version}). Next Etherpad version will remove support for Node version < 8.9.0. Please update your runtime.`); + + var values = require('object.values'); + + values.shim(); +} + var measured = require('measured-core') module.exports = measured.createCollection(); diff --git a/src/package.json b/src/package.json index 14309b775..02c276021 100644 --- a/src/package.json +++ b/src/package.json @@ -45,6 +45,7 @@ "log4js": "0.6.35", "measured-core": "1.11.2", "npm": ">=4.0.2", + "object.values": "^1.0.4", "request": "2.83.0", "resolve": "1.1.7", "security": "1.0.0",