angular-odata
Version:
Client side OData typescript library for Angular
56 lines (55 loc) • 2.05 kB
TypeScript
import { EnumTypeConfig, ParserOptions } from '../types';
import { ODataParserSchemaElement } from './element';
import { ODataEnumTypeFieldParser, ODataEnumTypeParser } from './parsers';
import { ODataSchema } from './schema';
export declare class ODataEnumType<E> extends ODataParserSchemaElement<E, ODataEnumTypeParser<E>> {
members: {
[name: string]: number;
} | {
[value: number]: string;
};
constructor(config: EnumTypeConfig, schema: ODataSchema);
configure({ options }: {
options: ParserOptions;
}): void;
/**
* Returns the fields of the enum type.
* @returns The fields of the enum type.
*/
fields(namesValue?: string | number): ODataEnumTypeFieldParser[];
/**
* Find a field by name or value.
* @param enu The name or value of the field
* @returns The field with the given name or value
*/
field(nameValue: string | number): ODataEnumTypeFieldParser | undefined;
/**
* Map the fields of the enum type.
* @param mapper Function that maps the value to the new value
* @returns The fields mapped by the mapper
*/
mapFields<T>(mapper: (field: ODataEnumTypeFieldParser) => T): T[];
/**
* Deseialize the given value from the enum type.
* @param value Value to deserialize
* @param options Options for deserialization
* @returns Deserialized value
*/
deserialize(value: any, options?: ParserOptions): E;
/**
* Serialize the given value for the enum type.
* @param value Value to serialize
* @param options Options for serialization
* @returns Serialized value
*/
serialize(value: number, options?: ParserOptions): any;
/**
* Encode the given value for the enum type.
* @param value Value to encode
* @param options Options for encoding
* @returns Encoded value
*/
encode(value: number, options?: ParserOptions): any;
unpack(value: string | number): number[];
pack(value: string | number | number[]): number;
}