I hereby claim:
- I am benadamstyles on github.
- I am benadamstyles (https://keybase.io/benadamstyles) on keybase.
- I have a public key ASCoqtUtnEKNadbubzwnDKTw-1hG6Da4ULe2g2-GU-wgZgo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
import {Map} from 'immutable' | |
// without Rapt | |
const processUser = user => { | |
log(user) | |
let userMap = Map(user) | |
if (emailHasBeenVerified) { | |
userMap = userMap.set('verified', true) | |
} | |
syncWithServer(userMap) |
// Below are some useful Flow utility type functions, some I've written and some I've found on the web. | |
// All contributions welcome! | |
// Extracting a data type from a maybe type, e.g. getting `string` from `?string` | |
type _ExtractFromMaybe<T, M: ?T> = T | |
export type ExtractFromMaybe<M> = _ExtractFromMaybe<*, M> | |
// FROM https://hackernoon.com/redux-flow-type-getting-the-maximum-benefit-from-the-fewest-key-strokes-5c006c54ec87 | |
// Extracting the type of a function's return value | |
type _ExtractReturn<R, F: (...args: any[]) => R> = R |
I hereby claim:
To claim this, I am signing this object:
var uuidCount = 0 | |
function uuid() { | |
return uuidCount++ | |
} | |
function arrayFrom(arrayLike) { | |
var array = [] | |
for (var i = 0; i < arrayLike.length; i++) { | |
array.push(arrayLike[i]) |
var crosslinkStyleCached | |
function getCrosslinkStyle(doc) { | |
if (!crosslinkStyleCached) crosslinkStyleCached = doc.paragraphStyles.item('crosslink') | |
return crosslinkStyleCached | |
} | |
function createHyperlink(dest, name, doc) { | |
var ip = app.selection[0], | |
story = ip.parentStory, |
var uuidCount = 0 | |
function uuid() { | |
return uuidCount++ | |
} | |
function process(doc, paraStyle) { | |
app.findTextPreferences = NothingEnum.nothing | |
app.changeTextPreferences = NothingEnum.nothing |
const keypaths = []; | |
const values = []; | |
const mapper = (input, keypath = '') => { | |
if (!_.isObject(input)) { | |
keypaths.push(keypath); | |
values.push(input); | |
} else { | |
const isArray = Array.isArray(input); |
// for rebuilding an array without reassignment | |
macro rebuild { | |
rule {$oldArr $newArr} => { | |
$oldArr.length = 0 | |
$oldArr.push.apply($oldArr, $newArr) | |
} | |
} | |
rebuild arr newArr; |
smoothScroll = speed => { | |
var endPos, comp, step; | |
const goScroll = function goScroll() { | |
scrollBy(0, step); | |
if (comp(window.scrollY, endPos)) { | |
window.requestAnimationFrame(goScroll); | |
} | |
}, | |
runner = end => { | |
endPos = end; |