How to use the ramda.compose 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 chris-l / mock-couch / lib / all_docs.js View on Github external
return function (req, res, next) {
    var original, offset, rows, db;

    original = self.databases[req.params.db];
    db = R.cloneDeep(original);
    offset = 0;

    // It creates and format the rows
    rows = R.compose(
      R.map(function (data) {
        var id, output, doc;

        id = data[0];
        doc = R.cloneDeep(data[1]);
        doc._id = id;

        // Prepare output
        output = {
          id    : id,
          key   : id,
          value : { rev : doc._rev }
        };

        // Show the document's content if include_docs=true
        if (req.query.include_docs === 'true') {
github coderplanets / coderplanets_web / containers / Doraemon / logic / advisor.js View on Github external
getSuggestionPath = p => {
    if (R.isEmpty(p)) {
      return R.path(p, this.curSuggestions)
    }
    const cmdChain = insertBetweenPath(p)
    this.store.markState({ cmdChain })
    return R.path(cmdChain, this.curSuggestions) || {}
  }

  suggestionPathInit = R.compose(
    this.getSuggestionPath,
    cmdInit
  )

  suggestionPath = R.compose(
    this.getSuggestionPath,
    cmdFull
  )

  suggestionPathThenStartsWith = val => {
    const init = this.suggestionPathInit(val)
    return R.pickBy((_, k) => R.startsWith(cmdLast(val), k), init)
  }

  walkSuggestion = R.ifElse(
    R.endsWith('/'),
    this.suggestionPath,
    this.suggestionPathThenStartsWith
  )

  suggestionBreif = R.compose(
github Undistraction / cssapi / src / utils / predicate.js View on Github external
export const tokenMatches = names => value => {
  const possibleNames = compose(joinWithPipe, ensureArray)(names)
  const regExp = new RegExp(`^(${possibleNames}):(.*)$`)
  return test(regExp, value)
}
github coderplanets / coderplanets_web / containers / Doraemon / logic / advisor.js View on Github external
import { ICON_CMD } from '@config'
import { notEmpty } from '@utils'

const cmdSplit = R.compose(
  R.split('/'),
  R.slice(1, Infinity)
)
const cmdFull = R.compose(
  R.filter(notEmpty),
  cmdSplit
)
const cmdHead = R.compose(
  R.head,
  cmdSplit
)
const cmdLast = R.compose(
  R.last,
  cmdFull
)
const cmdInit = R.compose(
  R.init,
  cmdFull
)

export const startWithSlash = R.startsWith('/')

export const searchablePrefix = R.compose(
  R.not,
  R.anyPass([
    R.startsWith('/'),
    R.startsWith('?'),
    R.startsWith('#'),
github podlove / podlove-ui / packages / player / state / transcripts / selectors.js View on Github external
import { compose, prop } from 'ramda'

export const timeline = prop('timeline')
export const active = prop('active')
export const follow = prop('follow')
export const hasTranscripts = prop('hasTranscripts')
export const search = prop('search')
export const searchQuery = compose(
  prop('query'),
  search
)
export const searchSelected = compose(
  prop('selected'),
  search
)
export const searchResults = compose(
  prop('results'),
  search
)
export const searching = compose(
  prop('searching'),
  search
)
github RossMcMillan92 / djent / src / generic / scripts / app / containers / SaveController.js View on Github external
const launchSaveModal = (audioPlaylist, enableModal, disableModal) => {
    const saveMIDI = () => {
        Tracking.sendSaveEvent('midi')
        buildAndSaveMidi(audioPlaylist)
    }
    const saveWAV = () => {
        Tracking.sendSaveEvent('wav')
        saveAudioPlaylistAsWav(audioPlaylist)
    }
    const content = (
        
    )
    enableModal({ className: 'modal--small', content, isCloseable: true, title: 'Save' })
}
github benji6 / andromeda / client / components / pages / ScaleAndPitchSelector.js View on Github external
export default connect(identity)(({arpeggiator: {arpeggiatorIsOn, patterns, selectedPattern},
                                   dispatch,
                                   rootNote, scale: {scaleName, scales}}) =>
  
      
      
      
    
  } onClose={() => render(
      
        
      
    )} />
  );
github OpenCTI-Platform / opencti / opencti-front / src / private / components / malware / MalwareKnowledgeBar.js View on Github external
/>
          
        
      
    );
  }
}

MalwareKnowledgeBar.propTypes = {
  malwareId: PropTypes.string,
  classes: PropTypes.object,
  location: PropTypes.object,
  t: PropTypes.func,
};

export default compose(
  inject18n,
  withRouter,
  withStyles(styles),
)(MalwareKnowledgeBar);
github goodjoblife / GoodJobShare / src / components / ShareExperience / InterviewStepsForm / formCheck.js View on Github external
]);

export const interviewSensitiveQuestions = R.anyPass([
  R.all(
    R.compose(
      R.allPass([lteLength(20), gtLength(0)]),
      R.defaultTo(''),
    ),
  ),
  n => n === [],
]);

const ifFalseLog = ifThenLog(n => n === false);

export const interviewFormCheck = R.allPass([
  R.compose(
    ifFalseLog('companyQuery not pass'),
    companyQuery,
    R.prop('companyQuery'),
  ),
  R.compose(
    ifFalseLog('region not pass'),
    region,
    R.prop('region'),
  ),
  R.compose(
    ifFalseLog('jobTitle not pass'),
    jobTitle,
    R.prop('jobTitle'),
  ),
  R.compose(
    ifFalseLog('experienceInYear not pass'),
github goodjoblife / GoodJobShare / src / components / TimeAndSalary / SearchBar.js View on Github external
import React, { useState, useCallback } from 'react';
import PropTypes from 'prop-types';
import cn from 'classnames';
import R from 'ramda';
import ReactPixel from 'react-facebook-pixel';
import { withRouter } from 'react-router-dom';

import AutoCompleteSearchTextInput from 'common/form/AutoCompleteTextInput_new/AutoCompleteSearchTextInput';
import Magnifiner from 'common/icons/Magnifiner';

import styles from './SearchBar.module.css';
import { searchKeywordSelector } from './common/selectors';

import PIXEL_CONTENT_CATEGORY from '../../constants/pixelConstants';

const getInitialSearchTextFromLocation = R.compose(
  R.defaultTo(''),
  searchKeywordSelector,
);

const SearchBar = ({ history, location }) => {
  const [searchText, setSearchText] = useState(
    getInitialSearchTextFromLocation({ location }),
  );

  const gotoSearchResult = useCallback(
    searchText => {
      history.push(`/search?q=${encodeURIComponent(searchText)}`);
      ReactPixel.track('Search', {
        search_string: searchText,
        content_category: PIXEL_CONTENT_CATEGORY.SEARCH_TIME_AND_SALARY,
      });