Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
liborm85 committed Nov 3, 2024
1 parent 2b3413a commit 033ea05
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
9 changes: 8 additions & 1 deletion src/ElementWriter.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,19 @@ import { EventEmitter } from 'events';
* their positions based on the context
*/
class ElementWriter extends EventEmitter {

/**
* @param {DocumentContext} context
*/
constructor(context) {
super();
this._context = context;
this.contextStack = [];
}

/**
* @returns {DocumentContext}
*/
context() {
return this._context;
}
Expand Down Expand Up @@ -371,7 +378,7 @@ class ElementWriter extends EventEmitter {
* pushContext(width, height) - creates and pushes a new context with the specified width and height
* pushContext() - creates a new context for unbreakable blocks (with current availableWidth and full-page-height)
*
* @param {object|number} contextOrWidth
* @param {DocumentContext|number} contextOrWidth
* @param {number} height
*/
pushContext(contextOrWidth, height) {
Expand Down
2 changes: 1 addition & 1 deletion src/Renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const findFont = (fonts, requiredFonts, defaultFont) => {
* @returns {number}
*/
const offsetText = (y, inline) => {
var newY = y;
let newY = y;
if (inline.sup) {
newY -= inline.fontSize * 0.75;
}
Expand Down
4 changes: 2 additions & 2 deletions src/SVGMeasure.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import xmldoc from 'xmldoc';
* @returns {?number}
*/
const stripUnits = textVal => {
var n = parseFloat(textVal);
let n = parseFloat(textVal);
if (typeof n !== 'number' || isNaN(n)) {
return undefined;
}
Expand All @@ -21,7 +21,7 @@ const stripUnits = textVal => {
* @returns {object}
*/
const parseSVG = (svgString) => {
var doc;
let doc;

try {
doc = new xmldoc.XmlDocument(svgString);
Expand Down
2 changes: 1 addition & 1 deletion src/TextInlines.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class TextInlines {
* Converts an array of strings (or inline-definition-objects) into a collection
* of inlines and calculated minWidth/maxWidth and their min/max widths
*
* @param {Array} textArray an array of inline-definition-objects (or strings)
* @param {Array|object} textArray an array of inline-definition-objects (or strings)
* @param {StyleContextStack} styleContextStack current style stack
* @returns {object} collection of inlines, minWidth, maxWidth
*/
Expand Down

0 comments on commit 033ea05

Please sign in to comment.