mirror of
https://github.com/shaka-project/shaka-player.git
synced 2026-06-25 17:45:03 +03:00
562a2d567b
This enables the eslint rule requiring jsdocs on all class
declarations, function declarations, and methods.
Unfortunately, there are two problems with this:
1. We don't use class _declarations_, we use class _expressions_,
which are not covered by this rule. So it does not enforce jsdoc at
the class level.
2. We tend to document a class at the class-level, rather than at the
constructor. But a constructor counts as a method for eslint, so it
requires docs on the constructor. There is no way to configure it to
make an exception for trivial constructors.
So for all trivial (no-argument) constructors, we add empty jsdocs:
/** */
constructor() {
This was quicker and easier than setting up some alternative plugin in
eslint to make an exception for us.
The good news is that this rule caught several undocumented parameters
and places where the jsdoc comment was malformed. So fixing those
also improves the compiler's ability to enforce types.
Change-Id: Icbc46ed690c94e53d354648a883119524f8fca45
36 lines
988 B
JavaScript
Executable File
36 lines
988 B
JavaScript
Executable File
#!/usr/bin/env node
|
|
/*! @license
|
|
* Shaka Player
|
|
* Copyright 2016 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
/**
|
|
* @fileoverview
|
|
*
|
|
* A node script that uses the Jimp module to compute the number of changed
|
|
* pixels between two images.
|
|
*/
|
|
|
|
const Jimp = require('jimp');
|
|
|
|
/**
|
|
* Compare two images and output the number of changed pixels. Uses the same
|
|
* node module as the comparisons done in the tests through Karma.
|
|
*
|
|
* @param {string} oldPath
|
|
* @param {string} newPath
|
|
*/
|
|
async function main(oldPath, newPath) {
|
|
const oldImage = await Jimp.read(oldPath);
|
|
const newImage = await Jimp.read(newPath);
|
|
const diff = Jimp.diff(oldImage, newImage, /* threshold= */ 0);
|
|
// "percent" is, surprisingly, a number between 0 and 1, not between 0 and
|
|
// 100. Convert this to a number of pixels.
|
|
const pixelsChanged =
|
|
diff.percent * diff.image.bitmap.width * diff.image.bitmap.height;
|
|
console.log(pixelsChanged);
|
|
}
|
|
|
|
main(process.argv[2], process.argv[3]);
|