Skip to content

Commit

Permalink
#24 Rewrite to es6 (#26)
Browse files Browse the repository at this point in the history
* Add _interface_ IStupidPlayer

* Refactor stupid-player using es6 syntax

* Fix editorconfig

* Fix IStupidPlayer for node.js

* Fix {I, }StupidPlayer for node.js v4, v5

* Use arrow function in class. Move hooks from stupid-player-old

* Remove set/get, add methods

* Bind context on hooks.

* Move code blocks
  • Loading branch information
kicumkicum authored Jun 19, 2016
1 parent 22eb9d9 commit ec901eb
Show file tree
Hide file tree
Showing 3 changed files with 370 additions and 358 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ insert_final_newline = true
charset = utf-8

# Indentation override for all JS under lib directory
[src/**.js]
[**.js]
indent_style = tab

# Matches the exact files either package.json or .travis.yml
Expand Down
91 changes: 91 additions & 0 deletions lib/interfaces/i-stupid-player.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
const events = require('events');



/**
* @interface
*/
module.exports = (function() {
'use strict';
return class IStupidPlayer extends events.EventEmitter {
constructor() {
super();

/**
* @const {string}
*/
this.EVENT_PLAY = 'play';

/**
* @const {string}
*/
this.EVENT_STOP = 'stop';

/**
* Fired with: {number} volume
* @const {string}
*/
this.EVENT_VOLUME_CHANGE = 'volume-change';

/**
* Fired with: string
* @const {string}
*/
this.EVENT_ERROR = 'error';
}

/**
* @param {string} url
* @return {Promise<undefined>}
*/
play(url) {
throw 'IStupidPlayer.play not implemented';
}

/**
* @return {Promise<undefined>}
*/
pause() {
throw 'IStupidPlayer.pause not implemented';
}

/**
* @return {Promise<undefined>}
*/
stop() {
throw 'IStupidPlayer.stop not implemented';
}

/**
* @return {number} 0..100
*/
getVolume() {
throw 'IStupidPlayer.[[Get]]volume not implemented';
}

/**
* @param {number} value 0..100
*/
setVolume(value) {
throw 'IStupidPlayer.[[Set]]volume not implemented';
}

/**
* @return {IStupidPlayer.State}
*/
get state() {
throw 'IStupidPlayer.[[Get]]state not implemented';
}

/**
* @enum {string}
*/
static get State() {
return {
PAUSE: 'pause',
PLAY: 'play',
STOP: 'stop'
};
}
};
})();
Loading

0 comments on commit ec901eb

Please sign in to comment.