Skip to content

Commit

Permalink
inline util._extend, rather than requiring util
Browse files Browse the repository at this point in the history
Related:
- #25
- #40

This removes the require('util') fallback for Object.assign, without
dropping support for node v4 (which will happen on the next major,
likely along with 6), but gets bundle sizes down in the meantime.
  • Loading branch information
isaacs committed Aug 4, 2019
1 parent 3776fa5 commit a5a91ac
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion git-host.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
'use strict'
var gitHosts = require('./git-host-info.js')
/* eslint-disable node/no-deprecated-api */

// copy-pasta util._extend from node's source, to avoid pulling
// the whole util module into peoples' webpack bundles.
/* istanbul ignore next */
var extend = Object.assign || require('util')._extend
var extend = Object.assign || function _extend (target, source) {
// Don't do anything if source isn't an object
if (source === null || typeof source !== 'object') return target

const keys = Object.keys(source)
let i = keys.length
while (i--) {
target[keys[i]] = source[keys[i]]
}
return target
}

var GitHost = module.exports = function (type, user, auth, project, committish, defaultRepresentation, opts) {
var gitHostInfo = this
Expand Down

0 comments on commit a5a91ac

Please sign in to comment.