Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | 34x 34x 34x | import * as Immutable from 'immutable';
import * as utils from '../utils';
export class ValueToStringError extends utils.SiError {}
export class ValueFromStringError extends utils.SiError {}
export interface ISiFieldValue<T> {
field: ISiDataType<T>;
value: T;
toString: () => string;
}
export type ISiStorageData = Immutable.List<number|undefined>;
export interface ISiDataType<T> {
isValueValid: (value: T) => boolean;
typeSpecificIsValueValid: (value: T) => boolean;
valueToString: (value: T) => string|ValueToStringError;
typeSpecificValueToString: (value: T) => string|ValueToStringError;
valueFromString: (string: string) => T|ValueFromStringError;
typeSpecificValueFromString: (string: string) => T|ValueFromStringError;
extractFromData: (data: ISiStorageData) => ISiFieldValue<T>|undefined;
typeSpecificExtractFromData: (data: ISiStorageData) => T|undefined;
updateData: (data: ISiStorageData, newValue: T|ISiFieldValue<T>) => ISiStorageData;
typeSpecificUpdateData: (data: ISiStorageData, newValue: T) => ISiStorageData;
}
export type ISiStorageLocations<Fields> = {
[id in keyof Fields]: ISiDataType<Fields[id]>
};
/** Consists of locations and size */
export type ISiStorageDefinition<Fields> = (
initArg?: Immutable.List<number|undefined>|Array<number|undefined>
) => ISiStorage<Fields>;
export interface ISiStorage<T> {
size: number;
locations: ISiStorageLocations<T>;
data: ISiStorageData;
get: <U extends keyof T>(
fieldName: U,
) => ISiFieldValue<T[U]>|undefined;
set: <U extends keyof T>(
fieldName: U,
newValue: ISiFieldValue<T[U]>|T[U],
) => void;
splice: (
index: number,
removeNum: number,
...values: number[]
) => void;
}
|