[Pkg-javascript-commits] [node-stream-http] 23/208: Replace util.inherits with inherits module
Bastien Roucariès
rouca at moszumanska.debian.org
Sun Aug 13 13:39:24 UTC 2017
This is an automated email from the git hooks/post-receive script.
rouca pushed a commit to branch master
in repository node-stream-http.
commit 3f96e0550baba167dc3b571a15e584b5dfbbc443
Author: Ben Drucker <bvdrucker at gmail.com>
Date: Fri Jul 3 09:20:19 2015 -0400
Replace util.inherits with inherits module
Also inlines util.isFunction
Reduces bundle size by not including extraneous code
---
lib/capability.js | 16 +++++++++-------
lib/request.js | 4 ++--
lib/response.js | 4 ++--
package.json | 1 +
4 files changed, 14 insertions(+), 11 deletions(-)
diff --git a/lib/capability.js b/lib/capability.js
index 09d8890..20400f9 100644
--- a/lib/capability.js
+++ b/lib/capability.js
@@ -1,6 +1,4 @@
-var util = require('util')
-
-exports.fetch = util.isFunction(window.fetch) && util.isFunction(window.ReadableByteStream)
+exports.fetch = isFunction(window.fetch) && isFunction(window.ReadableByteStream)
var xhr = new window.XMLHttpRequest()
xhr.open('GET', '/')
@@ -13,13 +11,17 @@ function checkTypeSupport (type) {
return false
}
-var haveArrayBuffer = util.isFunction(window.ArrayBuffer)
-var haveSlice = haveArrayBuffer && util.isFunction(window.ArrayBuffer.prototype.slice)
+var haveArrayBuffer = isFunction(window.ArrayBuffer)
+var haveSlice = haveArrayBuffer && isFunction(window.ArrayBuffer.prototype.slice)
exports.arraybuffer = haveArrayBuffer && checkTypeSupport('arraybuffer')
exports.msstream = haveSlice && checkTypeSupport('ms-stream')
exports.mozchunkedarraybuffer = haveArrayBuffer && checkTypeSupport('moz-chunked-arraybuffer')
-exports.overrideMimeType = util.isFunction(xhr.overrideMimeType)
-exports.vbArray = util.isFunction(window.VBArray)
+exports.overrideMimeType = isFunction(xhr.overrideMimeType)
+exports.vbArray = isFunction(window.VBArray)
+
+function isFunction (value) {
+ return typeof value === 'function'
+}
xhr = null // Help gc
diff --git a/lib/request.js b/lib/request.js
index 1e3c213..cf824ef 100644
--- a/lib/request.js
+++ b/lib/request.js
@@ -4,7 +4,7 @@ var foreach = require('foreach')
var keys = require('object-keys')
var response = require('./response')
var stream = require('stream')
-var util = require('util')
+var inherits = require('inherits')
var IncomingMessage = response.IncomingMessage
var rStates = response.readyStates
@@ -56,7 +56,7 @@ var ClientRequest = module.exports = function (opts) {
})
}
-util.inherits(ClientRequest, stream.Writable)
+inherits(ClientRequest, stream.Writable)
ClientRequest.prototype.setHeader = function (name, value) {
var self = this
diff --git a/lib/response.js b/lib/response.js
index 0af0b71..8efc820 100644
--- a/lib/response.js
+++ b/lib/response.js
@@ -1,7 +1,7 @@
var capability = require('./capability')
var foreach = require('foreach')
var stream = require('stream')
-var util = require('util')
+var inherits = require('inherits')
var rStates = exports.readyStates = {
UNSENT: 0,
@@ -79,7 +79,7 @@ var IncomingMessage = exports.IncomingMessage = function (xhr, response, mode) {
}
}
-util.inherits(IncomingMessage, stream.Readable)
+inherits(IncomingMessage, stream.Readable)
IncomingMessage.prototype._read = function () {}
diff --git a/package.json b/package.json
index fafadb4..246ff0c 100644
--- a/package.json
+++ b/package.json
@@ -15,6 +15,7 @@
"license": "MIT",
"dependencies": {
"foreach": "^2.0.5",
+ "inherits": "^2.0.1",
"object-keys": "^1.0.4"
},
"devDependencies": {
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-stream-http.git
More information about the Pkg-javascript-commits
mailing list