with babel-plugin-macros 🎣
Kent C. Dodds
Utah
1 wife, 4 kids
PayPal, Inc.
@kentcdodds
if you are able
if (
props.user &&
props.user.friends &&
props.user.friends[0] &&
props.user.friends[0].friends
) {
console.log('this user has friends!')
}
if (idx(props, p => p.user.friends[0].friends)) {
console.log('this user has friends!')
}
if (
props.user &&
props.user.friends &&
props.user.friends[0] &&
props.user.friends[0].friends
) {
console.log('this user has friends!')
}
{
plugins: [
"idx"
]
}
import _ from 'lodash'
import { add } from 'lodash/fp'
const addOne = add(1)
_.map([1, 2, 3], addOne)
import _add from 'lodash/fp/add'
import _map from 'lodash/map'
const addOne = _add(1)
_map([1, 2, 3], addOne)
{
plugins: [
"idx",
"lodash"
]
}
const x = preval`module.exports = 1`
const fileLastModifiedDate = preval.require(
'./get-last-modified-date'
)
const x = 1
const fileLastModifiedDate = '2017-07-05'
const x = 1
const fileLastModifiedDate = '2017-07-05'
{
plugins: [
"idx",
"lodash",
"preval"
]
}
import idx from 'idx.macro'
import _ from 'lodash.macro' // this doesn't exist yet
import { add } from 'lodash.macro/fp.macro' // this either
import preval from 'preval.macro'
if (idx(props, _ => _.user.friends[0].friends)) {
console.log('this user has friends!')
}
const addOne = add(1)
_.map([1, 2, 3], addOne)
const x = preval`module.exports = 1`
const fileLastModifiedDate = preval.require(
'./get-last-modified-date'
)
{"plugins": ["macros"]}