Skip to content

Instantly share code, notes, and snippets.

@swashcap
Created June 18, 2019 23:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save swashcap/1f14df7facfb46f39e46889b09334f7b to your computer and use it in GitHub Desktop.
Save swashcap/1f14df7facfb46f39e46889b09334f7b to your computer and use it in GitHub Desktop.
const assert = require('assert')
const get = require('lodash/fp/get')
const { createSelector } = require('reselect')
const list = get('list')
const getId = createSelector(
list,
get('id')
)
assert.equal(getId(), undefined)
assert.equal(getId({}), undefined)
assert.equal(getId({ list: '' }), undefined)
assert.equal(getId({ list: {} }), undefined)
assert.equal(getId({ list: { id: 'bananas' } }), 'bananas')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment