How to use the curry function from ramda

Find comprehensive JavaScript ramda.curry code examples handpicked from public code repositorys.

27
28
29
30
31
32
33
34
35
36
    items: R.adjust(Component.update(counterAction), idx)
  }, model)
})

// View
const view = R.curry((action$, model) =>
  h('div.list', [
    h('button', {on: {click: [action$, Action.Reverse()]}}, 'Reverse'),
    h('button', {on: {click: [action$, Action.Add()]}}, 'Add'),
    h('ul', R.mapIndexed((item, idx) =>
fork icon92
star icon0
watch icon0

37
38
39
40
41
42
43
44
45
46
               })}, model)
  });

// View

const viewCounter = R.curry((actions, c) => {
  const [id, model] = c;
  console.log('viewCounter', id, model);
  return counter.viewWithRemoveButton({
    actions: R.compose(actions, Action.Modify(id)),
fork icon92
star icon0
watch icon72

+ 3 other calls in file

65
66
67
68
69
70
71
72
73
74
  })
})

// View

const viewTodo = R.curry((action$, todo) => {
  return Todo.view({
    action$: forwardTo(action$, Action.Modify(todo)),
    remove$: forwardTo(action$, R.always(Action.Remove(todo))),
  }, todo)
fork icon92
star icon0
watch icon2

+ 3 other calls in file

43
44
45
46
47
48
49
50
51
52
const viewCounter = R.curry((actions, c) => {
  const [id, model] = c;
  return counter.view(R.compose(actions, Action.Modify(id)), model);
});

const view = R.curry(function (actions, model) {
  const counters = R.map(viewCounter(actions), model.counters);
  return h('div',
    R.concat([h('button.rm', {on: {click: [actions, Action.Remove()]}}, 'Remove'),
              h('button.add', {on: {click: [actions, Action.Insert()]}}, 'Add')], counters)
fork icon92
star icon0
watch icon72

+ 3 other calls in file

31
32
33
34
35
36
37
38
39
40
               })}, model)
  })

// View

const viewCounter = R.curry((actions, [id, model]) =>
  counter.view({
    actions: R.compose(actions, Action.Modify(id)),
    remove: R.compose(actions, R.always(Action.Remove(id))),
  }, model))
fork icon92
star icon0
watch icon72

+ 3 other calls in file

78
79
80
81
82
83
84
85
86
87
 * Prefix a string with '@' and its index
 * @param {number} idx
 * @param {string} s
 * @return {function(): string}
 */
const paramNameWithIdx = R.curry((idx, s) => '@' + s + idx)

/**
 * Return a function that takes the keys from an object joins them together into a list
 * of sql parameter identifiers.
fork icon14
star icon12
watch icon11

39
40
41
42
43
44
45
46
47
48
               })}, model)
  });

// View

const viewCounter = R.curry((actions$, c) => {
  const [id, model] = c;
  console.log('viewCounter', id, model);
  return counter.viewWithRemoveButton({
    actions$: forwardTo(actions$, Action.Modify(id)),
fork icon91
star icon0
watch icon2

+ 19 other calls in file

2
3
4
5
6
7
8
9
10
11
12
const {curry, isNil, pathSatisfies, test} = require('ramda');
const rp = require('request-promise');
const authHeader = require('./authHeader');
const baseUrl = require('./baseUrl');


module.exports = curry(async (path,qs) => {
  let options = {
    json: true,
    headers: {
      Authorization: authHeader(),
fork icon15
star icon10
watch icon0

7
8
9
10
11
12
13
14
15
16
17
18
      isStringOfLengthAtLeast = __.ofLength(String, 'gte'),
      isStringOfLengthAtMost  = __.ofLength(String, 'lte'),
      isStringLongerThan      = __.ofLength(String, 'gt'),
      isStringShorterThan     = __.ofLength(String, 'lt');


const isStringContaining = R.curry((subStr, str) => {
  return R.compose(R.not, R.equals(-1), R.indexOf(subStr))(str);
});


const isStringMatching = R.curry((pattern, str) => {
fork icon2
star icon11
watch icon0

+ 4 other calls in file

7
8
9
10
11
12
13
14
15
16
17
18
19
  const isMatch = ({ constructor: { name } }) => name === constructorName


  return findIndex(isMatch, plugins)
})


const injectPluginIndex = curry((constructorName, fn, config) => {
  const i = getPluginIndex(constructorName, config)
  i === -1 && error(`No plugin with constructor name ${constructorName} was found`)


  return fn(i)
fork icon2
star icon5
watch icon0

+ 31 other calls in file

-1
fork icon2
star icon5
watch icon0

+ 5 other calls in file

16
17
18
19
20
21
22
23
24
25
}
activate() {
  this.ep.loadProperties();
  this.disposables = new _eventKit.CompositeDisposable(); //console.log("activate")

  const editoHandler = R.curry(this.handleEditorDidLoad)(this.ep);
  global.inkdrop.onEditorLoad(editoHandler.bind(this));
}
deactivate() {
  if (this.disposables) {
fork icon0
star icon10
watch icon0

307
308
309
310
311
312
313
314
315
316
317
 */


