OperationCode/front-end

View on GitHub
common/utils/prop-utils.js

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
// General utilities for dealing with component prop types
import pickBy from 'lodash/pickBy';

export function getPropertiesStartingWith(string, props) {
  return pickBy(props, (value, key) => key.startsWith(string));
}

export function getDataAttributes(props) {
  return getPropertiesStartingWith('data-', props);
}

export function getAriaAttributes(props) {
  return getPropertiesStartingWith('aria-', props);
}