| Total Complexity | 2 |
| Complexity/F | 0 |
| Lines of Code | 40 |
| Function Count | 0 |
| Duplicated Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | import { FrameBuilder } from "../FrameBuilder" |
||
| 2 | import { FrameReader } from "../FrameReader" |
||
| 3 | import { TextEncoding } from "../definitions/Encoding" |
||
| 4 | import type { Data } from "./type" |
||
| 5 | |||
| 6 | export const GENERIC_TEXT = { |
||
| 7 | create: (frameIdentifier: string, data: Data) => { |
||
| 8 | if(!frameIdentifier || !data) { |
||
| 9 | return null |
||
| 10 | } |
||
| 11 | |||
| 12 | return new FrameBuilder(frameIdentifier) |
||
| 13 | .appendNumber(0x01, 0x01) |
||
| 14 | .appendValue(data, null, TextEncoding.UTF_16_WITH_BOM) |
||
| 15 | .getBuffer() |
||
| 16 | }, |
||
| 17 | read: (buffer: Buffer) => { |
||
| 18 | const reader = new FrameReader(buffer, 0) |
||
| 19 | |||
| 20 | return reader.consumeStaticValue('string') |
||
| 21 | } |
||
| 22 | } |
||
| 23 | |||
| 24 | export const GENERIC_URL = { |
||
| 25 | create: (frameIdentifier: string, data: Data) => { |
||
| 26 | if(!frameIdentifier || !data) { |
||
| 27 | return null |
||
| 28 | } |
||
| 29 | |||
| 30 | return new FrameBuilder(frameIdentifier) |
||
| 31 | .appendValue(data) |
||
| 32 | .getBuffer() |
||
| 33 | }, |
||
| 34 | read: (buffer: Buffer) => { |
||
| 35 | const reader = new FrameReader(buffer) |
||
| 36 | |||
| 37 | return reader.consumeStaticValue('string') |
||
| 38 | } |
||
| 39 | } |
||
| 40 |