/**
 * @type {RenderFn}
 */
const render = R.curry((options, column, block) => {
  const prefix = `${' '.repeat(column)} * `;
  const usePrintWidth = options.jsdocPrintWidth || options.printWidth;
  const width = usePrintWidth - prefix.length;
  const lines = [];
fork icon1
star icon9
watch icon0

2
3
4
5
6
7
8
9
10
11
12
13
const ApiError = require('../utilities/api-error');
const HTTP_CONSTANT = require('../utilities/http-constant');


const notNil = R.compose(R.not, R.isNil);


const mapValueAndRules = R.curry((data, allRules) => {
	const keys = R.keys(allRules);
	return R.map((key) => {
		const value = data ? data[key] : undefined;
		const rules = allRules[key];
fork icon4
star icon2
watch icon2

+ 413 other calls in file

0
1
2
3
4
5
6
7
8
9
10
const R = require('ramda');
const Result = require('folktale/result');
const whenResult = require('./whenResult');
const { ifElse } = require('./ifElse');


const executeIfResultIsSuccessful = R.curry(async (fn, result) => {
	if (Result.hasInstance(result)) {
		return whenResult((value) => fn(value))(result);
	}
	return Result.Error('Return type of execution was not type of folktale/result.');
fork icon4
star icon2
watch icon0

7
8
9
10
11
12
13
14
15
16
// lensStringPath :: String -> Object
const lensStringPath = R.pipe(splitPath, R.lensPath);
// getByStringPath :: String -> Object
const getByStringPath = R.pipe(splitPath, R.path);
// doArrayByPath :: Function -> String -> Object -> Object -> Object
const doArrayByPath = arrayFn => R.curry((objPath, data, object) =>
  R.pipe(
    getByStringPath(objPath),
    arrayFn(data),
    R.set(lensStringPath(objPath), R.__, object)
fork icon0
star icon2
watch icon0

+ 2 other calls in file

339
340
341
342
343
344
345
346
347
348
349
350
    return listTail(lst);
  }
  return nil;
}


member = R.curry(member);


function find(pred, list) {
  if (isNull(lst)) {
    return lst;
fork icon1
star icon1
watch icon0

+ 15 other calls in file

2
3
4
5
6
7
8
9
10
11
12
 * Author: Luis Atencio
 */
const R = require('ramda');


// checkType :: Type -> Type -> Type | TypeError
const checkType = R.curry(function(typeDef, obj) {
	if(!R.is(typeDef, obj)) {
		let type = typeof obj;
		throw new TypeError(`Type mismatch. Expected [${typeDef}] but found [${type}]`);
	}
fork icon0
star icon1
watch icon1

47
48
49
50
51
52
53
54
55
56
57
58
  ),
  R.indexBy(R.prop('id')),
  R.map(R.omit(['id'])),
)


const monkeyRoundMut = R.curry((commonMultiple, lowWorry, monkeys) => {
  for (const id of Object.keys(monkeys)) {
    const monkey = monkeys[id]


    const items = monkey.items
fork icon0
star icon1
watch icon0

18
19
20
21
22
23
24
25
26
27
28
      return Failure([errMessage]);
    }
  }
);


const HVXor = Type((success, failure) => curry((firstType, secondType, value) =>
  Just(xorValidation)
    .ap(Maybe.fromNullable(firstType))
    .ap(Maybe.fromNullable(secondType))
    .ap(Maybe.fromNullable(value))
fork icon0
star icon1
watch icon0

+ 7 other calls in file

Other functions in ramda

Sorted by popularity

function icon

ramda.clone is the most popular function in ramda (30311 examples)