I hereby claim:
- I am ca057 on github.
- I am christianost (https://keybase.io/christianost) on keybase.
- I have a public key ASBmdr_2SLX6UID5Ht5-KM71NKvqJigG7uNzNnLvzxMEngo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
import React, { PropTypes } from 'react'; | |
import { | |
StyleSheet, | |
View, | |
Text, | |
} from 'react-native'; | |
const styles = StyleSheet.create({ | |
textContainer: { | |
flexDirection: 'row', |
// @flow | |
import { flip, concat } from 'ramda'; | |
type AppendString = | |
| ((end: string) => (base: string) => string) | |
| ((end: string, base: string) => string); | |
/** | |
* Appends a string to another string, can be used curried. | |
* | |
* @example |
// @flow | |
import { compose, objOf, mergeAll, map, view, lensProp } from 'ramda'; | |
type MergeByKey = (key: string) => (Array<Object>) => Object; | |
/** | |
* Provided a key, this function returns a function which merges an array of nested objects. | |
* | |
* @example | |
* // Given two objects: | |
* const data1 = { key: { subStructure1: value1 } }; |
import { v4 } from 'uuid'; | |
import { map, is } from 'ramda'; | |
const isObject = is(Object); | |
const isDate = is(Date); | |
const isRegExp = is(RegExp); | |
export const assignIds = data => { | |
if (Array.isArray(data)) { | |
return data.map(assignIds); |
const duplicates = input => { | |
if (!Array.isArray(input)) return []; | |
const workingCopy = [...input]; | |
const duplicatesSet = new Set(); | |
// length of 1: no duplicate or already found | |
while (workingCopy.length > 1) { | |
const element = workingCopy.shift(); | |
if (workingCopy.includes(element)) { |
/** | |
* Asynchronously retry a given task the given times, but as least as long as the task does not | |
* throw an error or returns the first time. The return value is a promise with the value | |
* of the rejected/resolved task. | |
*/ | |
export const retryAsync = (times, task) => { | |
if (!task || typeof task !== 'function' || times < 0) { | |
throw new TypeError( | |
'No task passed or task is not of type function or times is a negative value.' | |
); |
const { performance } = require('perf_hooks'); | |
const express = require('express'); | |
const expressRequestDurationMiddleware = (req, res, next) => { | |
performance.mark('request.start'); | |
const end = res.end; | |
res.end = (...args) => { | |
performance.mark('request.end'); |
/** | |
* Curried higher-order function taking a predicate and an actual resolver function. In case the | |
* predicate returns true, an empty list is returned, otherwise the result of the actual resolver function. | |
* | |
* Both the predicate and the resolver function will get the all arguments as a standard resolver function. | |
*/ | |
const condResolveEmptyList = predicate => resolver => ( | |
data, | |
args, | |
context, |
import { combineReducers, Action } from '@reduxjs/toolkit'; | |
const withClearStateOnAction = <S = any>(clearStateAction: Action) => ( | |
reducer: Reducer<S | undefined, Action>, | |
) => (state: S, action: Action) => { | |
if (clearStateAction.type === action.type) { | |
return reducer(undefined, clearStateAction); | |
} | |
return reducer(state, action); | |
}; |