本文整理汇总了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;
},
示例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;
}
示例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);
}
示例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;
}
}
示例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);
}
示例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})`);
}
}
示例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);
});
示例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})`);
}
}