Debian Codegraph @

vendor/wikimedia/parsoid/core-upgrade.js

raw
1 'use strict';
2
3 // Register prfun's Promises with node-pn
4 var Promise = require('./lib/utils/promise.js');
5 require('pn/_promise')(Promise); // This only needs to be done once.
6
7 // Comments below annotate the highest lts version of node for which the
8 // polyfills are necessary. Remove when that version is no longer supported.
9
10 // v6
11 require('core-js/fn/object/entries');
12 require('core-js/fn/string/pad-start');
13 require('core-js/fn/string/pad-end');
14
15 // In Node v10, console.assert() was changed to log messages to stderr
16 // *WITHOUT THROWING AN EXCEPTION*. We should clearly have been using
17 // a proper assertion library... but since we're switching to PHP anyway,
18 // for the moment just hack console.assert() to make things behave the
19 // way they used to.
20 if (require('semver').gte(process.version, '10.0.0')) {
21 const oldAssert = console.assert;
22 console.assert = function(value) {
23 const args = Array.from(arguments);
24 oldAssert.apply(console, args);
25 if (!args[0]) {
26 // We only get here in Node >= 0.10!
27 args.shift();
28 let msg = 'AssertionError';
29 if (args.length) {
30 const util = require('util');
31 msg += ': ' + util.format.apply(util, args);
32 }
33 class AssertionException extends Error {
34 constructor(msg2) {
35 super(msg2); this.message = msg2;
36 }
37 }
38 throw new AssertionException(msg);
39 }
40 };
41 }