How to use the takeWhile function from ramda

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

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


const content = fs.readFileSync('./changelog.md').toString();
let lines = content.split('\n');


let numTagsSeen = 0;
lines = R.takeWhile(
	(line) => {
		if (line.startsWith('## ')) {
			numTagsSeen += 1;
		}
fork icon1
star icon6
watch icon0

20
21
22
23
24
25
26
27
28
29
30
  return str;
});


const concatUntil = (fn, index) => R.pipe(
  R.drop(index),
  R.takeWhile(R.complement(fn)),
  R.map(R.prop('str')),
  R.join(' '),
);

fork icon0
star icon1
watch icon0

4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
 * @see R.dropWhile, R.transduce, R.addIndex
 * @example
 *
 *      var isNotFour = x => x !== 4;
 *
 *      R.takeWhile(isNotFour, [1, 2, 3, 4, 3, 2, 1]); //=> [1, 2, 3]
 */
var takeWhile = _curry2(_dispatchable('takeWhile', _xtakeWhile, function takeWhile(fn, list) {
    var idx = 0;
    var len = list.length;
fork icon0
star icon0
watch icon0

+ 17 other calls in file

49
50
51
52
53
54
55
56
57
58

const canSee = x => x < currentHeight

const visibleCount = [ left, right, above, below ]
  .map(list => {
    const canSeeList = R.takeWhile(canSee, list)

    // If we got to the edge of the map then the visible
    // list will have the same length as the input list and
    // that is the number of trees we can see; if a tree
fork icon0
star icon0
watch icon0

4
5
6
7
8
9
10
11
12
13
14
15
16
  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(
    reduce((m, [a, b]) => assoc(b, a, m), {}),
    map(split(')')),
fork icon0
star icon0
watch icon0

172
173
174
175
176
177
178
179
180
181
R.pipe(identifierToFilename,
       parse,
       R.prop('ast'),
       R.prop('body'),
       warnIgnoredTopLevel,
       R.takeWhile(R.both(R.propEq('type', 'VariableDeclaration'),
                          R.pipe(R.prop('declarations'),
                                 R.all(isRequireExpr)))),
  R.pluck('declarations'),
       R.map(R.head),
fork icon0
star icon0
watch icon0

17
18
19
20
21
22
23
24
25
26
27
28
)


const indexRange = R.range(0, sortedAdapters.length)


const branchesForIndex = (index) =>
  R.takeWhile(
    (nextIndex) => sortedAdapters[nextIndex] - sortedAdapters[index] <= 3,
    R.drop(index + 1, indexRange)
  )
const branchesMap = R.map(branchesForIndex, indexRange)
fork icon0
star icon0
watch icon0

13374
13375
13376
13377
13378
13379
13380
13381
13382
13383
13384
13385
 *
 *      const isNotFour = x => x !== 4;
 *
 *      R.takeWhile(isNotFour, [1, 2, 3, 4, 3, 2, 1]); //=> [1, 2, 3]
 *
 *      R.takeWhile(x => x !== 'd' , 'Ramda'); //=> 'Ram'
 */




var takeWhile =
fork icon0
star icon0
watch icon2

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