{"version":3,"file":"index.cjs","sources":["../../src/jsonSerializerAdapter/JsonSerializerAdapter.js","../../src/index.js"],"sourcesContent":["/** @typedef SerializerHandler */\n\nexport class JsonSerializerAdapter {\n  #jsonSerializerCore\n\n  constructor(jsonSerializerCore) {\n    this.#jsonSerializerCore = jsonSerializerCore\n  }\n\n  /**\n   * Returns an object that contains the serializers added to JsonSerializer\n   * object. The keys are obtained from serializer.getSerializerType method and\n   * the values are the Serializer objects.\n   *\n   * @returns {object} Object that contains the serializers added to\n   *   JsonSerializer object.\n   */\n  getSerializers() {\n    return this.#jsonSerializerCore.getSerializers()\n  }\n\n  /**\n   * Adds serializers through the serializersInstaller and to update the\n   * JsonSerializer object.\n   *\n   * @param {object} serializersInstaller An object that adds serializers using\n   *   the install method.\n   * @param {(\n   *   serializerHandler: {\n   *     getSerializers: () => object\n   *     addSerializer: (serializer: object) => void\n   *   },\n   *   installOptions: object,\n   * ) => void} serializersInstaller.install\n   *   The method used to add serializers to JsonSerializer object.\n   * @param {object} [installOptions] An object that contains the install\n   *   options.\n   */\n  installSerializersAndRefreshJsonSerializer(\n    serializersInstaller,\n    installOptions = {},\n  ) {\n    this.#jsonSerializerCore.installSerializersAndRefreshJsonSerializer(\n      serializersInstaller,\n      installOptions,\n    )\n  }\n\n  /**\n   * Adds a Serializer and to update the JsonSerializer object.\n   *\n   * @param {object} serializer An object used to serialize and unserialize\n   *   data.\n   * @param {() => string} serializer.getSerializerType An function that returns\n   *   the type of serializer.\n   * @param {(unserializedData: any) => object} serializer.serialize An function\n   *   that serializes data.\n   * @param {(serializedData: string) => any} serializer.parse An function that\n   *   unserializes data.\n   */\n  addSerializerAndRefreshJsonSerializer(serializer) {\n    this.#jsonSerializerCore.addSerializerAndRefreshJsonSerializer(serializer)\n  }\n\n  /**\n   * Serializes the data.\n   *\n   * @param {any} value The data to serialize.\n   * @param {object} options The serialize options used by the\n   *   jsonSerializer.serialize method.\n   * @param {string | number} [options.space] Adds indentation, white space, and\n   *   line break characters to the return-value JSON text to make it easier to\n   *   read.\n   * @returns {string} JSON string that contains the serialized data.\n   */\n  serialize(value, options = {}) {\n    const { space } = options\n    return this.#jsonSerializerCore.serialize(value, space)\n  }\n\n  /**\n   * Unserializes the data serialized by serialize method.\n   *\n   * @param {string} value The data to unserialize.\n   * @param {object} options The parse options used by the jsonSerializer.parse\n   *   method.\n   * @returns {any} The unserialized data.\n   */\n  parse(value, options = {}) {\n    return this.#jsonSerializerCore.parse(value)\n  }\n}\n","import { JsonSerializerFactory } from '@cljimenez/json-serializer-core'\nimport { baseSerializersInstaller } from '@cljimenez/json-serializer-base-serializers'\nimport { JsonSerializerAdapter } from './jsonSerializerAdapter/JsonSerializerAdapter'\n\n/**\n * Creates a new instance of JsonSerializerAdapter.\n *\n * @param {object} options The options used to configure the installer created\n *   by json-serializer-base-serializers\n * @param {boolean} [options.includeFunctionSerializer] An Boolean that\n *   indicates if the FunctionSerializer must be included. By default is false.\n * @returns {JsonSerializerAdapter} A new JsonSerializerAdapter object.\n */\nexport function createJsonSerializerAdapter(options = {}) {\n  const jsonSerializerCore = JsonSerializerFactory.createJsonSerializer()\n\n  jsonSerializerCore.installSerializersAndRefreshJsonSerializer(\n    baseSerializersInstaller,\n    options,\n  )\n\n  return new JsonSerializerAdapter(jsonSerializerCore)\n}\n"],"names":["JsonSerializerAdapter","jsonSerializerCore","_classCallCheck","_classPrivateFieldInitSpec","_jsonSerializerCore","writable","value","_classPrivateFieldSet","_createClass","key","getSerializers","_classPrivateFieldGet","installSerializersAndRefreshJsonSerializer","serializersInstaller","installOptions","arguments","length","undefined","addSerializerAndRefreshJsonSerializer","serializer","serialize","options","space","parse","createJsonSerializerAdapter","JsonSerializerFactory","createJsonSerializer","baseSerializersInstaller"],"mappings":";;;;;;;;;;;IAEaA,qBAAqB;EAGhC,SAAAA,sBAAYC,kBAAkB,EAAE;IAAAC,eAAA,OAAAF,qBAAA;IAAAG,0BAAA,OAAAC,mBAAA;MAAAC,QAAA;MAAAC,KAAA;I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