-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #475 from michavie/codemetadata-codec
CodeMetadata Codec
- Loading branch information
Showing
4 changed files
with
47 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { CodeMetadata } from "../codeMetadata"; | ||
import { CodeMetadataValue } from "../typesystem/codeMetadata"; | ||
|
||
export class CodeMetadataCodec { | ||
decodeNested(buffer: Buffer): [CodeMetadataValue, number] { | ||
const codeMetadata = CodeMetadata.fromBuffer(buffer); | ||
|
||
return [new CodeMetadataValue(codeMetadata), length]; | ||
} | ||
|
||
decodeTopLevel(buffer: Buffer): CodeMetadataValue { | ||
const codeMetadata = CodeMetadata.fromBuffer(buffer); | ||
|
||
return new CodeMetadataValue(codeMetadata); | ||
} | ||
|
||
encodeNested(codeMetadata: CodeMetadataValue): Buffer { | ||
return codeMetadata.valueOf().toBuffer(); | ||
} | ||
|
||
encodeTopLevel(codeMetadata: CodeMetadataValue): Buffer { | ||
return codeMetadata.valueOf().toBuffer(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters