Skip to content

Commit

Permalink
3.0.0: Wrapped centra, default promisified, removed deprecated auth s…
Browse files Browse the repository at this point in the history
…upport.

Updated docs and tests accordingly.
  • Loading branch information
ethan7g committed Oct 28, 2018
1 parent 70398c6 commit 9c22da1
Show file tree
Hide file tree
Showing 13 changed files with 146 additions and 434 deletions.
9 changes: 0 additions & 9 deletions .babelrc

This file was deleted.

3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Only dev-dependencies
package-lock.json

# Env information / sensitive data
.env
pids
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ node_js:
- "node"
- "8"
- "6"
script: npm run test-dev
script: npm test
34 changes: 13 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@
```javascript
const p = require('phin')

p('https://ethanent.me', (err, res) => {
if (!err) console.log(res.body)
})
const res = await p('https://ethanent.me')

console.log(res.body)
```

Note that the above should be in an async context! phin also provides an unpromisified version of the library.

## Install

Expand All @@ -39,7 +40,7 @@ Also, phin is super **lightweight**. Like **99.8% smaller than request** lightwe
Simple POST:

```javascript
p({
await p({
url: 'https://ethanent.me',
method: 'POST',
data: {
Expand All @@ -48,20 +49,14 @@ p({
})
```

Promisified:

```javascript
const p = require('phin').promisified
```
## Unpromisified Usage

```javascript
;(async () => {
const res = await p({
url: 'https://ethanent.me'
})
const p = require('phin').unpromisified

console.log(res.body)
})()
p('https://ethanent.me', (err, res) => {
if (!err) console.log(res.body)
})
```

