How to use the ramda.propOr function in ramda

To help you get started, we’ve selected a few ramda examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ajhyndman / fire-emblem-working-title / packages / fire-emblem-heroes-stats / build / scrape-images.js View on Github external
}).then(json => {
    forEach(
      compose(
        url => {
          if (url !== '') fetchImage(url);
        },
        tap(console.log.bind(console)),
        propOr('', 'thumburl'),
        head,
        propOr([], 'imageinfo'),
      ),
      values(json.query.pages),
    );

    // Recursively paginate through results until complete.
    if (json.continue != null && json.continue.gaicontinue != null) {
      scrapeImages(thumbnailSize, json.continue.gaicontinue);
    }
  });
}
github strvcom / dep-manager-web / src / api / schema / bida / modules / npm / index.ts View on Github external
id?: string
  name: string
  version: string
}

const NPMPackage = {
  id: ({ id, name }: INPMPackage): string => {
    if (!id && !name) {
      throw new Error('NPMPackage::id must resolve to a valid value.')
    }

    return id || name
  },

  dependencies: pipe(
    propOr({}, 'dependencies'),
    // @ts-ignore
    toPairs,
    map(zipObj(['name', 'version']))
  ),
}

const NPMDependency = {
  id: ({ name, version }: INPMPackage) => {
    if (!name) {
      throw new Error('NPMDependency::id must have a name available.')
    }

    if (!version) {
      throw new Error('NPMDependency::id must have a version available.')
    }
github diegomura / react-pdf / src / svg / inheritProps.js View on Github external
import * as R from 'ramda';

import { SVG_INHERITED_PROPS } from '../constants';

const getInheritProps = R.compose(
  R.pick(SVG_INHERITED_PROPS),
  R.propOr({}, 'props'),
);

const inheritProps = node => {
  const props = getInheritProps(node);

  return R.evolve({
    children: R.map(
      R.compose(
        inheritProps,
        R.evolve({
          props: R.merge(props),
        }),
      ),
    ),
  })(node);
};
github cablelabs / lpwanserver / ui / src / views / Networks / views / NetworkView.js View on Github external
export default function NetworkView(props) {

  const { network={}, networkProtocol, onToggleEnabled, onEdit } = props;
  const { id='no-id', name, securityData } = network;
  const authorizied = propOr(false, 'authorized', securityData);
  const message = propOr('', 'message', securityData);
  const enabled = propOr(false, 'enabled', securityData);
  const { networkProtocolName } = propOr('', 'name', networkProtocol);

  const ConnectedTooltip = authorizied ? IsConnectedTooltip : IsNotConnectedTooltip;
  const statusGlyph = authorizied ?
    'glyphicon-transfer text-success' : 'glyphicon-exclamation-sign text-danger';

  return (
    <div>
      <div>{name}</div>

      { !isEmpty(network) &amp;&amp;  }
      <div data-for="{`enabled-xbox-${id}`}" data-tip="">
        <input checked="{enabled}" type="checkbox">
        Enabled
      </div></div>
github OpenCTI-Platform / opencti / opencti-platform / opencti-front / src / private / components / entities / Regions.js View on Github external
constructor(props) {
    super(props);
    const params = buildViewParamsFromUrlAndStorage(
      props.history,
      props.location,
      'Regions-view',
    );
    this.state = {
      sortBy: propOr('name', 'sortBy', params),
      orderAsc: propOr(true, 'orderAsc', params),
      searchTerm: propOr('', 'searchTerm', params),
      view: propOr('lines', 'view', params),
    };
  }
github OpenCTI-Platform / opencti / opencti-platform / opencti-front / src / private / components / entities / Sectors.js View on Github external
constructor(props) {
    super(props);
    const params = buildViewParamsFromUrlAndStorage(
      props.history,
      props.location,
      'Sectors-view',
    );
    this.state = {
      searchTerm: propOr('', 'searchTerm', params),
    };
  }
github mitodl / micromasters / static / js / lib / grades.js View on Github external
getm("runs")
)

export const hasPassingExamGrade = R.compose(
  R.any(R.propEq("passed", true)),
  R.propOr([], "proctorate_exams_grades")
)

export const hasFailingExamGrade = R.compose(
  R.any(R.propEq("passed", false)),
  R.propOr([], "proctorate_exams_grades")
)

export const hasPassedCourseRun = R.compose(
  R.any(R.propEq("status", STATUS_PASSED)),
  R.propOr([], "runs")
)

export const passedCourse = (course: Course): boolean => {
  return course.has_exam
    ? hasPassedCourseRun(course) && hasPassingExamGrade(course)
    : hasPassedCourseRun(course)
}
github OpenCTI-Platform / opencti / opencti-platform / opencti-front / src / private / components / techniques / AttackPatterns.js View on Github external
constructor(props) {
    super(props);
    const params = buildViewParamsFromUrlAndStorage(
      props.history,
      props.location,
      'AttackPatterns-view',
    );
    this.state = {
      sortBy: propOr('name', 'sortBy', params),
      orderAsc: propOr(true, 'orderAsc', params),
      searchTerm: propOr('', 'searchTerm', params),
      view: propOr('lines', 'view', params),
      filters: {},
    };
  }
github OpenCTI-Platform / opencti / opencti-platform / opencti-front / src / private / components / settings / Tags.js View on Github external
constructor(props) {
    super(props);
    const params = buildViewParamsFromUrlAndStorage(
      props.history,
      props.location,
      'Tags-view',
    );
    this.state = {
      sortBy: propOr('value', 'sortBy', params),
      orderAsc: propOr(true, 'orderAsc', params),
      searchTerm: propOr('', 'searchTerm', params),
      view: propOr('lines', 'view', params),
    };
  }