How to use the head function from ramda

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

152
153
154
155
156
157
158
159
160
161
    (d) => exists(d) && f.lastIndexOf(d) !== 0,
    (d) => d + '/' + f
  )
  .otherwise(f)

const fileName = `${process.cwd()}/${R.replace(__(messageDefinitionDir), outputDir, R.head(R.split('.', __(f))))}`
const p = fileName.lastIndexOf('/')
return [
  fileName.substring(0, p) +
    (path ? '/' + camelToSnakeCase(__(path)) : '') +
fork icon3
star icon44
watch icon6

+ 3 other calls in file

19
20
21
22
23
24
25
26
27
28
      LEFT JOIN [mtc_admin].sce
        ON sce.school_id = school.id
      WHERE school.id = @id
    `
  const rows = await sqlService.readonlyQuery(sql, [paramId], `schoolData.sqlFindOneById.${id}`)
  return R.head(rows)
},

/**
 * Find a School from the pin
fork icon14
star icon12
watch icon0

+ 4 other calls in file

60
61
62
63
64
65
66
67
68
69
70
71
                entity.name,
                changeDependency
            )();




            const parentEntity = R.head(data)[name];
            parentEntity[entity.name] = createdDependency[0][entity.name];
        }
    }
);
fork icon4
star icon0
watch icon0

+ 3 other calls in file

189
190
191
192
193
194
195
196
197
198
//

const initSelector = R.pipe(
  R.filter((c) => c.label === 'default' || c.label === 'new'),
  R.sortBy((c) => c.args.length),
  i => R.head(i),
  (i) => i ? i.selector : undefined,
)(contractFile.V3.spec.constructors)
if (!initSelector) {
  console.log('No default constructor found.')
fork icon1
star icon0
watch icon1

+ 339 other calls in file

35
36
37
38
39
40
41
42
43
44
if (lengthZero(remainingDirectories)) {

  return callback(folderName, fileFormat, directories);

} else {
  const dir = R.head(remainingDirectories);
  const outputDirectory = R.concat(dir, folderName);

  if (!R.contains(folderName, shell.ls(dir))) {
    shell.mkdir(outputDirectory);
fork icon1
star icon0
watch icon2

16
17
18
19
20
21
22
23
24
25
26
  R.toPairs
)(defaults)


const mergeString = R.unapply(R.compose(
  R.defaultTo(''),
  R.head(),
  R.reject(isUseless),
  R.reverse,
  R.drop(1)
))
fork icon0
star icon4
watch icon0

16
17
18
19
20
21
22
23
24
25
<div
  className="editableUneditableContainer"
  onClick={() => {
    const selected = Object.keys(props.selectedObject.objects).length;
    if (selected) {
      const firstKey = head(Object.keys(props.selectedObject.objects));
      let editable = !props.selectedObject.objects[firstKey].editable;
      if (
        typeof props.selectedObject.objects[firstKey].editable ===
        "undefined"
fork icon0
star icon0
watch icon4

+ 265 other calls in file

120
121
122
123
124
125
126
127
128
129
if (data.success) {
  let imageUrls = { ...state$.value.preview.imageUrls };
  let pageUrl = "";
  if (Array.isArray(data.data.image)) {
    imageUrls = data.data.image;
    pageUrl = head(data.data.image);
  } else {
    pageUrl = data.data.image;
    imageUrls[page - 1] = data.data.image;
  }
fork icon0
star icon0
watch icon4

+ 10 other calls in file

310
311
312
313
314
315
316
317
318
319
320
321
  )


// topRungSpec :: ParametricLadder -> RungSpec
// Returns top (first) RungSpec
// Note that rungSpecs must be in descending order by dim and bitrate
const topRungSpec = parametricLadder => R.head(R.view(RUNG_SPECS_LENS, parametricLadder))


// topRungSpecDim :: ParametricLadder -> Number
// Returns dimension of top RungSpec
const topRungSpecDim = parametricLadder => R.view(RS.DIM_LENS, topRungSpec(parametricLadder))
fork icon0
star icon0
watch icon0

+ 252 other calls in file

4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
* @return {*}
* @see R.tail, R.init, R.last
* @example
*
*      R.head(['fi', 'fo', 'fum']); //=> 'fi'
*      R.head([]); //=> undefined
*
*      R.head('abc'); //=> 'a'
*      R.head(''); //=> ''
*/
fork icon0
star icon0
watch icon2

+ 15 other calls in file

5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
* @param {Array|String} list
* @return {*}
* @see R.tail, R.init, R.last
* @example
*
*      R.head(['fi', 'fo', 'fum']); //=> 'fi'
*      R.head([]); //=> undefined
*
*      R.head('abc'); //=> 'a'
*      R.head(''); //=> ''
fork icon0
star icon0
watch icon0

+ 71 other calls in file

153
154
155
156
157
158
159
160
161
162
  return {
    formName: structure.form
  };
} else {
  const newPath = R.drop(1, path);
  const newTarget = R.head(newPath);
  const newStructure = R.find(
    R.propEq('moduleName', newTarget),
    structure.subfolders
  );
fork icon0
star icon0
watch icon0

48
49
50
51
52
53
54
55
56
57
  }
  else if (path.length === 1) {
      return structure
  } else {
      const newPath = R.drop(1, path)
      const newTarget = R.head(newPath)
      const newStructure = R.find(R.propEq('moduleName', newTarget), structure.subfolders)
      return getStructure(newPath, newStructure)
  }
}
fork icon0
star icon0
watch icon0

71
72
73
74
75
76
77
78
79
80
const indexedC = R.filter(R.compose(R.lt(startPoint[1]), R.head), R.zip(R.range(0, R.length(c)), c))
const blocked = R.find(R.compose(R.complement(R.equals('.')), R.last), indexedC)
if (!blocked) return -1


const r = row(cave, R.head(blocked))

const nextDropX = R.compose(
  R.head,
  R.reject(R.compose(isBlocked, R.last)),
fork icon0
star icon0
watch icon0

+ 2 other calls in file

16
17
18
19
20
21
22
23
24
25
// findTarget :: [Coin] -> Number -> [Coin] -> String -> Selection
const findTarget = (targets, feePerByte, coins, changeAddress) => {
  let target = foldCoins(targets).value;
  let _findTarget = seed => {
    let acc = seed[0];
    let newCoin = head(seed[2]);
    if (isNil(newCoin) || acc > target + seed[1]) { return false; }
    let partialFee = seed[1] + Coin.inputBytes(newCoin) * feePerByte;
    let restCoins = tail(seed[2]);
    let nextAcc = acc + newCoin.value;
fork icon0
star icon0
watch icon0

127
128
129
130
131
132
133
134
135
136
137
QUnit.test("무인수 함수로 합성", function () {
    // 주어진 데이터:
    let students = ['Rosser', 'Turing', 'Kleene', 'Church'];
    let grades = [80, 100, 90, 99];


    const first = R.head;
    const getName = R.pluck(0);
    const reverse = R.reverse;
    const sortByGrade = R.sortBy(R.prop(1));
    const combine = R.zip;
fork icon0
star icon0
watch icon1

128
129
130
131
132
133
134
135
136
137
138
  const [xs, ys] = R.splitWhen(
    ([_, cf]) => cf >= r,
    R.zip(population, cumulFitnesses)
  )
  const newPopulation = [...R.map(R.head, xs), ...R.map(R.head, R.tail(ys))]
  const chosen = R.head(R.head(ys))
  return [chosen, newPopulation]
}


// Float -> Chromosome -> Chromosome -> (Chromosome, Chromosome)
fork icon0
star icon0
watch icon0

+ 2 other calls in file

85
86
87
88
89
90
91
92
93
94
}

const promises = R.map(db.execute, entity.create(R.head(data)[name]));
const result = await Promise.all(promises);

lib.whenResult(createdEntity => R.head(data)[name].created_by_factory = true)(result[0]);
lib.whenResult(lib.doNothing, e => console.trace(entity.name, e))(result[0]);
lib.whenResult(lib.doNothing, (e) => {
    throw e;
})(result[0]);
fork icon0
star icon0
watch icon0

+ 19 other calls in file

85
86
87
88
89
90
91
92
93
94
    if (path.length === 0) {
        return structure.subfolders.map((sf) => sf.moduleName)
    }
    else {
        const newPath = R.drop(1, path)
        const newTarget = R.head(path)
        const newStructure = R.find(R.propEq('moduleName', newTarget), structure.subfolders)
        return getSubFolderNames(newPath, newStructure)
    }
}
fork icon0
star icon0
watch icon0

29
30
31
32
33
34
35
36
37
38

FAKE_TENANT_ACCESS_PERMISSION_DATA_WITH_KNOWN_TEST_TENANT_ACCESS_RESOURCE_ID = R.compose(
  R.mergeDeepRight(FAKE_TENANT_ACCESS_PERMISSION_DATA),
  R.objOf('tenantAccessResourceId'),
  R.prop('tenant_access_resource_id'),
  R.head
)(data);

mergeInsertId = R.mergeDeepRight(R.compose(R.objOf('id'), R.inc, R.length)(data));
done();
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)