Skip to content

Releases: LawsonCheng/poke

v1.3.2

09 Nov 09:05
Compare
Choose a tag to compare

Minor bug fixes caused by wrong callback function type.

What's Changed

Full Changelog: v1.3.0...v1.3.2

v1.3.0

09 Nov 05:32
Compare
Choose a tag to compare

This release contains a new coding style, we decided to use Class rather than function to make code easier to understand and maintain. Also, we removed some interfaces which is not necessary.

Finally, special thanks to @iamgabrielsoft, welcome to our new contributor 😎

What's Changed

New Contributors

Full Changelog: v1.2.5...v1.3.0

V1.2.5

03 Oct 14:48
Compare
Choose a tag to compare
  1. BUG FIX: Fix TypeScript compilation error.

v1.2.4

26 Aug 07:15
Compare
Choose a tag to compare

Bug Fix

Release v1.2.4 fixed a bug when user called the pipe method but the request doesn't fire, so that the file couldn't save.

v1.2.3

01 Aug 16:17
Compare
Choose a tag to compare

Now you can set timeout value to the PokeOptions. When the timeout value is reached and response is not return yet, the request will be aborted.

poke('https://foo.com/api/get', {
    // abort request after 5s is no response return
    timeout : 5000
})
.promise()
.then(...)
.catch(error => {
    // you will get a "socket hang up" error 
    console.log(error)
})

v1.2.2

19 Jul 09:52
Compare
Choose a tag to compare

Release v1.2.2 contains bug fixes and better types for your convenience of development.

  1. We decided to split PokeResult into PokeSuccess and PokeError for easier handling when request is done.
  2. Trim out some redundancy of the code and make it easier to maintain.
  3. Comments are added to functions and interfaces for the sake of IDE Friendly.

v1.2.1

12 Jul 08:53
Compare
Choose a tag to compare

This release has no difference with the previous release, just for npm package publish usage.

1.2.0

12 Jul 08:35
Compare
Choose a tag to compare
  1. Enhanced types declaration in Poke, thanks for contributors!
  2. Patches applied to prevent unexpected user behavior.

Expose APIs in both TypeScript and JavaScript

09 Jul 03:00
615e7a0
Compare
Choose a tag to compare

From now on you may import Poke directly into your project whether it is written in TypeScript or JavaScript : )

Streams and Event Listeners are available!

08 Jul 08:55
Compare
Choose a tag to compare

You may now using the on method to listen to omitted events.

const poke = require('js.poke')
// Using callback
poke(hostname , pokeOptions)
// listen to response retrived
.on('response', result => {
    console.log(res)
})
// on chunk is recieved
.on('data', (chunk) => {
    // handle your data here
    console.log(d)
})
// on request eneded
.on('end', () => {
    console.log('Request is finished')
})
// listening to error
.on('error', (result) => {
    // handle error
    console.log(result.error)
})

And added some functions for Poke to support stream usages.

Write response as a file

const fs = require('fs')
const poke = require('js.poke')

// get image
poke('https://via.placeholder.com/100x100')
// write data as a image file
.pipe(fs.createWriteStream('image.png'))

Use as a proxy

const poke = require('js.poke')

const serv = http.createServer((req, res) => {
    if (req.url === '/placeholder') {
        // get image or whatever you want
        poke('https://via.placeholder.com/100x100')
        // pipe response to res
        .pipe(res)
    } else {
        res.end('Bye!')
    }
})
serv.listen(4321)