@player-ui/player
Version:
50 lines • 1.91 kB
TypeScript
export interface BindingParserOptions {
/** Get the value for a specific binding */
get: (binding: BindingInstance) => any;
/**
* Set the values for bindings.
* This is used when the query syntax needs to modify an object
*/
set: (transaction: Array<[BindingInstance, any]>) => void;
/**
* Get the result of evaluating an expression
*/
evaluate: (exp: string) => any;
/**
* Without readOnly, if a binding such as this is used: arr[key='does not exist'],
* then an object with that key will be created.
* This is done to make assignment such as arr[key='abc'].val = 'foo' work smoothly.
* Setting readOnly to true will prevent this behavior, avoiding unintended data changes.
*/
readOnly?: boolean;
}
export type Getter = (path: BindingInstance) => any;
export type RawBindingSegment = number | string;
export type RawBinding = string | RawBindingSegment[];
export type BindingLike = RawBinding | BindingInstance;
export type BindingFactory = (raw: RawBinding, options?: Partial<BindingParserOptions>) => BindingInstance;
/**
* A path in the data model
*/
export declare class BindingInstance {
private split;
private joined;
private factory;
constructor(raw: RawBinding, factory?: (rawBinding: RawBinding) => BindingInstance);
asArray(): RawBindingSegment[];
asString(): string;
/**
* Check to see if the given binding is a sub-path of the current one
*/
contains(binding: BindingInstance): boolean;
relative(binding: BindingInstance): RawBindingSegment[];
parent(): BindingInstance;
key(): RawBindingSegment;
/**
* This is a utility method to get a binding that is a descendent of this binding
*
* @param relative - The relative path to descend to
*/
descendent(relative: BindingLike): BindingInstance;
}
//# sourceMappingURL=binding.d.ts.map