Simple parsing of JSON:
Expand All @@ -78,18 +73,15 @@ console.log(res.body.first)
```


## Documentation
## Full Documentation

See [the phin documentation](https://ethanent.github.io/phin/).

`phin` has [`util.promisify`](https://nodejs.org/dist/latest-v8.x/docs/api/util.html#util_util_promisify_original) support. The promisified library can also be accessed with `require('phin').promisified`!


## phin vs. the Competition

<img src="https://pbs.twimg.com/media/DSLU_UcUEAI4bgc.jpg:large" alt="Request is over 6MB in size. phin is just 25KB in size."/>

phin is super lightweight, and *it's getting lighter all the time*.
phin is a very lightweight library.

It contains all of the common HTTP client features included in competing libraries!

Expand All @@ -99,4 +91,4 @@ request | 4,446 | [53](http://npm.anvaka.com/#/view/2d/request) | 444.6x
superagent | 1,235 | [24](http://npm.anvaka.com/#/view/2d/superagent) | 123.5x
got | 664 | [44](http://npm.anvaka.com/#/view/2d/got) | 66.4x
snekfetch | 107 | [0](http://npm.anvaka.com/#/view/2d/snekfetch) | 10.7x
phin | 10 | [0](http://npm.anvaka.com/#/view/2d/phin) | 1x
phin | 10 | [1](http://npm.anvaka.com/#/view/2d/phin) | 1x
126 changes: 28 additions & 98 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>)</span><span class="type-signature"></span></h4>
<h4 class="name" id="phin"><span class="type-signature">(async) </span>phin<span class="signature">(options)</span><span class="type-signature"> &rarr; {Promise.&lt;http.serverResponse>}</span></h4>



Expand Down Expand Up @@ -136,12 +136,8 @@ <h5>Parameters:</h5>
<th>Type</th>


<th>Attributes</th>



<th>Default</th>


<th class="last">Description</th>
</tr>
Expand All @@ -168,64 +164,13 @@ <h5>Parameters:</h5>
</td>


<td class="attributes">





</td>



<td class="default">

</td>


<td class="description last">phin options object (or string for auto-detection)</td>
</tr>



<tr>

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


<td class="type">


<span class="param-type"><a href="global.html#phinResponseCallback">phinResponseCallback</a></span>



</td>


<td class="attributes">

&lt;optional><br>





</td>



<td class="default">

null

</td>


<td class="description last">Callback to which data is sent upon request completion</td>
</tr>


</tbody>
</table>

Expand Down Expand Up @@ -263,7 +208,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#line38">line 38</a>
<a href="phin.js.html">phin.js</a>, <a href="phin.js.html#line32">line 32</a>
</li></ul></dd>


Expand All @@ -286,6 +231,28 @@ <h5>Parameters:</h5>



<h5>Returns:</h5>


<div class="param-desc">
- phin-adapted response object
</div>



<dl>
<dt>
Type
</dt>
<dd>

<span class="param-type">Promise.&lt;http.serverResponse></span>


</dd>
</dl>





Expand Down Expand Up @@ -789,43 +756,6 @@ <h5 class="subsection-title">Properties:</h5>
</tr>



<tr>

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


<td class="type">


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



</td>


<td class="attributes">

&lt;optional><br>



</td>



<td class="default">

autodetect

</td>


<td class="description last">Request authentiction in 'user:password' format</td>
</tr>


</tbody>
</table>

Expand Down Expand Up @@ -861,7 +791,7 @@ <h5 class="subsection-title">Properties:</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#line8">line 8</a>
<a href="phin.js.html">phin.js</a>, <a href="phin.js.html#line3">line 3</a>
</li></ul></dd>


Expand Down Expand Up @@ -891,7 +821,7 @@ <h4 class="name" id="phinResponseCallback"><span class="type-signature"></span>p


<div class="description">
Response data callback
Response data
</div>


Expand Down Expand Up @@ -1032,7 +962,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#line26">line 26</a>
<a href="phin.js.html">phin.js</a>, <a href="phin.js.html#line20">line 20</a>
</li></ul></dd>


Expand Down Expand Up @@ -1080,7 +1010,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.5</a> on Fri Sep 07 2018 17:24:14 GMT-0700 (PDT)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Sat Oct 27 2018 20:49:46 GMT-0700 (PDT)
</footer>

<script> prettyPrint(); </script>
Expand Down
31 changes: 14 additions & 17 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,37 +52,34 @@ <h3> </h3>
<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>
<h2>Simple Usage</h2><pre class="prettyprint source lang-javascript"><code>const p = require('phin')

p('https://ethanent.me', (err, res) => {
if (!err) console.log(res.body)
})</code></pre><h2>Install</h2><pre class="prettyprint source"><code>npm install phin</code></pre><h2>Why phin?</h2><p>phin is <strong>trusted</strong> by some really important projects. The hundreds of contributors at <a href="https://github.com/less/less.js">Less</a>, for example, depend on phin as part of their development process.</p>
const res = await p('https://ethanent.me')

console.log(res.body)</code></pre><p>Note that the above should be in an async context! phin also provides an unpromisified version of the library.</p>
<h2>Install</h2><pre class="prettyprint source"><code>npm install phin</code></pre><h2>Why phin?</h2><p>phin is <strong>trusted</strong> by some really important projects. The hundreds of contributors at <a href="https://github.com/less/less.js">Less</a>, for example, depend on phin as part of their development process.</p>
<p>Also, phin is super <strong>lightweight</strong>. Like <strong>99.8% smaller than request</strong> lightweight. To compare to other libraries, see <a href="https://github.com/ethanent/phin/blob/master/README.md#phin-vs-the-competition">phin vs. the Competition</a>.</p>
<p><img src="https://pbs.twimg.com/media/DSPF9TaUQAA0tIe.jpg:large" alt="phin became 33% lighter with release 2.7.0!"/></p>
<h2>Quick Demos</h2><p>Simple POST:</p>
<pre class="prettyprint source lang-javascript"><code>p({
<pre class="prettyprint source lang-javascript"><code>await p({
url: 'https://ethanent.me',
method: 'POST',
data: {
hey: 'hi'
}
})</code></pre><p>Promisified:</p>
<pre class="prettyprint source lang-javascript"><code>const p = require('phin').promisified</code></pre><pre class="prettyprint source lang-javascript"><code>;(async () => {
const res = await p({
url: 'https://ethanent.me'
})

console.log(res.body)
})()</code></pre><p>Simple parsing of JSON:</p>
})</code></pre><h2>Unpromisified Usage</h2><pre class="prettyprint source lang-javascript"><code>const p = require('phin').unpromisified

p('https://ethanent.me', (err, res) => {
if (!err) console.log(res.body)
})</code></pre><p>Simple parsing of JSON:</p>
<pre class="prettyprint source lang-javascript"><code>// (In async function in this case.)

const res = await p({
url: 'https://ethanent.me/name',
parse: 'json'
})

console.log(res.body.first)</code></pre><h2>Documentation</h2><p>See <a href="https://ethanent.github.io/phin/">the phin documentation</a>.</p>
<p><code>phin</code> has <a href="https://nodejs.org/dist/latest-v8.x/docs/api/util.html#util_util_promisify_original"><code>util.promisify</code></a> support. The promisified library can also be accessed with <code>require('phin').promisified</code>!</p>
console.log(res.body.first)</code></pre><h2>Full Documentation</h2><p>See <a href="https://ethanent.github.io/phin/">the phin documentation</a>.</p>
<h2>phin vs. the Competition</h2><p><img src="https://pbs.twimg.com/media/DSLU_UcUEAI4bgc.jpg:large" alt="Request is over 6MB in size. phin is just 25KB in size."/></p>
<p>phin is super lightweight, and <em>it's getting lighter all the time</em>.</p>
<p>phin is a very lightweight library.</p>
<p>It contains all of the common HTTP client features included in competing libraries!</p>
<table>
<thead>
Expand Down Expand Up @@ -121,7 +118,7 @@ <h2>phin vs. the Competition</h2><p><img src="https://pbs.twimg.com/media/DSLU_U
<tr>
<td>phin</td>
<td>10</td>
<td><a href="http://npm.anvaka.com/#/view/2d/phin">0</a></td>
<td><a href="http://npm.anvaka.com/#/view/2d/phin">1</a></td>
<td>1x</td>
</tr>
</tbody>
Expand All @@ -142,7 +139,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.5</a> on Fri Sep 07 2018 17:24:14 GMT-0700 (PDT)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Sat Oct 27 2018 20:49:46 GMT-0700 (PDT)
</footer>

<script> prettyPrint(); </script>
Expand Down
Loading

0 comments on commit 9c22da1

Please sign in to comment.