This file contains 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
interface Powerful { | |
calculateFightPower(): number; | |
} | |
abstract class Character { | |
protected _power: number; | |
protected _name: string; | |
constructor(name:string, power: number = 0 ){ | |
this._name = name; |
This file contains 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
abstract class Character { | |
protected _power: number; | |
private _name: string; | |
constructor(name:string, power: number = 0 ){ | |
this._name = name; | |
this._power = power; | |
} | |
calculateFightPower(): number { |
This file contains 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
class Character { | |
private _power: number; | |
private _name: string; | |
private _type: string; // Heroe, Villain or Human | |
constructor(name:string, power: number = 0, type: string ){ | |
this._name = name; | |
this._power = power; | |
this._type = type; | |
} |
This file contains 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
class Character { | |
_name!: string; | |
constructor(name: string){ | |
this._name = name; | |
} | |
get name(): string { | |
return this._name; | |
} |
This file contains 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
class Character { | |
_name!: string; | |
constructor(name: string){ | |
this._name = name; | |
} | |
get name(): string { | |
return this._name; | |
} |
This file contains 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
/** Operators */ | |
const map = (mapper) => (reducer) => (acc, val) => reducer(acc, mapper(val)); | |
const filter = (predicate) => (reducer) => (acc, val) => | |
predicate(val) ? reducer(acc, val) : acc; | |
const some = (predicate) => (_) => (acc, val) => | |
acc !== true ? predicate(val) : true; | |
/** */ |
This file contains 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
buttonNoMemoization.addEventListener('click', () => { | |
console.clear(); | |
const times = inputTimes.value; | |
console.log('NOT USING MEMOIZATION'); | |
console.log('first execution'); | |
for (let i = times; i > 0; i--) { | |
params.forEach(param => measureTime(isUniqueExponential, param)); | |
} | |
console.log('---- FINISHED ----'); |
This file contains 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
buttonMemoization.addEventListener('click', () => { | |
console.clear(); | |
const times = inputTimes.value; | |
const isUniqueExponentialMemoized = memoize(isUniqueExponential); //Decorator Pattern | |
console.log('USING MEMOIZATION'); | |
console.log('first execution'); | |
for (let i = times; i > 0; i--) { | |
params.forEach(param => measureTime(isUniqueExponentialMemoized, param)); | |
} | |
console.log('---- FINISHED ----'); |
This file contains 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
import { | |
Middleware, | |
RoleMiddleware, | |
ThrottlingMiddleware, | |
UserExistsMiddleware, | |
} from "./middlewares"; | |
import { REQUEST_PER_MINUTE, USERS } from "./app.constants"; | |
import { Server } from "./server"; |
This file contains 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
export const USERS = { | |
ADMIN: { | |
email: "admin@example.com", | |
password: "admin", | |
}, | |
USER: { | |
email: "user@example.com", | |
password: "user", | |
}, | |
}; |
NewerOlder