Skip to content

Instantly share code, notes, and snippets.

View zerobias's full-sized avatar
💭
Set your status

Dmitry zerobias

💭
Set your status
View GitHub Profile
@zerobias
zerobias / flow-path-function.js
Created December 28, 2017 00:07
Infinite nested property lookup in flow
//@flow
declare function deepSeq<P>(
...path: P
): $TupleMap<P, <T, Prop>(prop: Prop) => T => $ElementType<T, Prop>>
declare var pipe: $ComposeReverse
const target: 'target' = 'target'
@zerobias
zerobias / do-notation.js
Created January 2, 2018 09:12
Do notation in js
export function Do(generatorFunction) {
const generator = generatorFunction()
return function next(error, v) {
const res = generator.next(v)
if (res.done)
return res.value
else
@zerobias
zerobias / redux-act.js
Created January 8, 2018 23:01
Flow redux-act typings for making redux stores, entirely typed by action's payloads
declare module 'redux-act' {
/**
* Single "action" as it referenced from classic redux
* @typedef {{ type: string, payload: P }} Act.<P>
* @template P
*/
declare export
type Act</*::+*/P = mixed> = {
@zerobias
zerobias / fs-extra.js
Last active April 12, 2025 23:15
Flow typings delaration for fs-extra
declare module 'fs-extra' {
import type {
createReadStream as createReadStreamType,
createWriteStream as createWriteStreamType,
} from 'fs'
declare export var createReadStream: $PropertyType<
$Exports<'fs'>,
'createReadStream',
>
@zerobias
zerobias / effector.js
Last active January 18, 2018 21:15
Effector cheatsheet
import {Stream, fromPromise} from 'most'
import {message, effect, Effect, Message} from 'effector'
type State = {
currentUser: number,
}
/**
* Plain async function
*/
@zerobias
zerobias / .flowconfig
Last active January 25, 2018 09:48
More effective flow typings
[options]
module.name_mapper='^most-subject$' -> '<PROJECT_ROOT>/most-subject'
@zerobias
zerobias / most.js
Created January 24, 2018 06:54
most flow typings
//@flow
export type SeedValue<S, V> = {
seed: S,
value: V,
}
export type TimeValue<V> = {
/*::+*/time: number,
/*::+*/value: V
}
//@flow
import type {Stream} from 'most'
function intoAsync<T>(str: Stream<T>): $AsyncIterable<T, void, any> {
let isEnd = false
let ask: Array<Dispose<T>> = []
let tell: Array<T> = []
const end = str.observe(t => {
if (ask.length > 0) {
@zerobias
zerobias / effects.js
Last active February 11, 2018 21:20
Effector example
//@flow
import {
ping,
submitLogin,
requestAuth,
showNotification,
} from './events'
import type {State} from './state'
@zerobias
zerobias / .eslintrc.yml
Created February 28, 2018 20:26
.eslintrc
parser: babel-eslint
parserOptions:
ecmaVersion: 8
ecmaFeatures:
experimentalObjectRestSpread: true
extends:
- 'plugin:flowtype/recommended'
plugins:
- babel
- flowtype