• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

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

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript event-stream.mapSync函数代码示例发布时间:2022-05-25
下一篇:
TypeScript event-stream.duplex函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap