Code & Beyond: Eugene’s Dev Journey

Back

getUniqueFileName.mjs
import splitFileNameRegex from './splitFileNameRegex.mjs'; 

/**
 * 주어진 파일 이름에 숫자 카운트를 추가하여 고유한 파일 이름을 생성합니다.
 *
 * @param {string} fileName - 원본 파일 이름.
 * @param {string | number} postfix - 중복 방지를 위한 postfix, 보통 숫자 카운트.
 * @returns {string} 고유한 파일 이름.
 */
export default function getUniqueFileName(fileName, postfix) {
  const splitted = splitFileNameRegex(fileName);
  return splitted.extension
    ? `${splitted.name}_${postfix}.${splitted.extension}`
    : `${splitted.name}_${postfix}`;
}
mjs
parse-code-blocks-with-gray-matter.mjs
https://eugenejeon.me/blog/snippet-parse-code-blocks-with-gray-matter-mjs/
Author Eugene
Published at 2025년 3월 2일