當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript strip-bom.default函數代碼示例

本文整理匯總了TypeScript中strip-bom.default函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript default函數的具體用法?TypeScript default怎麽用?TypeScript default使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了default函數的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: function

 files: function () {
   if (this._files) { return this._files; }
   this.isDummy = this.options.dummy;
   let sitemapFile = path.join(this.options.metadataDir, "application", "sitemap.json");
   let sitemap: metadata.Sitemap = JSON.parse(stripBom(fs.readFileSync(sitemapFile, "utf8")));
   if (this.project.isEmberCLIAddon() && !this.options.dummy) {
     if (sitemap.mobile) {
       this._files = CommonUtils.getFilesForGeneration(this, function (v) { return v === "__root__/locales/en/translations.js" || v === "__root__/locales/ru/translations.js"; });
     } else {
       this._files = CommonUtils.getFilesForGeneration(this, function (v) { return v === "__root__/templates/mobile/application.hbs" || v === "__root__/locales/en/translations.js" || v === "__root__/locales/ru/translations.js"; });
     }
   } else {
     if (sitemap.mobile) {
         this._files = CommonUtils.getFilesForGeneration(this, function (v) { return v === "addon/locales/en/translations.js" || v === "addon/locales/ru/translations.js"; });
     } else {
         this._files = CommonUtils.getFilesForGeneration(this, function (v) { return v === "__root__/templates/mobile/application.hbs" || v === "addon/locales/en/translations.js" || v === "addon/locales/ru/translations.js"; });
     }
   }
   if (this.project.isEmberCLIAddon() || this.options.dummy) {
       lodash.remove(this._files, function (v) { return v === "public/assets/images/cat.gif" || v === "public/assets/images/favicon.ico" || v === "public/assets/images/flexberry-logo.png"; });
   } else {
       lodash.remove(this._files, function (v) { return v === "test/dummy/public/assets/images/cat.gif" || v === "test/dummy/public/assets/images/favicon.ico" || v === "test/dummy/public/assets/images/flexberry-logo.png"; });
   }
   this._excludeIfExists();
   return this._files;
 },
開發者ID:Flexberry,項目名稱:ember-flexberry,代碼行數:26,代碼來源:index.ts

示例2: _loadModule

  private _loadModule(
    localModule: InitialModule,
    from: Config.Path,
    moduleName: string | undefined,
    modulePath: Config.Path,
    options: InternalModuleOptions | undefined,
    moduleRegistry: ModuleRegistry,
  ) {
    if (path.extname(modulePath) === '.json') {
      const text = stripBOM(fs.readFileSync(modulePath, 'utf8'));

      const transformedFile = this._scriptTransformer.transformJson(
        modulePath,
        this._getFullTransformationOptions(options),
        text,
      );

      localModule.exports = this._environment.global.JSON.parse(
        transformedFile,
      );
    } else if (path.extname(modulePath) === '.node') {
      localModule.exports = require(modulePath);
    } else {
      // Only include the fromPath if a moduleName is given. Else treat as root.
      const fromPath = moduleName ? from : null;
      this._execModule(localModule, options, moduleRegistry, fromPath);
    }
    localModule.loaded = true;
  }
開發者ID:facebook,項目名稱:jest,代碼行數:29,代碼來源:index.ts

示例3: parseContent

export function parseContent(contents: string, filename: string): TSConfig {
    const data = stripComments(stripBom(contents));

    // A tsconfig.json file is permitted to be completely empty.
    if (/^\s*$/.test(data)) {
        return {};
    }

    return parseJson(data, null, filename);
}
開發者ID:DevinNorgarb,項目名稱:chat-app-electron,代碼行數:10,代碼來源:tsconfig-utils.ts

示例4: prepareData

export function prepareData(chunk: Buffer, runtime: ParseRuntime): string {
  const workChunk = concatLeftChunk(chunk, runtime);
  runtime.csvLineBuffer = undefined;
  const cleanCSVString = cleanUtf8Split(workChunk, runtime).toString("utf8");
  if (runtime.started === false) {
    return stripBom(cleanCSVString);
  } else {
    return cleanCSVString;
  }
}
開發者ID:Keyang,項目名稱:node-csvtojson,代碼行數:10,代碼來源:dataClean.ts

示例5: constructor

 constructor(blueprint, options) {
   let listFormsDir = path.join(options.metadataDir, "list-forms");
   if (!options.file) {
     options.file = options.entity.name + ".json";
   }
   let localePathTemplate: lodash.TemplateExecutor = this.getLocalePathTemplate(options, blueprint.isDummy, path.join("forms", options.entity.name + ".js"));
   this.locales = new Locales(options.entity.name, "ru", localePathTemplate);
   let listFormFile = path.join(listFormsDir, options.file);
   let content = stripBom(fs.readFileSync(listFormFile, "utf8"));
   this.listForm = JSON.parse(content);
   this.locales.setupForm(this.listForm);
 }
開發者ID:Flexberry,項目名稱:ember-flexberry,代碼行數:12,代碼來源:index.ts

示例6: stripBom

export async function ReadUri(uri: string): Promise<string> {
  try {
    const readable = await getUriAsync(uri);

    const readAll = new Promise<string>(function (resolve, reject) {
      let result = "";
      readable.on("data", data => result += data.toString());
      readable.on("end", () => resolve(result));
      readable.on("error", err => reject(err));
    });

    return stripBom(await readAll);
  } catch (e) {
    throw new Error(`Failed to load '${uri}' (${e})`);
  }
}
開發者ID:jianghaolu,項目名稱:AutoRest,代碼行數:16,代碼來源:uri.ts

示例7: callback

        fs.readFile(filename, encoding, function (err2, content) {
            if (err2) {
                return callback(err2);
            }

            content = stripBom(content);

            // \uFFFD is used to replace an incoming character
            // whose value is unknown or unrepresentable
            if (/\uFFFD/.test(content)) {
                const err3: NodeJS.ErrnoException = new Error("ECHARSET: unsupported encoding in file: " + filename);
                err3.code = "ECHARSET";
                return callback(err3);
            }

            callback(null, content);
        });
開發者ID:zaggino,項目名稱:brackets-electron,代碼行數:17,代碼來源:fs-additions.ts

示例8: stripBom

export async function ReadUri(uri: string, headers: { [key: string]: string } = {}): Promise<string> {
  try {
    const readable = await getUriAsync(uri, { headers: headers });

    const readAll = new Promise<string>(function (resolve, reject) {
      let result = "";
      readable.on("data", data => result += data.toString());
      readable.on("end", () => resolve(result));
      readable.on("error", err => reject(err));
    });

    let result = await readAll;
    // fix up UTF16le files
    if (result.charCodeAt(0) === 65533 && result.charCodeAt(1) === 65533) {
      result = Buffer.from(result.slice(2)).toString("utf16le");
    }
    return stripBom(result);
  } catch (e) {
    throw new Error(`Failed to load '${uri}' (${e})`);
  }
}
開發者ID:indrajithbandara,項目名稱:autorest,代碼行數:21,代碼來源:uri.ts


注:本文中的strip-bom.default函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。