How to use the insert function from ramda

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

2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
 * @param {*} elt The element to insert into the Array
 * @param {Array} list The list to insert into
 * @return {Array} A new Array with `elt` inserted at `index`.
 * @example
 *
 *      R.insert(2, 'x', [1,2,3,4]); //=> [1,2,'x',3,4]
 */
var insert = _curry3(function insert(idx, elt, list) {
    idx = idx < list.length && idx >= 0 ? idx : list.length;
    var result = _slice(list);
fork icon0
star icon0
watch icon0

+ 17 other calls in file

117
118
119
120
121
122
123
124
125
126
  R.addIndex (R.map) (R.pair),
  R.filter(pair => !Player.isDead(pair[0]) && pair[1] != game.whoseTurn),
  R.map(R.nth(1))
) (game),

pushDeck_s: role => liftDeck(State(deck => Pair(null, R.insert(0, role, deck)))),

popDeck_s: () => liftDeck(State(deck => Pair(deck[0], R.remove(0, 1, deck)))),

shuffleDeck_s: () => liftDeck(State.get()).chain(
fork icon0
star icon0
watch icon0

+ 6 other calls in file

783
784
785
786
787
788
789
790
791
792
793
function insertCOGSRecord(cogsList, cogsToInsert) {
    const idx = R.pipe(
        R.findIndex((cogs) => (cogs.date_from >= cogsToInsert.date_from)),
        negativeToValueCurried(cogsList.length)
    )(cogsList)
    const mergedList = R.insert(idx, cogsToInsert, cogsList)
    return R.mapAccumRight(setDateAsPrevious, -1, mergedList)[0]


}

fork icon0
star icon0
watch icon0

+ 2 other calls in file

128
129
130
131
132
133
134
135
136
137
// insertIntoArray :: RungSpec -> RungSpecArray -> RungSpecArray
// Returns shallow copy of rungSpecs with newRung inserted, keeping result sorted by dim in descending order
const insertIntoArray = R.curry(
  (newRung, rungSpecs) => R.pipe(
    R.splitWhen(r => r.dim < newRung.dim),
    R.insert(1, newRung),
    R.flatten
  )(rungSpecs)
)

fork icon0
star icon0
watch icon0

Other functions in ramda

Sorted by popularity

function icon

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