-
t('конструктор')
нульнарный конструкторt('конструктор', тип)
обычный конструкторt([ t('конструктор'), t('конструктор')] )
перечесление, суммаt.forall(a => t('конструктор', a) )
конструктор принимающий любой тип
t.recursive(thisType => t('конструктор', thisType) )
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
// ----- lib ----- | |
const plus = (a, b) => a + b | |
const mul = (a, b) => a * b | |
const sum = arr => arr.reduce(plus) | |
const zip = (f, arr1, arr2) => Array.from({ length: Math.min(arr1.length, arr2.length) }, (_, i) => ( | |
f(arr1[i], arr2[i]) | |
)) | |
compose = (...fns) => |
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
/* | |
https://ru.stackoverflow.com/questions/664746/%D0%9A%D0%BE%D1%81%D0%B8%D0%BD%D1%83%D1%81%D0%BD%D0%BE%D0%B5-%D1%81%D1%85%D0%BE%D0%B4%D1%81%D1%82%D0%B2%D0%BE-%D0%BA%D0%BE%D1%81%D0%B8%D0%BD%D1%83%D1%81%D0%BD%D0%B0%D1%8F-%D0%BC%D0%B5%D1%80%D0%B0-%D0%B4%D0%BB%D1%8F-%D1%81%D1%82%D1%80%D0%BE%D0%BA | |
type Docs = Array<string> | |
type Words = Array<string> | |
type MapWordCount = {[string]: number} | |
type MapWordTF = {[string]: number} | |
type DocsMapWordTF = Array<MapWordTF> |
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
// @flow | |
type F = <P, D, R>(P => (D => R)) => (P => R) | |
type BindActions<O: {[key: string]: Function}> = $ObjMap<O, F> | |
type Dispatch = string | |
const actionFoo = (a: number) => (d: Dispatch): Promise<number> => Promise.resolve(a) | |
const actionBar = (a: string) => (d: Dispatch): Promise<Array<string>> => Promise.resolve([a]) |
у каджого сайта есть своя бизнесс логика, свои правила вывода информации на сайте и взаимодейсвие пользователя с сайтом.
В реакт приложении должен существовать какой-то роутинг, который будет объявлять правила, по каким роутам какой компонент отдавать, будем называть такой компонент страницей
бизнес логика может ставить такие правила, что некоторые страницы могут содержать в себе одни и те же компоненты которые должны быть у пользователя на виду всегда, например это может быть меню, которое доступно на всех страницах,
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 GenForm { | |
static propTypes = { | |
type: pt.oneOf(['checkbox', radioButton]).isRequared, | |
description: pt.string, | |
radioOptions: pt.arrayOf(pt.shape({ | |
name: pt.string, | |
description: pt.string, | |
})), | |
} |
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
var flattenObject = function(ob) { | |
var toReturn = {}; | |
for (var i in ob) { | |
if (!ob.hasOwnProperty(i)) continue; | |
if ((typeof ob[i]) == 'object') { | |
var flatObject = flattenObject(ob[i]); | |
for (var x in flatObject) { | |
if (!flatObject.hasOwnProperty(x)) continue; |
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
/* eslint-disable func-names, no-underscore-dangle */ | |
import EventBus from 'vertx3-eventbus-client' | |
import { DelayObserver } from '../lib/delay-observer' | |
import { endpointApi } from './constants' | |
const MyEventBus = (function () { | |
let callbacks = [] | |
const multiEmitter = (type) => (...param) => { |
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
// ------lib------ | |
const getType = (o) => { | |
return Object.prototype.toString.call(o).slice(8,-1).toLocaleLowerCase() | |
} | |
const types = () => { | |
const func = (val) => getType(val) === 'function' | |
const number = (val) => getType(val) === 'number' | |
const string = (val) => getType(val) === 'string' | |
const bool = (val) => getType(val) === 'boolean' |