<commit_before>Birdwatcher JS ![alt TravisCI Build](https://travis-ci.org/gmmorris/birdwatcherjs.svg?branch=master) [![Code Climate](https://codeclimate.com/github/gmmorris/birdwatcherjs/badges/gpa.svg)](https://codeclimate.com/github/gmmorris/birdwatcherjs) [![npm version](https://img.shields.io/npm/v/birdwatcher.svg?style=flat-square)](https://www.npmjs.com/package/birdwatcher)
=======

A small utility for implementing the NCZ JavaScript error handling pattern.
To understand the anti anti-pattern pattern: http://www.nczonline.net/blog/2009/04/28/javascript-error-handling-anti-pattern/

## In the Browser (as ES5)
To use birdwatcher, all you have to do is tell birdwatcher to spy on an object and set the callback you wish to have called when an error is raised.

As Birdwatcher is implemented in ES6 using the ES6 module system, you first need to build a version of the utility which can work in the browser.
I chose not to make any assumptions as to how Birdwatcher would be integrated into a project, so instead of providing a prebuilt version for the browsers, I simply recommend you use a module bundler that supports ES6.
Personally, I use [webpack](http://webpack.github.io/) along with [babel-loader](https://github.com/babel/babel-loader), but you can use whatever you find suitable.

Assuming you bundled the Birdwatcher utility into it's own file named *birdwatcher.min.js* you may continue thusly:

```html
    <script type="text/javascript" src="birdwatcher.min.js"></script>
```

### Basic usage
```js
    window.theKing = {
        giveUpThrone: function(){
            throw Error("The king will never be over thrown!");
        }<commit_msg>updated readme with quick description of why we need BW<commit_after>Birdwatcher JS ![alt TravisCI Build](https://travis-ci.org/gmmorris/birdwatcherjs.svg?branch=master) [![Code Climate](https://codeclimate.com/github/gmmorris/birdwatcherjs/badges/gpa.svg)](https://codeclimate.com/github/gmmorris/birdwatcherjs) [![npm version](https://img.shields.io/npm/v/birdwatcher.svg?style=flat-square)](https://www.npmjs.com/package/birdwatcher)
=======

A small utility for implementing the NCZ JavaScript error handling pattern.
To understand the anti anti-pattern pattern: http://www.nczonline.net/blog/2009/04/28/javascript-error-handling-anti-pattern/

## What do we need it for?
Birdwatcher allows you to completely decouple your error handling strategy from your component implementations.
It allows you to attach error handling to your objects without having to write try/catch throughout their implementations and at the same time, allows you to attach custom configurations for specific objects or groups of objects, while still maintaining a uniform strategy for dealing with their errors when they arise.

## In the Browser (as ES5)
To use birdwatcher, all you have to do is tell birdwatcher to spy on an object and set the callback you wish to have called when an error is raised.

As Birdwatcher is implemented in ES6 using the ES6 module system, you first need to build a version of the utility which can work in the browser.
I chose not to make any assumptions as to how Birdwatcher would be integrated into a project, so instead of providing a prebuilt version for the browsers, I simply recommend you use a module bundler that supports ES6.
Personally, I use [webpack](http://webpack.github.io/) along with [babel-loader](https://github.com/babel/babel-loader), but you can use whatever you find suitable.

Assuming you bundled the Birdwatcher utility into it's own file named *birdwatcher.min.js* you may continue thusly:

```html
    <script type="text/javascript" src="birdwatcher.min.js"></script>
```

### Basic usage
```js
    window.theKing = {
        giveUpThrone: function(){
            throw Error("The king will never be over thrown!");
        }
{'fraction_non_alphanumeric': 0.09546165884194054, 'fraction_numerical': 0.006259780907668232, 'mean_word_length': 4.598540145985401, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 12, 'lorem ipsum': 0, 'www.': 4, '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': '1129729', 'n_tokens_mistral': 1101, 'n_tokens_neox': 1039, 'n_words': 431}