How to use the prepend function from ramda

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

49
50
51
52
53
54
55
56
57
});

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

44
45
46
47
48
49
50
51
52
53
    on: {click: [actions, Action.Insert()]}
  }, 'Add counter')

const view = R.curry((actions, model) => {
  const counters = R.map(viewCounter(actions), model.counters)
  return h('div', R.prepend(addBtn(actions), counters))
})


module.exports = {init, Action, update, view}
fork icon92
star icon0
watch icon72

18
19
20
21
22
23
24
25
26
27
28
// bug in 'stylelint-custom-processor-loader' configPath resolution
const isESLintLoader = both(prop('loader'), propSatisfies(includes('eslint-loader'), 'loader'))


const addStylelintCustomProcessorLoader = path => config =>
  edit(
    prepend({
      loader: require.resolve('stylelint-custom-processor-loader'),
      options: {
        configPath: path,
        emitWarning: true,
fork icon2
star icon5
watch icon0

1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
* @sig a -> [a] -> [a]
* @param {*} el The element to add to the end of the new list.
* @param {Array} list The list whose contents will be added to the beginning of the output
*        list.
* @return {Array} A new list containing the contents of the old list followed by `el`.
* @see R.prepend
* @example
*
*      R.append('tests', ['write', 'more']); //=> ['write', 'more', 'tests']
*      R.append('tests', []); //=> ['tests']
fork icon0
star icon0
watch icon0

+ 35 other calls in file

27
28
29
30
31
32
33
34
35
36
37
38
39


  random: (min, max) => State(seed => Pair(Rand._random(seed, min, max), Rand._nextSeed(seed))),


  shuffle: list => list.length <= 1 ? State.of(list) :
    Rand.random(0, list.length - 1).chain(i =>
      Rand.shuffle(R.remove(i, 1, list)).map(tail => R.prepend(list[i], tail)))
};


///// Player

fork icon0
star icon0
watch icon0

+ 6 other calls in file

56
57
58
59
60
61
62
63
64
65
66
67
const rollPairS = () => randomS(1, 6).chain(r1 =>
    randomS(1, 6).map(r2 => [r1, r2]));


// console.log(rollPairS().runWith(mkStdGen(3)));


// const push = a => State(s => Pair(null, R.prepend(a, s)));
// const pop = () => State(s => Pair(s[0], R.remove(0, 1, s)));
// const add = () => pop().chain(a => pop().map(b => a + b));
// const op = push(1).chain(() => push(2)).chain(() => add());
// console.log(op.runWith([]));
fork icon0
star icon0
watch icon0

+ 4 other calls in file

2
3
4
5
6
7
8
9
10
11
12
13
14
15


const countOrbits = curry((orbitMap, p) =>
  orbitMap[p] ? 1 + countOrbits(orbitMap, orbitMap[p]) : 0);


const orbitPath = curry((orbitMap, p) =>
  orbitMap[p] ? prepend(p, orbitPath(orbitMap, orbitMap[p])) : ['COM']);


const longestCommonPrefix = compose(map(head), takeWhile(apply(equals)), zip);


const orbitMap = compose(
fork icon0
star icon0
watch icon0

95
96
97
98
99
100
101
102
103
104
105
  R.filter(filterByWeather),
  R.map(calcScore),
  R.sortWith([R.descend(city => city.score)]),
  R.take(10),
  R.map(cityToArray),
  R.prepend(interestingProps),
  table,
)(cities);


console.log(topCities);
fork icon0
star icon0
watch icon0

+ 2 other calls in file

37
38
39
40
41
42
43
44
45
46
const create = (item) => {
  if (isValidData(item) && !findName(item.name, items)) {
    const id = getNextId(items);
    let newItem = {};
    items = R.compose(
      R.prepend(R.__, items),
      R.assoc('id', id),
      R.assoc('createdAt', new Date().toISOString()),
      R.assoc('updatedAt', new Date().toISOString())
    )(item);
fork icon0
star icon0
watch icon0

8
9
10
11
12
13
14
15
16
17
18
19
const matchingParens = {'(': ')', '[': ']', '{': '}', '<': '>'};
const isOpen = R.flip(R.includes)(R.keys(matchingParens));
const isMatchingClose = (l, r) => (matchingParens[l] === r);


const findLineMismatch = R.reduce((stack, p) => {
  if (isOpen(p)) return R.prepend(p, stack);


  [top, ...stack] = stack;
  if (!isMatchingClose(top, p)) return R.reduced(p);

fork icon0
star icon0
watch icon0

40
41
42
43
44
45
46
47
48
49
)(newSeries);

const mapIndexed = R.addIndex(R.map);
const fold = f => l => R.reduce(f, R.head(l), R.tail(l));
const others = limit => label => R.compose(
  R.prepend(label),
  fold(R.zipWith(R.add)),
  R.map(R.tail),
  R.drop(limit)
);
fork icon0
star icon0
watch icon1

+ 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)