Skip to content

Instantly share code, notes, and snippets.

View Caballerog's full-sized avatar
:octocat:
live$.pipe(map(person => person.teach(me)),tap(me => me.betterEachDay())))

Carlos Caballero Caballerog

:octocat:
live$.pipe(map(person => person.teach(me)),tap(me => me.betterEachDay())))
View GitHub Profile
interface Powerful {
calculateFightPower(): number;
}
abstract class Character {
protected _power: number;
protected _name: string;
constructor(name:string, power: number = 0 ){
this._name = name;
abstract class Character {
protected _power: number;
private _name: string;
constructor(name:string, power: number = 0 ){
this._name = name;
this._power = power;
}
calculateFightPower(): number {
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;
}
class Character {
_name!: string;
constructor(name: string){
this._name = name;
}
get name(): string {
return this._name;
}
class Character {
_name!: string;
constructor(name: string){
this._name = name;
}
get name(): string {
return this._name;
}
/** 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;
/** */
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 ----');
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 ----');
import {
Middleware,
RoleMiddleware,
ThrottlingMiddleware,
UserExistsMiddleware,
} from "./middlewares";
import { REQUEST_PER_MINUTE, USERS } from "./app.constants";
import { Server } from "./server";
export const USERS = {
ADMIN: {
email: "admin@example.com",
password: "admin",
},
USER: {
email: "user@example.com",
password: "user",
},
};