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
export class StateStore { | |
// La fonction de réduction de ce store | |
#reducer; | |
// L'état courant | |
#currentState; | |
// Les "listeners" intéressés par les changements de l'état géré par ce store | |
#listeners; |
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
("use strict"); | |
/** | |
* Le type des fonctions d'écoute d'un événement. | |
* | |
* @typedef Listener | |
* @type {(...unknown) => void} | |
*/ | |
/** |
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
import { Monad } from "./Monad"; | |
interface EitherType<L, R> extends Monad<R> { | |
isLeft(): boolean; | |
isRight(): boolean; | |
} | |
class Left<L, R> implements EitherType<L, R> { | |
constructor(public readonly left: L) {} |
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
import * as winston from "winston"; | |
const { Console, File } = winston.transports; | |
const { combine, timestamp, logstash, colorize, padLevels, printf, label } = winston.format; | |
const consoleFormat = combine( | |
colorize(), | |
padLevels(), | |
timestamp(), | |
printf(info => `${info.timestamp} ${info.level}: ${info.message}`) |
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
// DOMAIN | |
// ------ | |
interface ShoppingCartDomainProbe { | |
applyDiscountCode(): void; | |
discountCodeLookupFailed(error: string): void; | |
discountCodeLookupSucceeded(): void; | |
discountApplied(amountDiscounted: number): void; | |
} |
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
<!DOCTYPE html> | |
<html lang="fr" dir="ltr"> | |
<head> | |
<meta charset="utf-8"> | |
<title>Sauvegarde Reactive</title> | |
</head> | |
<body> | |
<h1>Sauvegarde Reactive</h1> | |
<p>Types d'accidents</p> | |
<input id="typesAccidents" type="text" /> |
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
const fn = [(x) => x + "a", (x) => x + "b", (x) => x + "c", (x) => x + "d"].reduceRight( | |
(accumulator, currentFn) => { | |
return ((x) => currentFn(accumulator(x))); | |
} | |
); | |
console.log(fn("test")); |