This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum LoggerLevel { | |
VERBOSE = 0, | |
DEBUG = 1, | |
INFO = 2, | |
WARN = 3, | |
ERROR = 4 | |
} | |
enum ConsoleMethod { | |
log = 'log', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Tiny Redux | |
export const combineReducers = reducers => { | |
return (state = {}, action) => { | |
return Object.keys(reducers).reduce( | |
(nextState, key) => { | |
nextState[key] = reducers[key](state[key], action) | |
return nextState | |
}, | |
{} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 寄生组合继承 (相对完美的继承范式) | |
// 父类 | |
function Animal (name) { | |
// 实例方法 | |
this.name = name | |
this.sleep = function () { | |
console.log(`${this.name} is sleeping...`) | |
} |
OlderNewer