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


TypeScript event-stream.map函数代码示例

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


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

示例1: createReadStream

    .pipe(map((file, callback) => {
      let variableLine, variableName, defaultValue, multiline;
      createReadStream(file.path, { flags: 'r'})
        .pipe(split())
        .pipe(map((line, callback) => {
          if (line.charAt(0) === '$') {
            variableLine = line.split(/:(.+)/);
              variableName = variableLine[0];
              defaultValue = variableLine[1];

              // If there is a semicolon then it isn't a multiline value
              multiline = line.indexOf(';') > -1 ? false : true;
              if (!multiline && line.indexOf('!default') > -1) {
                addVariable(variableName, defaultValue, file);
              }
          } else if (multiline === true) {
              defaultValue += '\n' + line;

              // If the line has a semicolon then we've found the end of the value
              if (line.indexOf(';') > -1 && line.indexOf('!default') > -1) {
                addVariable(variableName, defaultValue, file);
                multiline = false;
              }
            }
            callback();
        }));
        callback();
    }).on('end', () => {
开发者ID:ciekawy,项目名称:ionic,代码行数:28,代码来源:docs.ts

示例2: getBrowserCode

export function getBrowserCode(appName: string, opts?: PrebootOptions, done?: Function): any {
  let deferred = Q.defer();
  let clientCode = '';

  // check cache first (as long as it wasn't disabled)
  let cacheKey = JSON.stringify(opts);
  // opts can be undefined
  if (opts && !opts.disableCodeCache && browserCodeCache[cacheKey]) {
    return Q.when(browserCodeCache[cacheKey]);
  }

  // get the browser code
  getBrowserCodeStream(appName, opts)
    .pipe(eventStream.map(function(file, cb) {
      clientCode += file.contents;
      cb(null, file);
    }))
    .on('error', function(err) {
      if (done) {
        done(err);
      }

      deferred.reject(err);
    })
    .on('end', function() {
      if (done) {
        done(null, clientCode);
      }

      browserCodeCache[cacheKey] = clientCode;
      deferred.resolve(clientCode);
    });

  return deferred.promise;
}
开发者ID:StevenLudwig,项目名称:universal,代码行数:35,代码来源:browser_code_generator.ts

示例3: getBrowserCode

export function getBrowserCode(opts?: PrebootOptions, done?: Function): any {
  let deferred = Q.defer();
  let clientCode = '';

  // check cache first
  let cacheKey = JSON.stringify(opts);
  if (browserCodeCache[cacheKey]) {
    return Q.when(browserCodeCache[cacheKey]);
  }

  // get the browser code
  getBrowserCodeStream(opts)
    .pipe(eventStream.map(function(file, cb) {
      clientCode += file.contents;
      cb(null, file);
    }))
    .on('error', function(err) {
      if (done) {
        done(err);
      }

      deferred.reject(err);
    })
    .on('end', function() {
      if (done) {
        done(null, clientCode);
      }

      browserCodeCache[cacheKey] = clientCode;
      deferred.resolve(clientCode);
    });

  return deferred.promise;
}
开发者ID:Pishtiko,项目名称:universal,代码行数:34,代码来源:browser_code_generator.ts

示例4: templateCache

function templateCache(options: NgTemplatesOptions) {
    return es.map(function(file: any, callback: (err: any, htmlMinifierfile: any) => void) {
        var template = '$templateCache.put("<%= url %>","<%= contents %>");';
        var url;

        file.path = path.normalize(file.path);

        if(typeof options.path === 'function') {
            url = path.join(options.path(file.path, file.base));
        } else {
            url = path.join(file.path);
            url = url.replace(file.base, '');
        };

        if (process.platform === 'win32') {
            url = url.replace(/\\/g, '/');
        }

        let contents = file.contents.toString();

        if(options.htmlMinifier) {
            contents = minify(contents, options.htmlMinifier);
        }

        contents = require('js-string-escape')(contents);

        file.contents = Buffer.from(lodashTemplate(template)({
            url: url,
            contents: contents,
            file: file
        }), 'utf8');

        callback(null, file);
    });
}
开发者ID:VictorQueiroz,项目名称:gulp-ng-templates,代码行数:35,代码来源:index.ts

示例5: task

task('docs.sassVariables', () => {
  let variables = [];
  const outputFile = 'tmp/sass.json';

  function addVariable(variableName, defaultValue, file) {
    const entities = new AllHtmlEntities();
    defaultValue = entities.encode(defaultValue);
    defaultValue = defaultValue.replace('!default;', '');

    variables.push({
      name: variableName,
      defaultValue: defaultValue.trim(),
      file: relative('./', file.path)
    });
  }

  return src('./src/**/*.scss')
    .pipe(map((file, callback) => {
      let variableLine, variableName, defaultValue, multiline;
      createReadStream(file.path, { flags: 'r'})
        .pipe(split())
        .pipe(map((line, callback) => {
          if (line.charAt(0) === '$') {
            variableLine = line.split(/:(.+)/);
              variableName = variableLine[0];
              defaultValue = variableLine[1];

              // If there is a semicolon then it isn't a multiline value
              multiline = line.indexOf(';') > -1 ? false : true;
              if (!multiline && line.indexOf('!default') > -1) {
                addVariable(variableName, defaultValue, file);
              }
          } else if (multiline === true) {
              defaultValue += '\n' + line;

              // If the line has a semicolon then we've found the end of the value
              if (line.indexOf(';') > -1 && line.indexOf('!default') > -1) {
                addVariable(variableName, defaultValue, file);
                multiline = false;
              }
            }
            callback();
        }));
        callback();
    }).on('end', () => {
      const config = require('../../config.json');
      console.log(`Writing to file at /driftyco/ionic/${outputFile}`);
      console.log(`Place this file in /driftyco/ionic-site/${config.v2DocsDir}/theming/overriding-ionic-variables in order to update the docs`);
      mkdirp.sync('tmp');
      writeFileSync(outputFile, JSON.stringify(variables));
    }));
});
开发者ID:ciekawy,项目名称:ionic,代码行数:52,代码来源:docs.ts

示例6: pipelineFunction

export default function pipelineFunction(event?: gulp.WatchEvent) {

    const files: string[] = event !== undefined ? [event.path] : [
        root.application.scripts.typescripts().toString(),
        root.application.scripts.typings().Not(),
        //`${Folders.clientUnitTests}/**/*.ts`,
        //`!${Folders.clientUnitTests}/typings/**/*.ts`,
        //`${Folders.gulp}/**/*.ts`,
        //`!${Folders.gulp}/typings/**/*.ts`
    ];

    const reporter = es.map((file, cb) => {
        if (event !== undefined) {
            const failures = JSON.parse(file.tslint.output);
            if (failures.length === 0) {

                const prefix = `[${gutil.colors.cyan('gulp-tslint')}]`;
                const fileName = path.basename(event.path);
                gutil.log(prefix, gutil.colors.green(`${fileName} doesn't have errors`));
            }
        }
    });

    const getConfiguration = () => {
        return JSON.parse(fs.readFileSync('tslint.json'));
    };

    const config = {
        configuration: getConfiguration()
    };

    return gulp.src(files)
        .pipe(tslint(config))
        .pipe(tslint.report('verbose', {
            emitError: false,
            summarizeFailureOutput: true
        }))
        .pipe(reporter);
};
开发者ID:ibzakharov,项目名称:angular_project_template,代码行数:39,代码来源:ts-lint.ts


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