Skip to content

convert project to ESM#401

Open
mlapaglia wants to merge 1 commit intosoldair:masterfrom
mlapaglia:master
Open

convert project to ESM#401
mlapaglia wants to merge 1 commit intosoldair:masterfrom
mlapaglia:master

Conversation

@mlapaglia
Copy link

No description provided.

@cinderblock
Copy link

Most of these diffs are formatting changes... would be nice to restrict it to the imports and leave whitespace/formatting alone.

Copy link

@Greenheart Greenheart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for starting an ESM migration.

However, there are some issues that need to be addressed:

  • Like previously mentioned, a big refactor like this should preserve the formatting (including whitespace) as closely as possible to reduce noise in the diff.

  • Another big problem with the current diff is that most useful docstrings are simply removed, rather than remaining with new ESM-equivalents in the code. The docstrings should remain even in the ESM version, since they provide a lot of useful information to understand the library.

Given there are several big issues in this diff, I think this change might benefit from a fresh start in a separate branch, while keeping this branch for reference.

Comment on lines -43 to -63

/**
* Returns an array containing the positions of each alignment pattern.
* Each array's element represent the center point of the pattern as (x, y) coordinates
*
* Coordinates are calculated expanding the row/column coordinates returned by {@link getRowColCoords}
* and filtering out the items that overlaps with finder pattern
*
* @example
* For a Version 7 symbol {@link getRowColCoords} returns values 6, 22 and 38.
* The alignment patterns, therefore, are to be centered on (row, column)
* positions (6,22), (22,6), (22,22), (22,38), (38,22), (38,38).
* Note that the coordinates (6,6), (6,38), (38,6) are occupied by finder patterns
* and are not therefore used for alignment patterns.
*
* let pos = getPositions(7)
* // [[6,22], [22,6], [22,22], [22,38], [38,22], [38,38]]
*
* @param {Number} version QR Code version
* @return {Array} Array of coordinates
*/

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current diff removes useful docstrings. These should remain even in the ESM version.

Comment on lines -13 to -26
/**
* Calculate the row/column coordinates of the center module of each alignment pattern
* for the specified QR Code version.
*
* The alignment patterns are positioned symmetrically on either side of the diagonal
* running from the top left corner of the symbol to the bottom right corner.
*
* Since positions are simmetrical only half of the coordinates are returned.
* Each item of the array will represent in turn the x and y coordinate.
* @see {@link getPositions}
*
* @param {Number} version QR Code version
* @return {Array} Array of coordinate
*/

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current diff removes useful docstrings. These should remain even in the ESM version.

Comment on lines -92 to -98
* Returns the number of error correction block that the QR Code should contain
* for the specified version and error correction level.
*
* @param {Number} version QR Code version
* @param {Number} errorCorrectionLevel Error correction level
* @return {Number} Number of error correction blocks
*/

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current diff removes useful docstrings. These should remain even in the ESM version.

Comment on lines -114 to -121
/**
* Returns the number of error correction codewords to use for the specified
* version and error correction level.
*
* @param {Number} version QR Code version
* @param {Number} errorCorrectionLevel Error correction level
* @return {Number} Number of error correction codewords
*/

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current diff removes useful docstrings. These should remain even in the ESM version.

Comment on lines -3 to -10

/**
* Returns an array containing the positions of each finder pattern.
* Each array's element represent the top-left point of the pattern as (x, y) coordinates
*
* @param {Number} version QR Code version
* @return {Array} Array of coordinates
*/

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current diff removes useful docstrings. These should remain even in the ESM version.

Comment on lines -3 to -10
/**
* Precompute the log and anti-log tables for faster computation later
*
* For each possible value in the galois field 2^8, we will pre-compute
* the logarithm and anti-logarithm (exponential) of this value
*
* ref {@link https://en.wikiversity.org/wiki/Reed%E2%80%93Solomon_codes_for_coders#Introduction_to_mathematical_fields}
*/

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current diff removes useful docstrings. These should remain even in the ESM version.

Comment on lines -34 to -40

/**
* Returns log value of n inside Galois Field
*
* @param {Number} n
* @return {Number}
*/

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current diff removes useful docstrings. These should remain even in the ESM version.

Comment on lines -45 to -52

/**
* Returns anti-log value of n inside Galois Field
*
* @param {Number} n
* @return {Number}
*/
exports.exp = function exp (n) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current diff removes useful docstrings. These should remain even in the ESM version.

Comment on lines -55 to -63

/**
* Multiplies two number inside Galois Field
*
* @param {Number} x
* @param {Number} y
* @return {Number}
*/
exports.mul = function mul (x, y) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current diff removes useful docstrings. These should remain even in the ESM version.

Comment on lines -1 to -5
/**
* Data mask pattern reference
* @type {Object}
*/
exports.Patterns = {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current diff removes useful docstrings. These should remain even in the ESM version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants