Skip to content

Commit

Permalink
update(data type): reformulate the data type and function of nomalize…
Browse files Browse the repository at this point in the history
…Data
  • Loading branch information
dependentmadani committed Jul 4, 2024
1 parent dbd0aa1 commit 9cbae65
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export default class Header {
* @type {HeaderData}
* @private
*/
this._data = this.normalizeData(data as HeaderData);
this._data = this.normalizeData(data);

/**
* Main Block wrapper
Expand Down Expand Up @@ -155,15 +155,15 @@ export default class Header {
* @returns {HeaderData}
* @private
*/
normalizeData(data: HeaderData): HeaderData {
normalizeData(data: HeaderData | {}): HeaderData {
const newData: HeaderData = { text: '', level: this.defaultLevel.number };

if (!this.isHeaderData(data)) {
data = { text: '', level: this.defaultLevel.number};
}

newData.text = data.text || '';
newData.level = parseInt(data.level.toString()) || this.defaultLevel.number;
newData.text = (data as HeaderData).text || '';
newData.level = parseInt((data as HeaderData).level.toString()) || this.defaultLevel.number;

return newData;
}
Expand Down

0 comments on commit 9cbae65

Please sign in to comment.