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 uranus = {}; | |
const trace = label => value => { | |
console.log(`${ label }: $ { value }`); | |
return value; | |
} | |
Object.defineProperty(uranus, 'compose', { | |
value: (...fns) => value => fns.reduceRight((g,f) => f(g), value), | |
configurable: false |
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 setState = x => { | |
let _x = x; | |
return [ | |
_x, | |
(newX) => { | |
_x += newX; | |
return _x; | |
} | |
]; | |
} |
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
function throttle (func, delay, watch) { | |
watch && clearTimeout(watch); | |
return setTimeout(func, delay) | |
} | |
function callSearchApi(v) { | |
console.log(v); | |
} | |
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 ModuleA = (function traceA(){ | |
function log(){ | |
console.log(this.foo); | |
} | |
function bar(){ | |
this.foo = 'bar'; | |
log.call(this, null); | |
} |
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 function Required(target: object, propertyKey: string) { | |
console.log('required ....'); | |
Object.defineProperty(target, propertyKey, { | |
get () { | |
throw new Error(`Attribute ${propertyKey} is required`); | |
}, | |
set (value) { | |
Object.defineProperty(target, propertyKey, { value, writable: true, configurable: true }); | |
}, | |
}); |
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 interface Iterator<T> { | |
next(): T; | |
hasNext(): boolean; | |
} | |
export interface Aggregator<T> { | |
createIterator(): Iterator<T>; | |
} | |
export class ConcreteIterator<IteratorType> implements Iterator<IteratorType> { |
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 once = (fn) => { | |
return (...args) => { | |
fn && fn(...args); | |
fn = null | |
} | |
} | |
const thisManyTimes = (fn, limit) => { | |
return (...args) => { | |
if(limit > 0) { |
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
//*********************** as libraries *********************** | |
const pipe = (...functions) => v => functions.reduce((y, f) => f(y), v) | |
const mapFn = f => arr => arr.map(f) | |
const trace = key => value => console.log(`${key} : ${value}`) | |
// TODO: need improvements | |
const expect = actual => ({ | |
toBe: expected => { | |
if (Array.isArray(expected)) { | |
if (expected.length > 0 && expected.length === actual.length) { |
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
#include <iostream> | |
#include <vector> | |
#include <algorithm> | |
#include <math.h> | |
enum class PointType { | |
cartesian, | |
polar | |
}; |
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
#include <iostream> | |
class Animal { | |
public: | |
Animal(std::string name): _name(name){} | |
~Animal(){ | |
_name = ""; | |
std::cout << "deleted animal\n"; | |
} | |