From 600f2eb529fb8c92ce581c4e73c539e508806563 Mon Sep 17 00:00:00 2001 From: Joe Fleming Date: Fri, 15 Apr 2016 16:05:43 -0700 Subject: [PATCH] make index the first param --- src/index.js | 5 +++-- test/index.js | 6 ++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/index.js b/src/index.js index 94ab2ae..231348b 100644 --- a/src/index.js +++ b/src/index.js @@ -3,12 +3,13 @@ import createClient from './helpers/create_client'; import { omit } from 'lodash'; export default class Elastique extends events.EventEmitter { - constructor(options = {}) { - if (!options.index) throw new Error('Must specify an index to write to'); + constructor(index, options = {}) { + if (!index) throw new Error('Must specify an index to write to'); super(); this.ready = true; + this.index = index; this.settings = Object.assign({ interval: '1w', timeout: 10000, diff --git a/test/index.js b/test/index.js index a801422..f75e46c 100644 --- a/test/index.js +++ b/test/index.js @@ -9,8 +9,7 @@ describe('Elastique class', function () { }); it('should throw with an invalid host', function () { - const init = () => new Elastique({ - index: 'elastique', + const init = () => new Elastique('elastique', { client: { host: 'nope://nope' } }); @@ -18,8 +17,7 @@ describe('Elastique class', function () { }); it('should throw with invalid hosts', function () { - const init = () => new Elastique({ - index: 'elastique', + const init = () => new Elastique('elastique', { client: { hosts: [{ host: 'localhost', protocol: 'nope' }] } });