当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript ramda.append函数代码示例

本文整理汇总了TypeScript中ramda.append函数的典型用法代码示例。如果您正苦于以下问题:TypeScript append函数的具体用法?TypeScript append怎么用?TypeScript append使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了append函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: append

 indexedData.forEach((obj: IOMessage, index: number) => {
   const length = lengths[index]
   if (sumLength + length > MAX_QUERYSTRING_LENGTH) {
     batchedData = append(batch, batchedData)
     batch = [obj]
     sumLength = length
   } else {
     sumLength = sumLength + length
     batch = append(obj, batch)
   }
 })
开发者ID:vtex,项目名称:apps-client-node,代码行数:11,代码来源:messagesLoader.ts

示例2: append

export default <T extends { id: string | number }>(item: T, items: T[]) => {
  if (items.length === 0) {
    return [item];
  }

  const found = items.findIndex((i) => i.id === item.id);
  if (found < 0) {
    return append(item, items);
  };

  return update(found, item, items);
}
开发者ID:displague,项目名称:manager,代码行数:12,代码来源:updateOrAdd.ts

示例3: reduce

  return reduce((files: string[], file: string) => {
    const abspath = join(directory, file);

    if (isFile(abspath))
      return append(file, files);

    if (isDirectory(abspath))
      return concat(files,
        getAllInDirectory(abspath).map((f: string) => join(relative(directory, abspath), f)));

    return files;
  }, [], fs.readdirSync(directory));
开发者ID:TylorS,项目名称:ts-lib,代码行数:12,代码来源:fs.ts

示例4: require

const fs = require('fs');
const {join: pjoin} = require('path');
const request = require('request');
const Task = require('data.task');
const {map, toUpper, compose, prop, append, traverse} = require('ramda');

const filePath = (file:string):string => (pjoin(__dirname, '../', file));
const logErr = (err):void => console.log(`Error: ${err}`);
const logData = (data):void => console.log('Data', data);
const exists = (x):boolean => x != null;

const taskifyReadFile = (path:string) => {
  return new Task((reject, resolve) => {
    fs.readFile(path, 'utf8', (err, data) => exists(err) ? reject(err) : resolve(data));
  });
};

const taskifyReq = (url:string) => {
  return new Task((reject, resolve) => {
    request(url, (err, resp, body) => {
      exists(err) ? reject(err) : resolve(JSON.parse(body));
    });
  });
};

const getFilesAsTasks = compose(map(taskifyReadFile), map(filePath));
const files = getFilesAsTasks(['a.txt', 'b.txt', 'c.txt']);
const getSkywalker = map(prop('name'), taskifyReq('http://swapi.co/api/people/1'));
const done = traverse(Task.of, map(toUpper), append(getSkywalker, files));

done.fork(logErr, logData);
开发者ID:githop,项目名称:folktale-fun,代码行数:31,代码来源:index.ts


注:本文中的ramda.append函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。