Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

co-assert-timeout

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

co-assert-timeout - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

10

index.js

@@ -19,2 +19,3 @@ var co = require('co')

err.status = 408
err.exposed = true
err.timeout = timeout

@@ -25,8 +26,5 @@ called = true

fn(function (err) {
if (called) {
if (logger && err)
logger(err)
return
}
fn(function () {
if (called)
return logger && logger.apply(ctx, arguments)

@@ -33,0 +31,0 @@ clearTimeout(id)

2

package.json
{
"name": "co-assert-timeout",
"description": "Assert a thunk or generator's timeout co-style",
"version": "0.0.1",
"version": "0.0.2",
"author": {

@@ -6,0 +6,0 @@ "name": "Jonathan Ong",

@@ -21,7 +21,7 @@ # Co Assert Timeout [![Build Status](https://travis-ci.org/koajs/co-assert-timeout.png)](https://travis-ci.org/koajs/co-assert-timeout)

not you.
Specifically, you should set a timeout only on the client sending a response:
Specifically, you should set a timeout only on the client sending a request:
```js
app.use(function* (next) {
var buffer = yield assertTimeout(this.request.buffer())
var buffer = yield assertTimeout(this.request.buffer(), '5 seconds')
})

@@ -35,5 +35,6 @@ ```

try {
var buffer = yield assertTimeout(this.request.buffer())
var buffer = yield assertTimeout(this.request.buffer(), '5 seconds')
} catch (err) {
if (err.status === 408) {
// assertTimeout's errors will have err.status = 408
// let's make a new error with a custom message

@@ -44,4 +45,7 @@ err = new Error('you took too long to upload')

// rethrow the error
throw err
}
yield next
})

@@ -52,7 +56,7 @@ ```

### assertTimeout(fn, timeout, [logger])
### assertTimeout(fn, timeout, [done])
- `fn` - a thunk, generator, or generator function
- `timeout` - timeout in milliseconds integer or a string
- `logger` - optional logger if `fn` errors after `timeout`
- `done` - optional callback called only when `fn` finishes executing after the timeout error is thrown

@@ -59,0 +63,0 @@ ## License

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc