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
/** Server-side */ | |
interface APIErrorDTO { | |
code: string; | |
message: string; | |
} | |
/** @todo Fix types */ | |
interface APIErrorArguments { | |
error: unknown; | |
status: 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 Maybe<T> { | |
public value: T | null | undefined; | |
constructor(value?: T) { | |
this.value = value; | |
} | |
public fmap<R>(transform: (value: T) => R | null | undefined): Just<R> | Nothing { | |
if (this.value === undefined || this.value === null) { return new Nothing(); } | |
return Maybe.fromNullable<R>(transform(this.value)); |
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
(function () { | |
'use strict'; | |
EventTarget.prototype.on = function (event, listener, options) { | |
if (arguments.length < 2) | |
throw new TypeError("Failed to execute 'on' on 'EventTarget': 2 arguments required, but only " + arguments.length + " present."); | |
var typeOfListener = typeof listener; | |
if (typeOfListener !== 'function' && typeOfListener !== 'object') | |
throw new TypeError("Failed to execute 'on' on 'EventTarget': The callback provided as parameter 2 is not an object."); |
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
(function () { | |
'use strict'; | |
var MONTHS_NAME = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']; | |
var DAYS_NAME = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']; // Weekdays | |
var DEFAULT_FORMAT = 'YYYY-MM-DDTHH:mm:ssZ'; | |
var FORMAT_REGEX = /\[.*?\]|Y{2,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g; | |
var STRIP_BRACKETS_REGEX = /\[|\]/g; | |
Date.prototype.addDate = function (value) { // Day |
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
const elementProperties = (input) => { | |
input = input.trim(); | |
const hasAttrs = input.indexOf(' ') + 1; | |
if (!hasAttrs) return {name: input, attributes: {}}; | |
const inputAttrs = input.substring(hasAttrs, input.length).trim(); | |
const length = inputAttrs.length; | |
const attrs = {}; | |
let i = 0; | |
while (i < length) { | |
const start = i; |
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
const generator = function*(i, j) { | |
for (let a = 1; a <= i; a++) { | |
for (let b = 1; b <= j; b++) yield [a, b, a * b]; | |
} | |
}; | |
for (const [i, j, k] of generator(9, 9)) { | |
console.log(`${i} x ${j} = ${k}`); | |
} |