當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript fs.readFileAsync函數代碼示例

本文整理匯總了TypeScript中fs.readFileAsync函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript readFileAsync函數的具體用法?TypeScript readFileAsync怎麽用?TypeScript readFileAsync使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了readFileAsync函數的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: readDownSQL

export function readDownSQL(migration: Migration): Promise<string> {
  if (migration.split) {
    return fs.readFileAsync(migration.downPath, {encoding: 'utf8'})
      .then(R.trim);
  }
  return fs.readFileAsync(migration.path, {encoding: 'utf8'})
    .then(R.split(MIGRATION_SQL_SPLIT_REGEXP))
    .tap(R.partial(assertSQLSections, migration))
    .then(R.nth(1))
    .then(R.trim);
}
開發者ID:programble,項目名稱:careen,代碼行數:11,代碼來源:files.ts

示例2: uploadStockTransactionsCSV

 uploadStockTransactionsCSV(path: string): Promise<any>{
   return fs.readFileAsync(path, "utf8").bind(this).then(function(content){
     if(!this.fileHandler.IsValid(content)){
       return Promise.reject(new Error("Invalid Stock CSV format."))
     }
     else{
       var trades = this.fileHandler.extractData(content);
       return Promise.resolve({filePath: path, transactionsCount: trades.length});
     }
   });
 }
開發者ID:kongbb,項目名稱:MyFinance,代碼行數:11,代碼來源:stock.controller.ts

示例3: importStockTransactions

 importStockTransactions(path: string): Promise<any>{
   return fs.readFileAsync(path, "utf8").bind(this).then(function(content){
     if(!this.fileHandler.IsValid(content)){
       return Promise.reject(new Error("Invalid Stock CSV format."))
     }
     else{
       var trades = this.fileHandler.extractData(content);
       return this.repository.importStockTrades(trades);
     }
   });
 }
開發者ID:kongbb,項目名稱:MyFinance,代碼行數:11,代碼來源:stock.controller.ts

示例4: create

export default function create(config: Config) {
  let directory = config.files.directory;
  let command = config.commands.create;

  let id = command.generateID();

  let ensureDirectory = files.ensureDirectory(directory);
  let createMigration: Promise<files.Migration>;

  if (command.split) {
    let readUpTemplate = fs.readFileAsync(
      command.templatePaths.up,
      {encoding: 'utf8'}
    );
    let readDownTemplate = fs.readFileAsync(
      command.templatePaths.down,
      {encoding: 'utf8'}
    );

    createMigration = Promise.join(
      readUpTemplate,
      readDownTemplate,
      ensureDirectory,
      (up, down) => files.createSplit(up, down, directory, id, command.name)
    );
  } else {
    let readTemplate = fs.readFileAsync(
      command.templatePaths.combined,
      {encoding: 'utf8'}
    );
    createMigration = Promise.join(
      readTemplate,
      ensureDirectory,
      template => files.create(template, directory, id, command.name)
    );
  }

  return createMigration.then(formatMigrationLong);
}
開發者ID:programble,項目名稱:careen,代碼行數:39,代碼來源:create.ts

示例5: require

import path = require("path");

const fs = require("fs");

let file = path.join(__dirname, "environment.json");
let env = {};

if (fs.existsSync(file)) {
    env = fs.readFileAsync(file, "utf-8");
    env = JSON.parse("");
    Object.keys(env).forEach(key => process.env[key] = env[key]);
}

const db = "mongodb://192.168.99.100:27017/dockerDb";

const facebook = {
    clientId: process.env.FACEBOOK_CLIENTID,
    clientSecret: process.env.FACEBOOK_SECRET,
    callbackUrl: "http://localhost:8080/auth/facebook/callback"
};

const github = {
    clientId: process.env.GITHUB_CLIENTID,
    clientSecret: process.env.GITHUB_SECRET,
    callbackUrl: "http://localhost:8080/auth/github/callback"
};

const google = {
    clientId: process.env.GOOGLE_CLIENTID,
    clientSecret: process.env.GOOGLE_SECRET,
    callbackUrl: "http://localhost:8080/auth/google/callback"
開發者ID:gvanderberg,項目名稱:docker-node-sample,代碼行數:31,代碼來源:development.ts

示例6: it

 it('writes down template to file', () =>
   fs.readFileAsync(migration.downPath, {encoding: 'utf8'})
     .tap(sql => assert.equal(sql, '-- down\n'))
開發者ID:programble,項目名稱:careen,代碼行數:3,代碼來源:files.ts


注:本文中的fs.readFileAsync函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。