當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。