@open-kappa/myjson
Version:
A simple JSON management library.
72 lines (71 loc) • 2.65 kB
TypeScript
import { MyJson, MyJsonBaseObject } from "./myjsonImpl";
/**
* @brief An object representing a map from strings to objects.
* @typeparam Element The map value type.
*/
declare class MyJsonMap<Element extends MyJson> extends MyJsonBaseObject {
/**
* @brief Constructor.
* @param {Element} element The validator for elements. If it is
* mandatory, then the map cannot be empty.
* @param {boolean} isMandatory True if the object must appear in the
* hierarchy.
* @param {string} name The name of the object.
*/
constructor(element: Element, isMandatory: boolean, name: string);
/**
* @brief Return the internal validator element of the map.
* It uses a symbol to hide the properties to "usual" javascript methods.
* @private
* @return {Element} The validator.
*/
private _getValidatorElement;
/**
* @brief Parse a JSON object.
* @param {any} json The JSON to parse.
* @throws {Error} If a validation error occurrs.
*/
protected parseJsonImpl(json: any): void;
/**
* @brief Clear the object content.
*/
protected clearImpl(): void;
/**
* @brief Clone this object.
* @return {MyJsonMap<Element>} The copy.
*/
clone(): MyJsonMap<Element>;
/**
* @brief Check if two JSON objects are equals.
* @param {MyJson} other The other object of comparison.
* @return {boolean} True if they are equals.
*/
isEqual(other: MyJson): boolean;
/**
* @brief Execute the given callback on each element.
* The callback takes the key, the element, and the whole object.
* It returns true to break the loop before having rolled on all elements.
* @param {(key:string,value:Element,obj:MyJsonMap<Element>)=>boolean} func
* The callback.
* @param {any | null | undefined} [funcThis=null] The optional "this" for
* the callback.
*/
forEach(func: (key: string, value: Element, obj: MyJsonMap<Element>) => boolean, funcThis?: any | null | undefined): boolean;
/**
* @brief Merge the two objects.
* Already existent keys are merged recursively.
* @param {MyJson} other The other object to merge.
* @throws {Error} If the two objects cannot be merged.
*/
merge(other: MyJson): void;
/**
* @brief Add a new child element.
* This is a build-time support method.
* @param {MyJson} _element The child element.
* @return {MyJson} This.
* @throws {Error} If element cannot be added.
*/
add(_element: MyJson): MyJsonMap<Element>;
}
export { MyJsonMap };
export default MyJsonMap;