ramda#path JavaScript Examples

The following examples show how to use ramda#path. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GithubSagas.js    From gDoctor with MIT License 6 votes vote down vote up
export function * getUserAvatar (api, action) {
  const { username } = action
  // make the call to the api
  const response = yield call(api.getUser, username)

  if (response.ok) {
    const firstUser = path(['data', 'items'], response)[0]
    const avatar = firstUser.avatar_url
    // do data conversion here if needed
    yield put(GithubActions.userSuccess(avatar))
  } else {
    yield put(GithubActions.userFailure())
  }
}
Example #2
Source File: fhir-references.js    From discovery-mobile-ui with MIT License 6 votes vote down vote up
referenceMap = {
  // each key is a "type" (but not the referenced _resource_ type, eg: "Practitioner")
  // each value operates on a FHIR resource, and returns an Array of reference Objects
  serviceProvider: compose(
    (result) => (result ? [result] : []),
    path(['serviceProvider']),
  ),
  requester: compose(
    (result) => (result ? [result] : []),
    path(['requester']), // may or may not be practitioner?
  ),
  participant: compose(
    map(path(['individual'])), // may or may not be practitioner?
    filter(hasPath(['individual', 'reference'])),
    propOr([], 'participant'),
  ),
}
Example #3
Source File: breakDownAllNodes.js    From gatsby-startbootstrap-agency with MIT License 6 votes vote down vote up
/**
 * break down all data retrieved in index.js
 */
export default function breakDownAllNodes(nodes) {
  const filterByFileName = propFilter(["fields", "fileName"]);
  const filterByDirectoryName = propFilter(["fields", "directoryName"]);

  // top part
  const topNode = nodes.find(filterByFileName(/top/i)) || {};
  // navbar
  const navBarNode = nodes.find(filterByFileName(/navbar/i)) || {};
  // footer
  const footerNode = nodes.find(filterByFileName(/footer/i)) || {};

  // sections part
  const sectionsNodes = nodes.filter(filterByDirectoryName(/sections/i));

  // anchors for NavBar
  const anchors = sectionsNodes.map(path(["frontmatter", "anchor"])).filter(identity);

  return {
    topNode,
    navBarNode,
    footerNode,
    sectionsNodes,
    anchors,
  };
}
Example #4
Source File: fhir-references.js    From discovery-mobile-ui with MIT License 5 votes vote down vote up
encounters = {
  encounter: compose(
    (result) => (result ? [result] : []),
    path(['encounter']),
  ),
}