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


TypeScript Q.denodeify函数代码示例

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


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

示例1: viewDynamic

export function viewDynamic(
    viewName: string,
    viewData: any,
    layoutName?: string ) : Q.Promise< relaxjs.Embodiment > {
  var log = _log.child( { func: 'internals.viewDynamic'} );
  var laterAct = Q.defer< relaxjs.Embodiment >();
  var readFile = Q.denodeify(fs.readFile);
  var templateFilename = './views/'+viewName+'._';
  if ( viewName === 'site') {
    templateFilename = `${__dirname}/../views/${viewName}._`;
  }
  if ( layoutName ) {
    var layoutFilename = './views/'+layoutName+'._';
    log.info('Reading template %s in layout %s',templateFilename, layoutFilename );
    Q.all( [ readFile( templateFilename,  { 'encoding':'utf8'} ),
             readFile( layoutFilename,    { 'encoding':'utf8'} ) ])
    .spread( (content: string, outerContent : string) => {
      try {
        log.info('Compile composite view %s in %s',templateFilename,layoutFilename);
        var innerContent = new Buffer( _.template(content)(viewData), 'utf-8' );
        var fullContent = new Buffer( _.template(outerContent)( { page: innerContent, name: viewData.Name, data: viewData.data }), 'utf-8');
        laterAct.resolve( new relaxjs.Embodiment( 'text/html', 200, fullContent ));
      }
      catch( err ) {
        log.error( err );
        laterAct.reject( emitCompileViewError(content,err, templateFilename +' in '+ layoutFilename) );
      }
    })
    .catch( (err : Error ) => {
      log.error( err );
      laterAct.reject( emitCompileViewError('N/A',err, templateFilename +' in '+ layoutFilename ) );
    });
  }
  else {
    log.info('Reading template %s',templateFilename);
    readFile( templateFilename,  { 'encoding':'utf8'} )
    .then( ( content:string ) => {
      try {
        log.info( 'Compiling view %s', templateFilename );
        var fullContent = new Buffer( _.template(content)(viewData) , 'utf-8') ;
        laterAct.resolve( new relaxjs.Embodiment( 'text/html', 200, fullContent ));
      }
      catch( err ) {
        log.error( err );
        laterAct.reject( emitCompileViewError(content,err, templateFilename ) );
      }
    })
    .catch( ( err : Error ) => {
      log.error( err );
      laterAct.reject( emitCompileViewError('N/A',err, templateFilename ) );
    });
  }
  return laterAct.promise;
}
开发者ID:micurs,项目名称:relaxjs,代码行数:54,代码来源:internals.ts

示例2: cleanup

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for details.

'use strict';

import * as child_process from 'child_process';
import * as fs from 'fs';
import * as net from 'net';
import * as path from 'path';
import * as pl from 'plist-with-patches';
import * as Q from 'q';

let promiseExec = Q.denodeify(child_process.exec);

export class CordovaIosDeviceLauncher {
    private static nativeDebuggerProxyInstance: child_process.ChildProcess;
    private static webDebuggerProxyInstance: child_process.ChildProcess;

    public static cleanup(): void {
        if (CordovaIosDeviceLauncher.nativeDebuggerProxyInstance) {
            CordovaIosDeviceLauncher.nativeDebuggerProxyInstance.kill('SIGHUP');
            CordovaIosDeviceLauncher.nativeDebuggerProxyInstance = null;
        }
        if (CordovaIosDeviceLauncher.webDebuggerProxyInstance) {
            CordovaIosDeviceLauncher.webDebuggerProxyInstance.kill();
            CordovaIosDeviceLauncher.webDebuggerProxyInstance = null;
        }
    }

    public static getBundleIdentifier(projectRoot: string): Q.Promise<string> {
        return Q.nfcall(fs.readdir, path.join(projectRoot, 'platforms', 'ios')).then((files: string[]) => {
开发者ID:Paradox-Cascade,项目名称:vscode-cordova,代码行数:31,代码来源:cordovaIosDeviceLauncher.ts

示例3: require

const _ = require('lodash')
const FS  = require('fs')
const Q  = require('q')
const glob = require('glob')
const sass = require('node-sass')

let globSearch = Q.denodeify(glob)
let sassRender = Q.nbind(sass.render, sass)
let writeFile = Q.denodeify(FS.writeFile)
let sassDefaults = {
  includePaths: [
  ],
  indentedSyntax: true
}

globSearch('src/**/*.scss')
  .then((files) => {
    var result = Q()
    files.forEach((srcFile) => {
      result = result
        .then(() => {
          let dstFile = srcFile.replace(/\.scss$/i, '.css')
          return buildSassFile(srcFile, dstFile)
        })
    })
    return result
  })
  .then(() => {
    console.log('Compiled CSS files.')
  })
  .catch((err) => {
开发者ID:ng-cookbook,项目名称:angular2-redux-complex-ui,代码行数:31,代码来源:build-css.ts

示例4:

import * as Q from 'q';
import * as _ from 'lodash';

// key generation parameters
const pbkdf2SaltLen = 64;
const pbkdf2Iterations = 6911;
const pbkdf2KeyLen = 192 / 8;
const pbkdf2Digest = 'sha256';

// see https://tools.ietf.org/html/rfc5084
// console.log((<any>crypto).getCiphers());
const cipherAlgorithm = 'aes-192-gcm';
const cipherIvLen = 12;

// promised variants
const randomBytes = Q.denodeify<Buffer>(crypto.randomBytes);
const pbkdf2 = Q.denodeify<Buffer>(crypto.pbkdf2);

/**
 * encrypted object data.
 *
 * @internal Not part of public API, exported for library use only.
 */
export interface EncryptedJson<T> {
  salt: string;
  iv: string;
  tag?: string;
  value: string;
}

/**
开发者ID:relution-io,项目名称:relution-sdk,代码行数:31,代码来源:cipher.ts


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