当前位置: 首页>>代码示例>>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;未经允许,请勿转载。