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
export default (property, ascOrDesc = 'asc') => (a, b) => { | |
const asc = ascOrDesc === 'asc' | |
const valA = a[property] | |
const valB = b[property] | |
if (valA > valB) { | |
return asc ? 1 : -1 | |
} | |
if (valB > valA) { | |
return asc ? -1 : 1 | |
} |
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
// compare to https://bundlephobia.com/[email protected] | |
export default (obj, keys = []) => { | |
const copy = Object.assign({}, obj) | |
keys.forEach(key => { | |
delete copy[key] | |
}) | |
return copy | |
} |
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
[ | |
{ | |
"location": { | |
"lat": 42.2152227, | |
"lng": -89.4553088 | |
}, | |
"weight": 4 | |
}, | |
{ | |
"location": { |
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
import gqlFetch from '../helpers/gql-fetch' | |
import config from '../config' | |
export default { | |
name: 'extraArgs', | |
getExtraArgs: store => { | |
return { | |
gqlFetch: gqlFetch({ | |
apiUrl: config.apiUrl, | |
getToken: () => store.selectAuthToken(), |
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
<html> | |
<head> | |
<style> | |
body { | |
font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; | |
font-weight: 300; | |
color: gray; | |
} | |
badass-list-thing { |
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
// what if this was something browsers just gave us? | |
const { vdom } = document; | |
// this is same idea as React.createElement | |
// or any of the other similar appraoches | |
const newVirtualDom = vdom('div', {className: 'some-class'}, [ | |
vdom('p', null, 'hi') | |
]) | |
// if preferred, someone could easily use JSX and precompile it |
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
export default (fn, ...args) => { | |
if (typeof window !== 'undefined') { | |
fn(...args) | |
} else { | |
const last = args.slice(-1)[0] | |
let argString = '' | |
if (typeof last !== 'undefined') { | |
argString = args.reduce((accum, val, index) => { | |
const type = typeof val | |
const isLast = index === args.length - 1 |
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
import { createFilter } from 'rollup-pluginutils' | |
function assign (target, source) { | |
Object.keys(source).forEach((key) => { | |
target[key] = source[key] | |
}) | |
return target | |
} | |
const DEFAULT_HEADER = 'import React from \'react\';' |
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
import { DO_THING, DO_OTHER_THING, SOMETHING_ELSE } from './actions' | |
export default (state, { type, payload }) => { | |
switch (type) { | |
case DO_THING: { | |
// by using blocks in our case statements we can create locally scoped vars | |
// and returning early keeps things readable | |
const scopedVariable = payload.thing | |
return Object.assign({}, state, {do: scopedVariable}) | |
} |
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
export default (cb) => { | |
ensurePromise(() => { | |
ensureFetch(cb) | |
}) | |
} | |
const ensurePromise = (cb) => { | |
if (typeof Promise === 'undefined') { | |
require.ensure([], (require) => { | |
require('imports?this=>window!es6-promise') |
NewerOlder