UNPKG

jamp3

Version:

mp3, id3v1, id3v2 - reader & writer

25 lines (23 loc) 673 B
import {IFrameImpl} from '../id3v2.frame'; import {ascii} from '../../../common/encodings'; import {IID3V2} from '../../id3v2.types'; export const FrameAscii: IFrameImpl = { /** Information <text string> */ parse: async (reader) => { const text = reader.readStringTerminated(ascii); const value: IID3V2.FrameValue.Ascii = {text}; return {value, encoding: ascii}; }, write: async (frame, stream) => { const value = <IID3V2.FrameValue.Ascii>frame.value; await stream.writeString(value.text, ascii); }, simplify: (value: IID3V2.FrameValue.Ascii) => { if (value && value.text && value.text.length > 0) { return value.text; } return null; } };