From 221bfac0191c496706bbf50e1a051d537170357b Mon Sep 17 00:00:00 2001 From: Amaury Martiny Date: Wed, 17 Oct 2018 11:51:57 +0200 Subject: [PATCH] No from* (#309) * Remove fromJSON/fromU8a * Remove fromJSONx * Remove unused import --- packages/types/src/AccountId.ts | 12 --------- packages/types/src/AccountIndex.ts | 14 ----------- packages/types/src/Address.ts | 14 ----------- packages/types/src/Bool.ts | 12 --------- packages/types/src/Bytes.ts | 8 ------ packages/types/src/Extrinsic.spec.js | 2 +- packages/types/src/Extrinsic.ts | 14 ----------- packages/types/src/ExtrinsicEra.ts | 6 ----- packages/types/src/ExtrinsicSignature.ts | 18 -------------- packages/types/src/Metadata.ts | 31 +++--------------------- packages/types/src/Moment.ts | 14 ----------- packages/types/src/Null.ts | 8 ------ packages/types/src/Text.ts | 14 ----------- packages/types/src/Type.ts | 12 --------- packages/types/src/codec/Base.spec.js | 2 +- packages/types/src/codec/Base.ts | 10 +------- packages/types/src/codec/Compact.spec.js | 2 +- packages/types/src/codec/Compact.ts | 8 ------ packages/types/src/codec/Enum.ts | 14 ----------- packages/types/src/codec/EnumType.ts | 26 -------------------- packages/types/src/codec/Option.ts | 20 --------------- packages/types/src/codec/Struct.ts | 31 ------------------------ packages/types/src/codec/Tuple.spec.js | 19 --------------- packages/types/src/codec/Tuple.ts | 19 ++------------- packages/types/src/codec/U8a.ts | 14 +---------- packages/types/src/codec/U8aFixed.ts | 14 ----------- packages/types/src/codec/UInt.ts | 10 -------- packages/types/src/codec/Vector.ts | 15 ------------ 28 files changed, 11 insertions(+), 372 deletions(-) diff --git a/packages/types/src/AccountId.ts b/packages/types/src/AccountId.ts index 4e57cef3c4..6e17048989 100644 --- a/packages/types/src/AccountId.ts +++ b/packages/types/src/AccountId.ts @@ -41,18 +41,6 @@ export default class AccountId extends U8aFixed { return decodeAddress(value); } - fromJSON (input: any): AccountId { - super.fromJSON(AccountId.decodeAccountId(input)); - - return this; - } - - fromU8a (input: Uint8Array): AccountId { - super.fromU8a(input); - - return this; - } - toJSON (): any { return this.toString(); } diff --git a/packages/types/src/AccountIndex.ts b/packages/types/src/AccountIndex.ts index eb93fdad7e..ec6055a217 100644 --- a/packages/types/src/AccountIndex.ts +++ b/packages/types/src/AccountIndex.ts @@ -90,20 +90,6 @@ export default class AccountIndex extends U8a { } } - fromJSON (input: any): AccountIndex { - super.fromJSON(AccountIndex.decodeAccountIndex(input)); - - return this; - } - - fromU8a (input: Uint8Array): AccountIndex { - const [offset, length] = AccountIndex.readLength(input); - - super.fromU8a(input.subarray(offset, offset + length)); - - return this; - } - toJSON (): any { return this.toString(); } diff --git a/packages/types/src/Address.ts b/packages/types/src/Address.ts index 6b50b8b32c..721daf6742 100644 --- a/packages/types/src/Address.ts +++ b/packages/types/src/Address.ts @@ -69,20 +69,6 @@ export default class Address extends Base { ); } - fromJSON (input: any): Address { - this.raw = Address.decodeAddress(input); - - return this; - } - - fromU8a (input: Uint8Array): Address { - this.raw = input[0] === 0xff - ? new AccountId().fromU8a(input.subarray(1)) - : new AccountIndex().fromU8a(input); - - return this; - } - toHex (): string { return u8aToHex(this.toU8a()); } diff --git a/packages/types/src/Bool.ts b/packages/types/src/Bool.ts index 8ceb2b5b10..6ca356d4be 100644 --- a/packages/types/src/Bool.ts +++ b/packages/types/src/Bool.ts @@ -26,18 +26,6 @@ export default class Bool extends Base { return 1; } - fromJSON (input: any): Bool { - this.raw = input === true; - - return this; - } - - fromU8a (input: Uint8Array): Bool { - this.raw = input[0] === 1; - - return this; - } - toJSON (): any { return this.raw; } diff --git a/packages/types/src/Bytes.ts b/packages/types/src/Bytes.ts index cc994e9216..543522f880 100644 --- a/packages/types/src/Bytes.ts +++ b/packages/types/src/Bytes.ts @@ -50,14 +50,6 @@ export default class Bytes extends U8a { return this.length + Compact.encodeU8a(this.length, DEFAULT_LENGTH_BITS).length; } - fromU8a (input: Uint8Array): Bytes { - const [offset, length] = Compact.decodeU8a(input, DEFAULT_LENGTH_BITS); - - super.fromU8a(input.subarray(offset, offset + length.toNumber())); - - return this; - } - toU8a (isBare?: boolean): Uint8Array { return isBare ? this.raw diff --git a/packages/types/src/Extrinsic.spec.js b/packages/types/src/Extrinsic.spec.js index 24d8dc7247..835c739412 100644 --- a/packages/types/src/Extrinsic.spec.js +++ b/packages/types/src/Extrinsic.spec.js @@ -12,7 +12,7 @@ describe('Extrinsic', () => { Method.injectExtrinsics(extrinsics); }); - it('decodes a non-signed properly via fromJSON', () => { + it('decodes a non-signed properly via JSON', () => { const extrinsic = new Extrinsic('0x010200ea51b75b00000000'); expect(extrinsic.isSigned).toEqual(false); diff --git a/packages/types/src/Extrinsic.ts b/packages/types/src/Extrinsic.ts index b0c975d0f4..bb6548e16f 100644 --- a/packages/types/src/Extrinsic.ts +++ b/packages/types/src/Extrinsic.ts @@ -111,20 +111,6 @@ export default class Extrinsic extends Struct { return length + Compact.encodeU8a(length, DEFAULT_LENGTH_BITS).length; } - fromJSON (input: any): Extrinsic { - super.fromU8a(hexToU8a(input)); - - return this; - } - - fromU8a (input: Uint8Array): Extrinsic { - const [offset, length] = Compact.decodeU8a(input, DEFAULT_LENGTH_BITS); - - super.fromU8a(input.subarray(offset, offset + length.toNumber())); - - return this; - } - sign (signerPair: KeyringPair, nonce: AnyNumber, blockHash: AnyU8a): Extrinsic { this.signature.addSignature(this.method, signerPair, nonce, blockHash); diff --git a/packages/types/src/ExtrinsicEra.ts b/packages/types/src/ExtrinsicEra.ts index 06c893a96d..8c147c0153 100644 --- a/packages/types/src/ExtrinsicEra.ts +++ b/packages/types/src/ExtrinsicEra.ts @@ -28,10 +28,4 @@ export default class ExtrinsicEra extends U8a { return new Uint8Array([0]); } - - fromU8a (input: Uint8Array): ExtrinsicEra { - super.fromU8a(ExtrinsicEra.decodeExtrinsicEra(input)); - - return this; - } } diff --git a/packages/types/src/ExtrinsicSignature.ts b/packages/types/src/ExtrinsicSignature.ts index 631db46522..301dcce417 100644 --- a/packages/types/src/ExtrinsicSignature.ts +++ b/packages/types/src/ExtrinsicSignature.ts @@ -7,7 +7,6 @@ import { AnyNumber, AnyU8a } from './types'; import isU8a from '@polkadot/util/is/u8a'; import u8aConcat from '@polkadot/util/u8a/concat'; -import u8aToU8a from '@polkadot/util/u8a/toU8a'; import Struct from './codec/Struct'; import Address from './Address'; @@ -122,23 +121,6 @@ export default class ExtrinsicSignature extends Struct { return this; } - fromJSON (input: any) { - return this.fromU8a(u8aToU8a(input)); - } - - fromU8a (input: Uint8Array): ExtrinsicSignature { - const version = input[0]; - - if ((version & BIT_SIGNED) === BIT_SIGNED) { - super.fromU8a(input.subarray(1)); - } else { - // Just clear signature, leave others as-is - this.raw.signature = new Signature(); - } - - return this; - } - toU8a (isBare?: boolean): Uint8Array { return u8aConcat( new Uint8Array([this.version]), diff --git a/packages/types/src/Metadata.ts b/packages/types/src/Metadata.ts index 7e3dd1b63d..f888f78bb4 100644 --- a/packages/types/src/Metadata.ts +++ b/packages/types/src/Metadata.ts @@ -7,7 +7,6 @@ import { AnyNumber } from './types'; import hexToU8a from '@polkadot/util/hex/toU8a'; import isHex from '@polkadot/util/is/hex'; import isU8a from '@polkadot/util/is/u8a'; -import toU8a from '@polkadot/util/u8a/toU8a'; import Base from './codec/Base'; import Compact, { DEFAULT_LENGTH_BITS } from './codec/Compact'; @@ -332,6 +331,8 @@ export default class RuntimeMetadata extends Struct { static decodeMetadata (value: any): object | Uint8Array { if (isHex(value)) { + // We receive this as an Array in the JSON output from the Node. + // Convert to u8a and use the U8a version to do the actual parsing. return RuntimeMetadata.decodeMetadata(hexToU8a(value)); } else if (isU8a(value)) { // HACK 13 Oct 2018 - For current running BBQ nodes, Metadata is not properly @@ -350,34 +351,10 @@ export default class RuntimeMetadata extends Struct { return value; } - // We receive this as an Array in the JSON output from the Node. Convert - // to u8a and use the fromU8a to do the actual parsing - fromJSON (input: Uint8Array | string | Array): RuntimeMetadata { - return this.fromU8a( - toU8a(input) - ); - } - - fromU8a (input: Uint8Array): RuntimeMetadata { - // HACK 13 Oct 2018 - For current running BBQ nodes, Metadata is not properly - // encoded, it does not have a length prefix. For latest substrate master, it - // is properly encoded. Here we pull the prefix, check it agianst the length - - // if matches, then we have the length, otherwise we assume it is an older node - // and use the whole buffer - const [offset, length] = Compact.decodeU8a(input, DEFAULT_LENGTH_BITS); - - super.fromU8a( - input.length === (offset + length.toNumber()) - ? input.subarray(offset) - : input - ); - - return this; - } - // FIXME Currently toJSON creates a struct, so it is not a one-to-one mapping // with what is actually found on the RPC layer. This needs to be adjusted to - // match fromJSON. (However for now, it is useful in debugging) + // match the constructor with JSON. (However for now, it is useful in + // debugging). toJSON (): any { return super.toJSON(); } diff --git a/packages/types/src/Moment.ts b/packages/types/src/Moment.ts index 193605d9ee..94e649d1b0 100644 --- a/packages/types/src/Moment.ts +++ b/packages/types/src/Moment.ts @@ -48,20 +48,6 @@ export default class Moment extends Base { return BITLENGTH / 8; } - fromJSON (input: any): Moment { - this.raw = Moment.decodeMoment(input); - - return this; - } - - fromU8a (input: Uint8Array): Moment { - this.raw = Moment.decodeMoment( - u8aToBn(input.subarray(0, this.byteLength()), true) - ); - - return this; - } - getTime (): number { return this.raw.getTime(); } diff --git a/packages/types/src/Null.ts b/packages/types/src/Null.ts index eceadeeeb6..3d38bb0fec 100644 --- a/packages/types/src/Null.ts +++ b/packages/types/src/Null.ts @@ -14,14 +14,6 @@ export default class Null extends Base { return 0; } - fromJSON (input: any): Null { - return this; - } - - fromU8a (input: Uint8Array): Null { - return this; - } - toJSON (): any { return null; } diff --git a/packages/types/src/Text.ts b/packages/types/src/Text.ts index 0c46703b53..5b00b45864 100644 --- a/packages/types/src/Text.ts +++ b/packages/types/src/Text.ts @@ -53,20 +53,6 @@ export default class Text extends Base { return this.length + Compact.encodeU8a(this.length, DEFAULT_LENGTH_BITS).length; } - fromU8a (input: Uint8Array): Text { - const [offset, length] = Compact.decodeU8a(input, DEFAULT_LENGTH_BITS); - - this.raw = u8aToUtf8(input.subarray(offset, offset + length.toNumber())); - - return this; - } - - fromJSON (input: any): Text { - this.raw = `${input || ''}`; - - return this; - } - toJSON (): any { return this.toString(); } diff --git a/packages/types/src/Type.ts b/packages/types/src/Type.ts index df0cacba51..01ada18c10 100644 --- a/packages/types/src/Type.ts +++ b/packages/types/src/Type.ts @@ -27,18 +27,6 @@ export default class Type extends Text { return this._originalLength; } - fromJSON (input: any): Type { - super.fromJSON(input); - - return this._cleanupTypes(); - } - - fromU8a (input: Uint8Array): Type { - super.fromU8a(input); - - return this._cleanupTypes(); - } - // Note Since we are mangling what we get in beyond recognition, we really should // not allow the re-encoding. Additionally, this is probably more of a decoder-only // helper, so treat it as such. diff --git a/packages/types/src/codec/Base.spec.js b/packages/types/src/codec/Base.spec.js index 1aecc435ea..870e49be03 100644 --- a/packages/types/src/codec/Base.spec.js +++ b/packages/types/src/codec/Base.spec.js @@ -9,7 +9,7 @@ describe('Base', () => { expect(new Base('foo-bar').raw).toEqual('foo-bar'); }); - ['byteLength', 'fromJSON', 'fromU8a', 'toJSON', 'toString', 'toU8a'].forEach((method) => { + ['byteLength', 'toJSON', 'toString', 'toU8a'].forEach((method) => { it(`has abstract (?) impl for ${method}`, () => { expect( () => new Base()[method]() diff --git a/packages/types/src/codec/Base.ts b/packages/types/src/codec/Base.ts index 6c39bab7da..a943e6f3aa 100644 --- a/packages/types/src/codec/Base.ts +++ b/packages/types/src/codec/Base.ts @@ -15,7 +15,7 @@ export const l = logger('codec'); // - Not convinced about abstratc - there are a number of extensions to this class that // don't provide some implementations (e.g. Length, good example and should not be // used-as-is). In those case it just relies in the throw in here. -export default class Base { +export default class Base { raw: T; constructor (value?: any) { @@ -26,14 +26,6 @@ export default class Base { throw new Error('Base::byteLength: unimplemented'); } - fromJSON (input: any): Base { - throw new Error('Base::fromJSON: unimplemented'); - } - - fromU8a (input: Uint8Array): Base { - throw new Error('Base::fromU8a: unimplemented'); - } - toJSON (): any { throw new Error('Base::toJSON: unimplemented'); } diff --git a/packages/types/src/codec/Compact.spec.js b/packages/types/src/codec/Compact.spec.js index 85eb980281..adc204f522 100644 --- a/packages/types/src/codec/Compact.spec.js +++ b/packages/types/src/codec/Compact.spec.js @@ -102,7 +102,7 @@ describe('Compact', () => { ).toEqual(5); }); - it('constructs properly via fromU8a', () => { + it('constructs properly via U8a', () => { expect( new Compact(new Uint8Array([254, 255, 3, 0])).raw ).toEqual(new BN(0xffff)); diff --git a/packages/types/src/codec/Compact.ts b/packages/types/src/codec/Compact.ts index b689040c3d..f5ca1b8d0a 100644 --- a/packages/types/src/codec/Compact.ts +++ b/packages/types/src/codec/Compact.ts @@ -102,14 +102,6 @@ export default class Compact extends UInt { return this.toU8a().length; } - fromU8a (input: Uint8Array): UInt { - const [, value] = Compact.decodeU8a(input, this._bitLength); - - this.raw = value; - - return this; - } - toU8a (isBare?: boolean): Uint8Array { return Compact.encodeU8a(this.raw, this._bitLength); } diff --git a/packages/types/src/codec/Enum.ts b/packages/types/src/codec/Enum.ts index e65115f656..ba132ea209 100644 --- a/packages/types/src/codec/Enum.ts +++ b/packages/types/src/codec/Enum.ts @@ -42,20 +42,6 @@ export default class Enum extends Base { return 1; } - fromJSON (input: any): Enum { - // FIXME We potentially want to assert that the value is actually inside this._enum - this.raw = input; - - return this; - } - - fromU8a (input: Uint8Array): Enum { - // FIXME We potentially want to assert that the value is actually inside this._enum - this.raw = input[0]; - - return this; - } - toJSON (): any { return this.raw; } diff --git a/packages/types/src/codec/EnumType.ts b/packages/types/src/codec/EnumType.ts index bfad257a63..b437a6aa8f 100644 --- a/packages/types/src/codec/EnumType.ts +++ b/packages/types/src/codec/EnumType.ts @@ -90,32 +90,6 @@ export default class EnumType extends Base> { return 1 + this.raw.byteLength(); } - fromJSON (input: any = {}): EnumType { - // JSON comes in the form of { "": "" }, here we - // additionally force to lower to ensure forward compat - const key = Object.keys(input)[0]; - const lowerKey = key.toLowerCase(); - const index = this._indexes.find((value, index) => - this._Types[index].name.toLowerCase() === lowerKey - ); - - if (isUndefined(index)) { - throw new Error('Unable to reliably map input on JSON'); - } - - this.setValue(index); - this.raw.fromJSON(input[key]); - - return this; - } - - fromU8a (input: Uint8Array): EnumType { - this.setValue(input[0]); - this.raw.fromU8a(input.subarray(1)); - - return this; - } - setValue (index?: | EnumType | number, value?: any): void { if (index instanceof EnumType) { this._index = index._index; diff --git a/packages/types/src/codec/Option.ts b/packages/types/src/codec/Option.ts index 3dabc8aa7e..83b30b8a7e 100644 --- a/packages/types/src/codec/Option.ts +++ b/packages/types/src/codec/Option.ts @@ -67,26 +67,6 @@ export default class Option extends Base> { return 1 + childLength; } - fromJSON (input: any): Option { - this._isEmpty = isNull(input) || isUndefined(input); - - if (!this._isEmpty) { - this.raw.fromJSON(input); - } - - return this; - } - - fromU8a (input: Uint8Array): Option { - this._isEmpty = input[0] === 0; - - if (!this._isEmpty) { - this.raw.fromU8a(input.subarray(1)); - } - - return this; - } - toJSON (): any { return this._isEmpty ? undefined diff --git a/packages/types/src/codec/Struct.ts b/packages/types/src/codec/Struct.ts index 83382813ce..f2b07fdfc9 100644 --- a/packages/types/src/codec/Struct.ts +++ b/packages/types/src/codec/Struct.ts @@ -7,7 +7,6 @@ import isHex from '@polkadot/util/is/hex'; import isObject from '@polkadot/util/is/object'; import isU8a from '@polkadot/util/is/u8a'; import u8aConcat from '@polkadot/util/u8a/concat'; -import toU8a from '@polkadot/util/u8a/toU8a'; import Base from './Base'; import { Constructor } from '../types'; @@ -125,36 +124,6 @@ export default class Struct< }, 0); } - fromJSON (input: any): Struct { - if (isHex(input) || isU8a(input)) { - return this.fromU8a(toU8a(input)); - } - - // null & undefined yields empty - if (!input) { - input = {}; - } - - Object.keys(this.raw).forEach((key) => { - const jsonKey = this._jsonMap.get(key as any) || key; - - // @ts-ignore as above... - this.raw[key].fromJSON(input[jsonKey]); - }); - - return this; - } - - fromU8a (input: Uint8Array): Struct { - Object.values(this.raw).reduce((offset, entry) => { - entry.fromU8a(input.subarray(offset)); - - return offset + entry.byteLength(); - }, 0); - - return this; - } - get (index: number): Base { return this.values()[index]; } diff --git a/packages/types/src/codec/Tuple.spec.js b/packages/types/src/codec/Tuple.spec.js index 245ee5ebc1..cf1e832507 100644 --- a/packages/types/src/codec/Tuple.spec.js +++ b/packages/types/src/codec/Tuple.spec.js @@ -51,25 +51,6 @@ describe('Tuple', () => { ]); }); - // FIXME Remove fromJSON - it('fromJSON still works', () => { - const test = new (Tuple.with({ - a: Text, - b: U32, - c: Text - }))(); - - expect( - test.fromJSON([ - 'bazzing', 32 - ]).toJSON() - ).toEqual([ - 'bazzing', - 32, - '' - ]); - }); - it('creates properly via actual hex string', () => { const test = new (Tuple.with({ blockNumber: BlockNumber, diff --git a/packages/types/src/codec/Tuple.ts b/packages/types/src/codec/Tuple.ts index fbbc37510f..740afb9f2a 100644 --- a/packages/types/src/codec/Tuple.ts +++ b/packages/types/src/codec/Tuple.ts @@ -2,15 +2,12 @@ // This software may be modified and distributed under the terms // of the ISC license. See the LICENSE file for details. -import hexToU8a from '@polkadot/util/hex/toU8a'; -import isHex from '@polkadot/util/is/hex'; - import { AnyU8a, Constructor } from '../types'; import Base from './Base'; import Struct from './Struct'; -// A Tuple defines an anonymous Object with key/values - where the values are Base values.It -// is a specialization of the Struct type where the toJSON/fromJSON operates on Array structures, +// A Tuple defines an anonymous Object with key/values - where the values are Base values. It +// is a specialization of the Struct type where the toJSON operates on Array structures, // while the U8a encoding is handled in the same way as a Struct export default class Tuple< // S & T definitions maps to what we have in Struct (naming documented there) @@ -48,18 +45,6 @@ export default class Tuple< }; } - fromJSON (input: any): Tuple { - if (isHex(input)) { - return this.fromU8a(hexToU8a(input)); - } - - Object.values(this.raw).forEach((entry, index) => { - entry.fromJSON(input[index]); - }); - - return this; - } - toJSON (): any { return Object.values(this.raw).map((entry) => entry.toJSON() diff --git a/packages/types/src/codec/U8a.ts b/packages/types/src/codec/U8a.ts index 2b9c9cc013..e91eee0e3f 100644 --- a/packages/types/src/codec/U8a.ts +++ b/packages/types/src/codec/U8a.ts @@ -11,7 +11,7 @@ import Base from './Base'; // A U8a. A basic wrapper around Uint8Array, with no frills and no fuss. It // wraps a Uint8Array. It does differ from other implementations wher it will -// consume the full u8a as passed to it in fromU8a. As such it is meant to be +// consume the full u8a as passed to it in U8a. As such it is meant to be // subclassed where the wrapper takes care of the actual lengths. export default class U8a extends Base { constructor (value: AnyU8a = new Uint8Array()) { @@ -38,18 +38,6 @@ export default class U8a extends Base { return this.length; } - fromJSON (input: any): U8a { - this.raw = toU8a(input); - - return this; - } - - fromU8a (input: Uint8Array): U8a { - this.raw = input; - - return this; - } - toHex (): string { return u8aToHex(this.raw); } diff --git a/packages/types/src/codec/U8aFixed.ts b/packages/types/src/codec/U8aFixed.ts index 9a79b2c044..f01ce4b491 100644 --- a/packages/types/src/codec/U8aFixed.ts +++ b/packages/types/src/codec/U8aFixed.ts @@ -32,18 +32,4 @@ export default class U8aFixed extends U8a { byteLength (): number { return this._trimLength(); } - - fromJSON (input: any): U8aFixed { - super.fromJSON(input); - - this._trim(); - - return this; - } - - fromU8a (input: Uint8Array): U8aFixed { - super.fromU8a(input.subarray(0, this._trimLength())); - - return this; - } } diff --git a/packages/types/src/codec/UInt.ts b/packages/types/src/codec/UInt.ts index 7774ffa7b9..025e6c895d 100644 --- a/packages/types/src/codec/UInt.ts +++ b/packages/types/src/codec/UInt.ts @@ -58,16 +58,6 @@ export default class UInt extends Base { return this._bitLength / 8; } - fromJSON (input: any): UInt { - this.raw = UInt.decodeUInt(input, this._bitLength); - - return this; - } - - fromU8a (input: Uint8Array): UInt { - return this.fromJSON(input); - } - toHex (): string { return bnToHex(this.raw, this._bitLength); } diff --git a/packages/types/src/codec/Vector.ts b/packages/types/src/codec/Vector.ts index bb47aa6073..e0a30cd4b6 100644 --- a/packages/types/src/codec/Vector.ts +++ b/packages/types/src/codec/Vector.ts @@ -87,21 +87,6 @@ export default class Vector< return this.raw.forEach(fn); } - fromJSON (input: any): Vector { - // input could be null/undefined to indicate empty - this.raw = (input || []).map((input: any) => - new this._Type().fromJSON(input) - ); - - return this; - } - - fromU8a (input: Uint8Array): Vector { - this.raw = Vector.decode(this._Type, input); - - return this; - } - get (index: number): T { return this.raw[index]; }