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


TypeScript fs.read函數代碼示例

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


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

示例1: readConfigFile

 readConfigFile() {
   return fs.read(configFile).then((data: any) => {return JSON.parse(data); }, 
     (err: any) => {
       this.logger.log('Error on reading Config File!');
       this.logger.log(err);
     });
 }
開發者ID:DanielSchuech,項目名稱:webend,代碼行數:7,代碼來源:configuration.ts

示例2: printTailAndWatchFile

async function printTailAndWatchFile(file:any, tailSize:number) {
    if (await qfs.exists(file)) {
      const content = await qfs.read(file)
      const lines = content.split('\n')
      const from = Math.max(0, lines.length - tailSize)
      const lastLines = lines.slice(from).join('\n')
      console.log(lastLines)
    }
    watchFile(file)
}
開發者ID:duniter,項目名稱:duniter,代碼行數:10,代碼來源:daemon.ts

示例3:

					return Q.all(names.reduce((memo:any[], name:string) => {
						var pack = path.join(src, project, name);
						memo.push(Q.all([
							xm.file.readJSONPromise(path.join(pack, 'fields.json')),
							FS.read(path.join(pack, 'header.ts'))
						]).spread((fields, header) => {
							var data = new helper.HeaderAssert(project, name);
							data.fields = fields;
							data.header = header;
							res.push(data);
						}));
						return memo;
					}, []));
開發者ID:AbraaoAlves,項目名稱:tsd,代碼行數:13,代碼來源:HeaderHelper.ts

示例4: lsc

function lsc(inputLambdaScriptFile: string, outputJsFile: string) {
    return qFs.read(inputLambdaScriptFile).then(function(lambdaScriptCode: string) {
        const lscAst = getLscAst(lambdaScriptCode),
            jsAst = astToJsAst(lscAst);
        logger.debug({jsAst: jsAst}, 'Converted LambdaScript AST to JS AST');

        const js = escodegen.generate(jsAst);
        logger.debug({js: js}, 'Generated raw js');

        const jsWithPrelude = withPrelude(js);
        logger.debug({jsWithPrelude: jsWithPrelude}, 'Added prelude to raw js');

        return qFs.write(outputJsFile, jsWithPrelude);
    });
}
開發者ID:NickHeiner,項目名稱:lambdascript,代碼行數:15,代碼來源:index.ts

示例5:

var headers:QioHTTP.Headers;
var reader:Qio.Reader;
var writer:Qio.Writer;
var stream:Qio.Stream;

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

fs.open(path, options).then((x) => {
});
//fs.open(path, options):Q.Promise<Qio.Reader>;
//fs.open(path, options):Q.Promise<Qio.Writer>;
//fs.open(path, options):Q.Promise<NodeBuffer>;

//TODO how to define the multiple return types? use any for now?
anyQ = fs.read(path, options);
//strQ = fs.read(path, options);
//fs.read(path, options):Q.Promise<NodeBuffer>;

voidQ = fs.write(path, buffer, options);
voidQ = fs.write(path, str, options);

voidQ = fs.append(path, buffer, options);
voidQ = fs.append(path, str, options);

voidQ = fs.copy(source, target);
voidQ = fs.copyTree(source, target);

strArrQ = fs.list(path);
strArrQ = fs.listTree(path, (path, x) => {
    return true;
開發者ID:3x14159265,項目名稱:DefinitelyTyped,代碼行數:30,代碼來源:Q-io-tests.ts

示例6: lscHighlight

function lscHighlight(inputLambdaScriptFile: string): Q.IPromise<string> {
    return qFs.read(inputLambdaScriptFile).then(function(lambdaScriptCode: string) {
        const lscAst = getLscAst(lambdaScriptCode);
        return getHighlightedCode(lscAst, lambdaScriptCode);
    });
}
開發者ID:NickHeiner,項目名稱:lambdascript,代碼行數:6,代碼來源:index.ts

示例7:

					}).then(() => {
						return FS.read(path.join(gitTest.extraDir, 'tmp_test.bin'), {flags:'rb'});
					}, (err) => {
開發者ID:AbraaoAlves,項目名稱:tsd,代碼行數:3,代碼來源:Github.ts


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