<commit_before>callback-timeout
================

Executes callback with single error argument if timeout is exceeded before it's called naturally

[![browser support](http://ci.testling.com/jasonpincin/callback-timeout.png)](http://ci.testling.com/jasonpincin/callback-timeout)

# example

``` js
var timeout = require('callback-timeout')

function doSomethingFast(cb) { setTimeout(cb, 100) }
function doSomethingSlow(cb) { setTimeout(cb, 2000) }

doSomethingFast(timeout(function doSomethingFastHandler (err) {
    if (err)
        console.log(err.message) // Will not happen
    else
        console.log('doSomethingFastHandler executed without error.') // Will happen
}, 1000))

doSomethingSlow(timeout(function doSomethingSlowHandler (err) {
    if (err)
        console.log(err.message) // Will happen
    else
        console.log('doSomethingSlowHandler executed without error.') // Will not happen
}, 1000))
```

# usage

``` js
var timeout = require('callback-timeout')
```

## timeout(callback, [ms])

Returns a callback function that will execute after `ms` milliseconds with a single `Error` argument 
if not invoked by other means first. If the `ms` timeout argument is omitted, 0, or null, then the timeout 
is disabled and the original callback is returned.

# install

With [npm](https://npmjs.org) do:

```
npm install callback-timeout
```

# license

MIT<commit_msg>added doc for pr #1<commit_after>callback-timeout
================

Executes callback with single error argument if timeout is exceeded before it's called naturally

[![browser support](http://ci.testling.com/jasonpincin/callback-timeout.png)](http://ci.testling.com/jasonpincin/callback-timeout)

# example

``` js
var timeout = require('callback-timeout')

function doSomethingFast(cb) { setTimeout(cb, 100) }
function doSomethingSlow(cb) { setTimeout(cb, 2000) }

doSomethingFast(timeout(function doSomethingFastHandler (err) {
    if (err)
        console.log(err.message) // Will not happen
    else
        console.log('doSomethingFastHandler executed without error.') // Will happen
}, 1000))

doSomethingSlow(timeout(function doSomethingSlowHandler (err) {
    if (err)
        console.log(err.message) // Will happen
    else
        console.log('doSomethingSlowHandler executed without error.') // Will not happen
}, 1000))
```

# usage

``` js
var timeout = require('callback-timeout')
```

## timeout(callback [, ms, msg])

Returns a callback function that will execute after `ms` milliseconds with a single `Error` argument 
if not invoked by other means first. If the `ms` timeout argument is omitted, 0, or null, then the timeout 
is disabled and the original callback is returned. `msg` may be used to set a custom error message (on 
timeout), otherwise an appropriate one will be set for you.

# install

With [npm](https://npmjs.org) do:

```
npm install callback-timeout
```

# license

MIT
{'fraction_non_alphanumeric': 0.1223643276875216, 'fraction_numerical': 0.011406844106463879, 'mean_word_length': 4.379182156133829, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3415941', 'n_tokens_mistral': 868, 'n_tokens_neox': 801, 'n_words': 271}