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

TypeScript through2.obj函数代码示例

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

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



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

示例1: createLayoutHtml

export function createLayoutHtml(
  pkg: PackageJson,
  fetcher: Fetcher = null,
  logger: Logger = gutil
) {
  const actualFetcher =
    fetcher ||
    new NodeFetcher(null, '/tmp/valotas.com.createLayoutHtml', logger);
  return through.obj(function(file: GulpFile, enc, callback) {
    if (file.meta) {
      renderLayout(file, actualFetcher, pkg).then(
        html => {
          file.html = html;
          callback(null, file);
        },
        er => {
          logger.log('Could not create html', file.path, er);
          callback(er);
        }
      );
    } else {
      callback(null, file);
    }
  });
}
开发者ID:valotas,项目名称:valotas.com,代码行数:25,代码来源:createLayoutHtml.ts


示例2: function

export default function(options?: AnalyzerOptions): Stream  {
  options = options || {};
  return through.obj(function(file:gutil.File, encoding: string, callback: (err?: Error, data?: gutil.File) => void) {

		if (file.isNull()) {
			callback(null, file);
			return;
		}

		if (file.isStream()) {
			callback(new gutil.PluginError('gulp-guidestyle', 'Streaming not supported'));
			return;
		}

    let analyzer = new Analyzer(options);
    new Analyzer(options).analyzeString(file.contents.toString(), path.extname(file.path).substring(1))
      .then(styleguide => {
        var basename = path.basename(file.path),
            stylename = basename.substr(0, basename.length-path.extname(basename).length);
        var styleFile = file.clone();
        styleFile.path = path.join(file.base, stylename+".json");
        styleFile.contents = Buffer.from(styleguide.stringify());
        callback(null, styleFile);
      })
      .catch(err => callback(new gutil.PluginError("gulp-guidestyle", err), null))
  });
};
开发者ID:kaa,项目名称:gulp-guidestyle,代码行数:27,代码来源:index.ts


示例3: logCompileStatus

	function logCompileStatus() {
		return through.obj(function(file, enc, cb) {
			grunt.verbose.or.writeln('Compiling "' + file.path + '"...');
			this.push(file);
			cb();
		});
	}
开发者ID:jedmao,项目名称:grunt-blink,代码行数:7,代码来源:blink.ts


示例4: deploy

export function deploy(base: string, mlClientOptions: ConnectionParams, mlAdminOptions: ConnectionParams, baseUri: string, schemaFile: NodeJS.ReadWriteStream, mlSpecsFile: NodeJS.ReadWriteStream) {
  let schemaPromise = new Promise(function(resolve) {
    schemaFile.pipe(through2.obj(function(chunk: File, enc: string, callback: () => {}) {
      resolve(JSON.parse(chunk.contents.toString()))
      callback()
    }))
  })
  let mlSpecsPromise = new Promise(function(resolve) {
    mlSpecsFile.pipe(through2.obj(function(chunk: File, enc: string, callback: () => {}) {
      resolve(JSON.parse(chunk.contents.toString()))
      callback()
    }))
  })
  let promise = Promise.all([schemaPromise, mlSpecsPromise])

  let client = mlAdmin.createAdminClient(mlClientOptions)
  let adminClient = mlAdmin.createAdminClient(mlAdminOptions)

  return through2.obj(function(chunk: File, enc: string, callback: (error, chunk?) => void) {
    let self = this
    promise.then(function(files: [s.Schema, MLSpecs]) {
      let [schema, mlSpecs] = files

      let moduleName = s.fileNameToModuleName(path.relative(base, chunk.path))
      let moduleSchema = schema[moduleName]

      return _deploy(client, adminClient, baseUri, moduleName, mlSpecs, moduleSchema, chunk.contents.toString())
    }).then(function(chunk) {
      callback(null, chunk)
    }).catch(function(error) {
      callback(error)
    })
  })
}
开发者ID:christyharagan,项目名称:gulp-ml-uservices,代码行数:34,代码来源:gulpDeploy.ts


示例5: createPlatformTests

  function createPlatformTests() {
    let platforms = [
      'android',
      'ios',
      'windows'
    ];

    let testTemplate = template(readFileSync(`${SCRIPTS_ROOT}/${E2E_NAME}/e2e.template.js`).toString());

    return obj(function (file, enc, next) {
      let self = this;

      let relativePath = dirname(file.path.replace(/^.*?src(\/|\\)components(\/|\\)/, ''));
      relativePath = relativePath.replace('/test/', '/');

      let contents = file.contents.toString();
      platforms.forEach(function (platform) {
        let platformContents = testTemplate({
          contents: contents,
          buildConfig: buildConfig,
          relativePath: relativePath,
          platform: platform
        });
        self.push(new VinylFile({
          base: file.base,
          contents: new Buffer(platformContents),
          path: file.path.replace(/e2e.js$/, platform + '.e2e.js')
        }));
      });
      next();
    });
  }
