Compact unwrap (returns raw UInt/Moment) (#636)

This commit is contained in:
Jaco Greeff
2019-01-28 12:14:27 +01:00
committed by Amaury Martiny
parent e4de84b225
commit 5898caa71e
2 changed files with 11 additions and 0 deletions
+4
View File
@@ -145,6 +145,10 @@ describe('Compact', () => {
it('compares against a primitive', () => {
expect(new Compact(U32, 12345).eq(12345)).toBe(true);
});
it('unwraps to the wrapped value', () => {
expect(new Compact(U32, 12345).unwrap() instanceof U32).toBe(true);
});
});
describe('helpers', () => {
+7
View File
@@ -133,4 +133,11 @@ export default class Compact extends Base<UInt | Moment> implements Codec {
toU8a (isBare?: boolean): Uint8Array {
return Compact.encodeU8a(this.raw.toBn());
}
/**
* @description Returns the embedded [[UInt]] or [[Moment]] value
*/
unwrap (): UInt | Moment {
return this.raw;
}
}