Skip to content

Commit

Permalink
Release 5.5.1: Additions to README, removal of dep injection.
Browse files Browse the repository at this point in the history
  • Loading branch information
ethan7g committed Dec 2, 2017
1 parent c062888 commit 30b3634
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 59 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
[Full documentation](https://ethanent.github.io/phin/) | [GitHub](https://github.com/Ethanent/phin) | [NPM](https://www.npmjs.com/package/phin)

[![ethanent Discord Server Status](https://discordapp.com/api/guilds/386353885377331211/widget.png)](https://ethanent.me/discord "ethanent Official Discord Server")

## Simple Usage
For a simple page GET request.

Expand Down
45 changes: 3 additions & 42 deletions docs/global.html
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ <h3 class="subsection-title">Methods</h3>



<h4 class="name" id="phin"><span class="type-signature"></span>phin<span class="signature">(options, callback<span class="signature-attributes">opt</span>, httpModule<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4>
<h4 class="name" id="phin"><span class="type-signature"></span>phin<span class="signature">(options, callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4>



Expand Down Expand Up @@ -226,45 +226,6 @@ <h5>Parameters:</h5>
</tr>



<tr>

<td class="name"><code>httpModule</code></td>


<td class="type">


<span class="param-type">Object</span>



</td>


<td class="attributes">

&lt;optional><br>





</td>



<td class="default">

require('http')

</td>


<td class="description last">HTTP module injection (for testing)</td>
</tr>


</tbody>
</table>

Expand Down Expand Up @@ -302,7 +263,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="phin.js.html">phin.js</a>, <a href="phin.js.html#line37">line 37</a>
<a href="phin.js.html">phin.js</a>, <a href="phin.js.html#line36">line 36</a>
</li></ul></dd>


Expand Down Expand Up @@ -1045,7 +1006,7 @@ <h2><a href="index.html">Home</a></h2><h3>Global</h3><ul><li><a href="global.htm
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.3</a> on Sun Sep 03 2017 13:15:26 GMT-0700 (PDT)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Fri Dec 01 2017 20:42:18 GMT-0800 (PST)
</footer>

<script> prettyPrint(); </script>
Expand Down
3 changes: 2 additions & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ <h3> </h3>
<p>Ultra-simple, lightweight, dependency-free Node.JS HTTP request client (with util.promisify support)</p>
</blockquote>
<p><a href="https://ethanent.github.io/phin/">Full documentation</a> | <a href="https://github.com/Ethanent/phin">GitHub</a> | <a href="https://www.npmjs.com/package/phin">NPM</a></p>
<p><a href="https://ethanent.me/discord" title="ethanent Official Discord Server"><img src="https://discordapp.com/api/guilds/386353885377331211/widget.png" alt="ethanent Discord Server Status"></a></p>
<h2>Simple Usage</h2><p>For a simple page GET request.</p>
<pre class="prettyprint source lang-javascript"><code>var p = require(&quot;phin&quot;);

Expand Down Expand Up @@ -101,7 +102,7 @@ <h2><a href="index.html">Home</a></h2><h3>Global</h3><ul><li><a href="global.htm
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.3</a> on Sun Sep 03 2017 13:15:26 GMT-0700 (PDT)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Fri Dec 01 2017 20:42:18 GMT-0800 (PST)
</footer>

<script> prettyPrint(); </script>
Expand Down
11 changes: 3 additions & 8 deletions docs/phin.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ <h1 class="page-title">Source: phin.js</h1>

<section>
<article>
<pre class="prettyprint source linenums"><code>const realHttp = require('http')
<pre class="prettyprint source linenums"><code>const http = require('http')
const https = require('https')
const url = require('url')
const qs = require('querystring')
Expand Down Expand Up @@ -60,9 +60,8 @@ <h1 class="page-title">Source: phin.js</h1>
* Sends an HTTP request
* @param {phinOptions|string} options - phin options object (or string for auto-detection)
* @param {phinResponseCallback} [callback=null] - Callback to which data is sent upon request completion
* @param {Object} [httpModule=require('http')] - HTTP module injection (for testing)
*/
const phin = (opts, cb, injectedHttp) => {
const phin = (opts, cb) => {
if (typeof(opts) !== 'string') {
if (!opts.hasOwnProperty('url')) {
throw new Error('Missing url option from options for request method.')
Expand Down Expand Up @@ -128,10 +127,6 @@ <h1 class="page-title">Source: phin.js</h1>
})
}

// Dependency injection for testing

const http = injectedHttp || realHttp

switch (addr.protocol.toLowerCase()) {
case 'http:':
req = http.request(options, resHandler)
Expand Down Expand Up @@ -216,7 +211,7 @@ <h2><a href="index.html">Home</a></h2><h3>Global</h3><ul><li><a href="global.htm
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.3</a> on Sun Sep 03 2017 13:15:26 GMT-0700 (PDT)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Fri Dec 01 2017 20:42:18 GMT-0800 (PST)
</footer>

<script> prettyPrint(); </script>
Expand Down
9 changes: 2 additions & 7 deletions lib/phin.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const realHttp = require('http')
const http = require('http')
const https = require('https')
const url = require('url')
const qs = require('querystring')
Expand Down Expand Up @@ -32,9 +32,8 @@ const util = require('util')
* Sends an HTTP request
* @param {phinOptions|string} options - phin options object (or string for auto-detection)
* @param {phinResponseCallback} [callback=null] - Callback to which data is sent upon request completion
* @param {Object} [httpModule=require('http')] - HTTP module injection (for testing)
*/
const phin = (opts, cb, injectedHttp) => {
const phin = (opts, cb) => {
if (typeof(opts) !== 'string') {
if (!opts.hasOwnProperty('url')) {
throw new Error('Missing url option from options for request method.')
Expand Down Expand Up @@ -100,10 +99,6 @@ const phin = (opts, cb, injectedHttp) => {
})
}

// Dependency injection for testing

const http = injectedHttp || realHttp

switch (addr.protocol.toLowerCase()) {
case 'http:':
req = http.request(options, resHandler)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "phin",
"version": "2.4.18",
"version": "2.5.1",
"description": "Ultra-simple, lightweight, dependency-free Node.JS HTTP request client",
"main": "lib/phin.js",
"scripts": {
Expand Down

0 comments on commit 30b3634

Please sign in to comment.