<commit_before>const fs = require('fs');
const path = require('path');
const crypto = require('crypto');
const pack = require('../package.json');
const rootDir = path.dirname(__dirname);
const readmeDraft = fs.readFileSync(path.join(rootDir, 'tools', 'README.draft.md'), 'utf8');

const hash = crypto.createHash('sha384');
hash.update(fs.readFileSync(path.join(rootDir, 'dist', 'browser-id3-writer.min.js'), 'utf8'));
const digest = hash.digest('base64');

const readme = readmeDraft
    .replace('###version###', pack.version)
    .replace('###hash###', `sha384-${digest}`);

fs.writeFileSync(path.join(rootDir, 'README.md'), readme);

console.log(`README.md is updated, version: ${pack.version}, hash: ${digest}`);
<commit_msg>update prepare_readme.js<commit_after>const fs = require('fs');
const path = require('path');
const crypto = require('crypto');
const pack = require('../package.json');

const rootDir = path.dirname(__dirname);
const readmePath = path.join(rootDir, 'README.md');
const readmeDraftPath = path.join(rootDir, 'tools', 'README.draft.md');
const distFilePath = path.join(rootDir, 'dist', 'browser-id3-writer.min.js');
const algo = 'sha384';

const readmeDraft = fs.readFileSync(readmeDraftPath, 'utf8');
const hash = crypto.createHash(algo);
hash.update(fs.readFileSync(distFilePath, 'utf8'));
const digest = hash.digest('base64');
const readme = readmeDraft
    .replace('###version###', pack.version)
    .replace('###hash###', `${algo}-${digest}`);
fs.writeFileSync(readmePath, readme);

console.log(`${readmePath} is updated, version: ${pack.version}, hash: ${algo}-${digest}`);

{'fraction_non_alphanumeric': 0.20410703173615433, 'fraction_numerical': 0.011823273179838207, 'mean_word_length': 6.584905660377358, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4704490', 'n_tokens_mistral': 545, 'n_tokens_neox': 535, 'n_words': 109}