Skip to content

Commit

Permalink
Fix capitalization of comment keys
Browse files Browse the repository at this point in the history
  • Loading branch information
the1812 committed Jun 30, 2023
1 parent 9dbab25 commit cecc052
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "flac-tagger",
"version": "1.0.1",
"version": "1.0.2",
"description": "Pure JavaScript FLAC Tag writer and reader.",
"main": "dist/esm/index.js",
"types": "dist/types/index.d.ts",
Expand Down
15 changes: 14 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,19 @@ import { MetadataBlockType } from './metadata-block/header'
* ```
*/
export type FlacTagMap = Record<string, string[] | string>
const createFlacTagMap = (): FlacTagMap => {
return new Proxy(
{},
{
get(target, p, receiver) {
return Reflect.get(target, p.toString().toUpperCase(), receiver)
},
set(target, p, newValue, receiver) {
return Reflect.set(target, p.toString().toUpperCase(), newValue, receiver)
},
},
)
}
/**
* The FLAC tags interface for read / write.
*/
Expand Down Expand Up @@ -65,7 +78,7 @@ const readFlacTagsBuffer = (buffer: Buffer) => {
const stream = FlacStream.fromBuffer(buffer)
const { vorbisCommentBlock, pictureBlock } = stream
const commentList = vorbisCommentBlock?.commentList ?? []
const tagMap: FlacTagMap = {}
const tagMap = createFlacTagMap()
commentList.forEach(it => {
const splitIndex = it.indexOf('=')
if (splitIndex === -1) {
Expand Down

0 comments on commit cecc052

Please sign in to comment.