From 4580fcbfb6e7c37b34df7ab2ef0a60e0d675bcb9 Mon Sep 17 00:00:00 2001 From: _Ghostrick_ Date: Mon, 25 Dec 2017 12:35:35 +0900 Subject: [PATCH] fix indent --- .editorconfig | 7 +++++ index.js | 2 +- lib/connect.js | 82 +++++++++++++++++++++++++------------------------- lib/search.js | 18 +++++------ 4 files changed, 58 insertions(+), 51 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..db2a145 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,7 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +indent_style = space +indent_size = 2 diff --git a/index.js b/index.js index 80de480..ee5dafd 100644 --- a/index.js +++ b/index.js @@ -1,4 +1,4 @@ const search = require('./lib/search'), - Connecter = require('./lib/connect') + Connecter = require('./lib/connect') module.exports = { search, Connecter } diff --git a/lib/connect.js b/lib/connect.js index 8d1c984..d79cc78 100644 --- a/lib/connect.js +++ b/lib/connect.js @@ -1,49 +1,49 @@ const googletts = require('google-tts-api'), - Client = require('castv2-client').Client, - DefaultMediaReceiver = require('castv2-client').DefaultMediaReceiver + Client = require('castv2-client').Client, + DefaultMediaReceiver = require('castv2-client').DefaultMediaReceiver const Connecter = (() => { - const playMethod = Symbol('playMethod') - - class Connecter { - - constructor(ip){ - this.ip = ip - this.lang = 'en' - } - - config(options = {}) { - this.lang = options.lang || this.lang - } - - async speak(message, speed = 1, timeout = 3000) { - const url = await googletts(message, this.lang, speed, timeout) - return await this[playMethod](url) - } - - async [playMethod](url) { - - const client = new Client() - const params = { - contentId: url, - contentType: 'audio/mp3', - streamType: 'BUFFERED' - } - - const status = await new Promise((resolve, reject) => client.connect(this.ip, () => { - client.launch(DefaultMediaReceiver, (err, player) => { - player.load(params, { autoplay: true }, (err, status) => { - err ? reject() : resolve(status) - }) - }) - })) - - client.close() - return status - } + const playMethod = Symbol('playMethod') + + class Connecter { + + constructor(ip){ + this.ip = ip + this.lang = 'en' + } + + config(options = {}) { + this.lang = options.lang || this.lang + } + + async speak(message, speed = 1, timeout = 3000) { + const url = await googletts(message, this.lang, speed, timeout) + return await this[playMethod](url) + } + + async [playMethod](url) { + + const client = new Client() + const params = { + contentId: url, + contentType: 'audio/mp3', + streamType: 'BUFFERED' + } + + const status = await new Promise((resolve, reject) => client.connect(this.ip, () => { + client.launch(DefaultMediaReceiver, (err, player) => { + player.load(params, { autoplay: true }, (err, status) => { + err ? reject() : resolve(status) + }) + }) + })) + + client.close() + return status } + } - return Connecter; + return Connecter; })() diff --git a/lib/search.js b/lib/search.js index f66bbed..53d378b 100644 --- a/lib/search.js +++ b/lib/search.js @@ -1,18 +1,18 @@ const mdns = require('mdns'), - browser = mdns.createBrowser(mdns.tcp('googlecast')) + browser = mdns.createBrowser(mdns.tcp('googlecast')) async function search(waitTime = 1000) { - let services = [] + let services = [] - browser.start() - browser.on('serviceUp', service => { services.push(service) }) - await new Promise(resolve => setTimeout(resolve, 1000)) - browser.stop() + browser.start() + browser.on('serviceUp', service => { services.push(service) }) + await new Promise(resolve => setTimeout(resolve, 1000)) + browser.stop() - return services - .filter(service => { if(service.txtRecord.md === 'Google Home') return service }) - .map(service => { return Object.assign(service.txtRecord, {address: service.addresses[0]}) }) + return services + .filter(service => { if(service.txtRecord.md === 'Google Home') return service }) + .map(service => { return Object.assign(service.txtRecord, {address: service.addresses[0]}) }) } module.exports = search