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


TypeScript through2.obj函数代码示例

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