开发者ID:fsdn,项目名称:ionic,代码行数:32,代码来源:e2e.dev.ts


示例6: addSitemap

export function addSitemap() {
  const sitemap: string[] = [];
  let cwd;
  let enc;
  return through.obj(
    function(file, fileEnc, callback) {
      const meta = file.meta;
      if (meta) {
        cwd = file.cwd;
        enc = fileEnc;
        sitemap.push(createSitemapEntry(meta));
      }
      callback(null, file);
    },
    function(callback) {
      const file = new File({
        cwd: cwd,
        base: path.join(cwd, 'src'),
        path: path.join(cwd, 'src', 'sitemap.txt'),
        contents: new Buffer(sitemap.join('\n'), enc)
      }) as any;
      this.push(file);
      callback();
    }
  );
}
开发者ID:valotas,项目名称:valotas.com,代码行数:26,代码来源:addSitemap.ts


示例7: createStream

    /**
     * Creates a stream of package descriptors.
     *
     * @returns A stream that contains the 'package.json' files as they are received..
     */
    public createStream(): NodeJS.ReadWriteStream {
        return through.obj((file, encoding, callback) => {
            this.onHandleWorkspacePackage(file, JSON.parse(file.contents.toString()));

            callback(null, file);
        });
    }
开发者ID:i-e-b,项目名称:gulp-npmworkspace,代码行数:12,代码来源:StreamFactory.ts


示例8: prerender

export function prerender(options: GulpUniversalConfig | any) {
  function transform(file: any, enc: string, cb: Function) {

    if (file.isStream()) {
      return cb(new PluginError('angular2-gulp-prerender', 'Streaming is not supported'));
    }

    let template: string = file.contents.toString();

    // bootstrap and render component to string
    const _options = options;
    const _template = template;
    const _Bootloader = Bootloader;
    let bootloader = _options.bootloader;
    if (_options.bootloader) {
      bootloader = _Bootloader.create(_options.bootloader);
    } else {
      let doc = _Bootloader.parseDocument(_template);
      _options.document = doc;
      _options.template = _options.template || _template;
      bootloader = _Bootloader.create(_options);
    }

    return bootloader.serializeApplication()
      .then(html => {
        file.contents = new Buffer(html);
        cb(null, file);
      });
  }
  return through.obj(transform);
}
开发者ID:An0564,项目名称:universal,代码行数:31,代码来源:prerender.ts


示例9: run

function run(options?: IPluginOptions) {
  options = options || {};

  const importLister = new ImportLister(options);

  const instanceKey = crypto
    .createHash("md5")
    .update(__dirname + JSON.stringify(options))
    .digest("hex");
  const bufferKey = `${MODULE_NAME}-${instanceKey}`;
  const importBuffer = new ImportBuffer(
    importLister.listImports.bind(importLister),
    bufferKey,
  );

  const importChecker = new ImportChecker(options, importBuffer);

  return through.obj(function(
    file: File,
    enc: string,
    callback: (error: any, data: any) => any,
  ) {
    importChecker.checkFileForChanges(this, file, enc, callback);
  });
}
开发者ID:bingnz,项目名称:gulp-less-changed,代码行数:25,代码来源:main.ts


示例10: transform

export = () => {
  function transform(file: any, encode: string, callback: Function) {
    if (file.isNull()) {
      callback();
      return;
    }

    if (file.isStream()) {
      this.emit('error', new gutil.PluginError(PACKAGE_NAME, 'Streaming not supported'));
      callback();
      return;
    }

    const code = file.contents.toString(encode);
    const css = parse(code);
    const output = new (gutil.File as any)({
      cwd: file.cwd,
      base: file.base,
      path: file.path.replace(/\.js$/, '.css'),
    });
    output.contents = new Buffer(css);
    this.push(output);
    callback();
  }

  return through2.obj(transform);
};
开发者ID:mozisan,项目名称:menthe,代码行数:27,代码来源:gulp.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript subjquery.tQuery函数代码示例发布时间:2022-05-25
下一篇:
TypeScript through2.default函数代码示例发布时间: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