<commit_before># hobknob-client-nodejs

> A node client to retrieve feature toggles stored in Etcd.

[![Build Status](https://travis-ci.org/opentable/hobknob-client-nodejs.svg?branch=master)](https://travis-ci.org/opentable/hobknob-client-nodejs)

[![NPM](https://nodei.co/npm/hobknob-client-nodejs.png)](https://nodei.co/npm/hobknob-client-nodejs)

## Installation

```
npm install hobknob-client-nodejs
```

## Usage

```javascript
var Client = require('hobknob-client-nodejs');

var client = new Client("application-name", {
    etcdHost: "127.0.0.1",
    etcdPort: 4001,
    cacheIntervalMs: 60000
});

client.on("error", function(err) {
    console.log(err);
});

client.on("updated-cache", function(togglesChanged){
    console.log('updated-cache' + JSON.stringify(togglesChanged)); // contains an array of toggles that changed in the last update
});

client.initialise(function(err) {

    if(err){
        throw err;
    }

    console.log(client.get("toggle1"));

    console.log(client.getOrDefault("toggle2", true));
});
```

### Important Note

The "error" event must be subscribed to, otherwise errors will cause the application to exit

```javascript
client.on("error", function(err) { });
```

## Etcd<commit_msg>remove last traces of .get() from the readme<commit_after># hobknob-client-nodejs

> A node client to retrieve feature toggles stored in Etcd.

[![Build Status](https://travis-ci.org/opentable/hobknob-client-nodejs.svg?branch=master)](https://travis-ci.org/opentable/hobknob-client-nodejs)

[![NPM](https://nodei.co/npm/hobknob-client-nodejs.png)](https://nodei.co/npm/hobknob-client-nodejs)

## Installation

```
npm install hobknob-client-nodejs
```

## Usage

```javascript
var Client = require('hobknob-client-nodejs');

var client = new Client("application-name", {
    etcdHost: "127.0.0.1",
    etcdPort: 4001,
    cacheIntervalMs: 60000
});

client.on("error", function(err) {
    console.log(err);
});

client.on("updated-cache", function(togglesChanged){
    console.log('updated-cache' + JSON.stringify(togglesChanged)); // contains an array of toggles that changed in the last update
});

client.initialise(function(err) {

    if(err){
        throw err;
    }

    console.log(client.getOrDefault("toggle2", true));
});
```

### Important Note

The "error" event must be subscribed to, otherwise errors will cause the application to exit

```javascript
client.on("error", function(err) { });
```

## Etcd
{'fraction_non_alphanumeric': 0.1668029435813573, 'fraction_numerical': 0.01349141455437449, 'mean_word_length': 4.498876404494382, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '391499', 'n_tokens_mistral': 883, 'n_tokens_neox': 837, 'n_words': 165}