Releases: LawsonCheng/poke
v1.3.2
Minor bug fixes caused by wrong callback function type.
What's Changed
- Develop by @LawsonCheng in #95
- Release 1.3.0 by @LawsonCheng in #96
- Merge pull request #95 from LawsonCheng/develop by @LawsonCheng in #97
- Patch/event manager access modifier by @LawsonCheng in #98
- Release 1.3.1 by @LawsonCheng in #100
- Callback function type hot fix by @LawsonCheng in #102
Full Changelog: v1.3.0...v1.3.2
v1.3.0
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
- build 1.2.5 by @LawsonCheng in #87
- Release/1.2.5 by @LawsonCheng in #88
- Refactor the Code by @iamgabrielsoft in #90
- Patch/refactor by @LawsonCheng in #92
- Patch/access modifier by @LawsonCheng in #94
New Contributors
- @iamgabrielsoft made their first contribution in #90
Full Changelog: v1.2.5...v1.3.0
V1.2.5
- BUG FIX: Fix TypeScript compilation error.
v1.2.4
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
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
Release v1.2.2 contains bug fixes and better types for your convenience of development.
- We decided to split
PokeResult
intoPokeSuccess
andPokeError
for easier handling when request is done. - Trim out some redundancy of the code and make it easier to maintain.
- Comments are added to functions and interfaces for the sake of IDE Friendly.
v1.2.1
This release has no difference with the previous release, just for npm package publish usage.
1.2.0
- Enhanced types declaration in Poke, thanks for contributors!
- Patches applied to prevent unexpected user behavior.
Expose APIs in both TypeScript and JavaScript
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!
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)