Skip to content

Commit

Permalink
globalThis
Browse files Browse the repository at this point in the history
  • Loading branch information
David Mark Clements committed May 11, 2019
1 parent 248be4e commit 2b3bbf1
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var format = require('quick-format-unescaped')

module.exports = pino

var _console = global.console || {}
var _console = polyfillGlobalThis().console || {}
var stdSerializers = {
mapHttpRequest: mock,
mapHttpResponse: mock,
Expand Down Expand Up @@ -304,3 +304,18 @@ function asErrValue (err) {
function mock () { return {} }
function passthrough (a) { return a }
function noop () {}

/* eslint-disable */
/* istanbul ignore next */
function polyfillGlobalThis () {
if (typeof globalThis !== 'undefined') return globalThis
Object.defineProperty(Object.prototype, 'globalThis', {
get: function () {
delete Object.prototype.globalThis
return (this.globalThis = this)
},
configurable: true
})
return globalThis
}
/* eslint-enable */

0 comments on commit 2b3bbf1

Please sign in to comment.