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
fc.assert( | |
fc.property( | |
fc.nat(), fc.nat(), | |
(a, b) => lcm(a, b) * gcd(a, b) === a * b)); |
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
'Istanbul'.toLocaleLowerCase('US') // result: 'istanbul' | |
'Istanbul'.toLocaleLowerCase('TR') // result: 'ıstanbul' |
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 A { | |
a() { } | |
} | |
class B { | |
b() { } | |
} | |
class C extends B { | |
c() { } | |
} | |
class HasStaticNameMethod { |
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 map2 = function<UU extends URIS>(functor: Apply1<UU>) { | |
return function< | |
TypeUUA extends Type<UU, any>, | |
TypeUUB extends Type<UU, any>, | |
R | |
>( | |
fa: TypeUUA, fb: TypeUUB, f: (a: TypeUUA['_A'], b: TypeUUB['_A']) => R): Type<UU, R> { | |
return functor.ap( | |
functor.map( | |
fa, |
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
// success(depth: number, numTries: number, q: number) | |
// | |
// Compute the probability to generate at least one tree with depth superior to `depth` | |
// Given we tried `numTries` times with a probality of having a node of q | |
// | |
// with: | |
// type Tree<T> = Node<T> | Leaf<T> | |
// type Node<T> = { left: Tree<T>, right: Tree<T> } | |
// type Leaf<T> = T | |
// |
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
// Update of tree-depth-proba.js | |
// Supposed to allow to deal with higher values of depth (approximations are done) | |
// success(depth: number, q: Frac) | |
// | |
// Compute the probability to generate at least one tree with depth superior to `depth` | |
// Given we tried 1 times with a probality of having a node of q | |
// | |
// with: | |
// type Tree<T> = Node<T> | Leaf<T> |
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
{ | |
"version": "0.2.0", | |
"configurations": [ | |
{ | |
"name": "Debug Unit Tests", | |
"type": "node", | |
"request": "launch", | |
"runtimeArgs": [ | |
"--inspect-brk", | |
"${workspaceRoot}/node_modules/jest/bin/jest.js", |
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
type EnableIf<T, U, ErrorMessage extends string = never> = T extends true ? U : ErrorMessage; | |
type IsArrayOf<T, U> = T extends U[] ? true : false; | |
function enableIf<T, U>(t: T, u: EnableIf<IsArrayOf<T, U>, U, 'T has to be an array of U'>) { | |
// Code | |
} | |
enableIf([1, 2], 3); | |
enableIf([1, 2], '3'); |
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
type EnableIf<T, U, ErrorMessage extends string = never> = T extends true ? U : ErrorMessage; | |
type Not<T> = T extends true ? false : true; | |
type And<T, U, V = true, W = true, X = true> = T extends true ? U extends true ? V extends true ? W extends true ? X extends true ? true : false : false : false : false : false; | |
type Or<T, U> = T extends true ? true : U extends true ? true : false; | |
type Extends<T, U> = T extends U ? true : false; | |
type IsPrimitive<T> = T extends object ? false : true; | |
type IsNever<T> = [T] extends [never] ? true : false |
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
// Log everything | |
function logAllCalls(ClassType) { | |
for (const k in ClassType.prototype) { | |
try { | |
if (typeof ClassType.prototype[k] !== "function") { | |
continue; | |
} | |
} | |
catch(err) { |