Skip to content

Instantly share code, notes, and snippets.

@FbN
FbN / A.js
Created March 9, 2021 16:12
Clojure Protocols Inspired last param type polimorfism
export const of = x => ({ '@@type': 'A', x })
export const f1 = a => a.x
f1.arity = 1
export const f2 = c => a => a.x + c
f2.arity = 2
export const f3 = d => c => a => a.x + c + d
f3.arity = 3
@FbN
FbN / A.js
Created March 9, 2021 14:03
Closure Like Protocol
export const f1 = a => a.x
f1.arity = 1
export const f2 = c => a => a.x + c
f2.arity = 2
export const f3 = d => c => a => a.x + c + d
@FbN
FbN / resume.json
Last active December 4, 2020 13:02
{
"basics": {
"name": "Fabiano Taioli",
"label": "Developer",
"picture": "http://www.gravatar.com/avatar/e700256406c0274e61418a575900dc76.png",
"email": "[email protected]",
"phone": "(+39) 3471150092",
"website": "",
"summary": "Growing up with Internet. Enthusiast of all open source technologies that are part of the web and their applications. I am discovering and loving functional programming more and more.",
"location": {
@FbN
FbN / xstream.js
Created November 1, 2019 13:18
xstream version
function todoList (deferred) {
const ping$ = xs.create({
start: function (listener) {
setTimeout(() => {
;[...Array(config.iterations).keys()].forEach(i =>
listener.next(i)
)
}, 0)
},
@FbN
FbN / most-core.js
Created November 1, 2019 13:16
Most/Core Version
function todoList (deferred) {
const ping$ = fromArray([...Array(config.iterations).keys()])
const todo$ = multicast(map(todo, ping$))
const old$ = merge(
map(todo => (todo.id % 4 === 0 ? todo : {}), take(1, todo$)),
filter(todo => todo.id % 4 === 0, skip(1, todo$))
)
const sample$ = snapshot(
(old, last) => ({...last, old}),
old$,
@FbN
FbN / imperative.js
Created November 1, 2019 13:14
Imperative Version
function todoList (deferred) {
const list = []
let old = {}
for (let i = 0; i < config.iterations; i++) {
const t = todo()
old = t.id % 4 === 0 ? { ...t } : old
t.old = { ...old }
list.push(t)
}
return deferred.resolve(list)
@FbN
FbN / RxJS.js
Last active November 1, 2019 13:15
RxJS version
function todoList (deferred) {
const ping$ = new R.Observable(listener => {
setTimeout(() => {
;[...Array(config.iterations).keys()].forEach(i => listener.next(i))
}, 0)
})
const todo$ = RO.share()(RO.map(todo)(ping$))
const old$ = RO.startWith({})(RO.filter(todo => todo.id % 4 === 0)(todo$))
const sample$ = RO.map(([last, old]) => ({
...last,
import { induce as imperativeInduce } from '../imperative.mjs'
import { induce as mostInduce } from '../most.mjs'
import { induce as xstreamInduce } from '../xstream.mjs'
import { induce as rxjsInduce } from '../rxjs.mjs'
import { typeWriter } from './common.mjs'
import memwatch from '@HolgerFrank/node-memwatch'
const type = process.argv[2]
const cycles = parseInt(process.argv[3])
import { induce as mostInduce } from '../most.mjs'
import { induce as xstreamInduce } from '../xstream.mjs'
import { induce as rxjsInduce } from '../rxjs.mjs'
import { induce as imperativeInduce } from '../imperative.mjs'
import { typeWriter } from './common.mjs'
import memwatch from '@HolgerFrank/node-memwatch'
const type = process.argv[2]
const cycles = parseInt(process.argv[3])
@FbN
FbN / operators.csv
Created November 1, 2019 12:50
Operators comparison
RxJS Xstream Most/Core
map map map
withLatestFrom sampleCombine snapshot
scan fold scan
take take take
filter filter filter
share - multicast