drop unneeded toString conversion

This commit is contained in:
Denis Pushkarev
2026-04-25 18:10:01 +07:00
parent 49eb91ecd8
commit 2e54cf995e
3 changed files with 6 additions and 11 deletions
+1 -1
View File
@@ -29,7 +29,7 @@ const internalModules = await jsModulesFrom('packages/core-js/internals');
const allModules = await glob('packages/core-js?(-pure)/**/*.js');
await Promise.all(allModules.map(async path => {
for (const dependency of konan(String(await fs.readFile(path, 'utf8'))).strings) {
for (const dependency of konan(await fs.readFile(path, 'utf8')).strings) {
internalModules.delete(dependency.match(/\/internals\/(?<module>[^/]+)$/)?.groups.module);
}
}));
+1 -1
View File
@@ -143,7 +143,7 @@ subset('core-js/stage/4', /^(?:es\.string\.at|esnext\.)/);
async function unexpectedInnerNamespace(namespace, unexpected) {
const paths = await glob(`packages/core-js/${ namespace }/**/*.js`);
await Promise.all(paths.map(async path => {
for (const dependency of konan(String(await fs.readFile(path, 'utf8'))).strings) {
for (const dependency of konan(await fs.readFile(path, 'utf8')).strings) {
if (unexpected.test(dependency)) {
echo(chalk.red(`${ chalk.cyan(path) }: found unexpected dependency: ${ chalk.cyan(dependency) }`));
fail = true;
+4 -9
View File
@@ -176,7 +176,7 @@ async function buildBlogMenu() {
let menu = '<ul>';
for (const mdPath of mdFiles) {
if (mdPath.endsWith('index.md')) continue;
const content = await readFileContent(mdPath);
const content = await readFile(mdPath, 'utf8');
const tokens = marked.lexer(content);
const firstH1 = tokens.find(token => token.type === 'heading' && token.depth === 1);
@@ -212,11 +212,6 @@ async function getVersionFromMdFile(mdPath) {
return match?.groups?.version ?? DEFAULT_VERSION;
}
async function readFileContent(filePath) {
const content = await readFile(filePath, 'utf8');
return content.toString();
}
async function buildPlaygrounds(template, versions) {
for (const version of versions) {
await buildPlayground(template, version, versions);
@@ -228,7 +223,7 @@ async function buildPlayground(template, version, versions) {
const bundleScript = `<script nomodule src="${ bundlesPath }/${ config.bundleName }"></script>`;
const bundleESModulesScript = `<script type="module" src="${ bundlesPath }/${ config.bundleNameESModules }"></script>`;
const babelScript = '<script src="./babel.min.js"></script>';
const playgroundContent = await readFileContent(`${ config.srcDir }playground.html`);
const playgroundContent = await readFile(`${ config.srcDir }playground.html`, 'utf8');
const versionsMenu = await buildVersionsMenu(versions, version.label, 'playground');
let playground = template.replace('{content}', playgroundContent);
playground = playground.replace('{base}', BASE);
@@ -290,7 +285,7 @@ function getTitle(content) {
}
async function build() {
const template = await readFileContent(config.templatePath);
const template = await readFile(config.templatePath, 'utf8');
await buildBlogMenu();
const mdFiles = await getAllMdFiles(config.docsDir);
const versions = await getVersions();
@@ -304,7 +299,7 @@ async function build() {
let isChangelog;
for (let i = 0; i < mdFiles.length; i++) {
const mdPath = mdFiles[i];
const content = await readFileContent(mdPath);
const content = await readFile(mdPath, 'utf8');
isDocs = mdPath.includes('/docs');
isChangelog = mdPath.includes('/changelog');
isBlog = mdPath.includes('/blog');