clone-response
Advanced tools
Comparing version 0.1.1 to 0.2.0
{ | ||
"name": "clone-response", | ||
"version": "0.1.1", | ||
"version": "0.2.0", | ||
"description": "Clone a Node.js response object", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -33,3 +33,3 @@ 'use strict'; | ||
toStream[prop] = typeof prop === 'function' ? fromStream[prop].bind(fromStream) : fromStream[prop]; | ||
toStream[prop] = typeof fromStream[prop] === 'function' ? fromStream[prop].bind(fromStream) : fromStream[prop]; | ||
} | ||
@@ -36,0 +36,0 @@ }; |
@@ -46,3 +46,3 @@ import http from 'http'; | ||
cloneResponse.knownProps.forEach(prop => t.is(clonedResponse[prop], response[prop])); | ||
cloneResponse.knownProps.forEach(prop => t.true(typeof clonedResponse[prop] !== 'undefined')); | ||
}); | ||
@@ -58,8 +58,10 @@ | ||
test('custom functions are copied over', async t => { | ||
test('function methods are bound to the original response instance', async t => { | ||
const response = await rfpify(http.get)(s.url + '/'); | ||
response.foo = () => 'bar'; | ||
response.getThis = function () { | ||
return this; | ||
}; | ||
const clonedResponse = cloneResponse(response); | ||
t.is(clonedResponse.foo(), 'bar'); | ||
t.is(response.getThis(), clonedResponse.getThis()); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6759
88