Skip to content

Commit 5e92916

Browse files
Update JSDoc to use CallbackType for return types
1 parent ddc7358 commit 5e92916

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

exercises/concept/coordinate-transformation/coordinate-transformation.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,18 @@
44
// the @ts-check directive. It will give you helpful autocompletion when
55
// implementing this exercise.
66

7+
/**
8+
* @typedef {function (number, number): [number, number]} CallbackType
9+
*/
10+
711
/**
812
* Create a function that returns a function making use of a closure to
913
* perform a repeatable 2d translation of a coordinate pair.
1014
*
1115
* @param {number} dx the translate x component
1216
* @param {number} dy the translate y component
1317
*
14-
* @returns {function} a function which takes an x, y parameter, returns the
18+
* @returns {CallbackType} a function which takes an x, y parameter, returns the
1519
* translated coordinate pair in the form [x, y]
1620
*/
1721
export function translate2d(dx, dy) {
@@ -25,7 +29,7 @@ export function translate2d(dx, dy) {
2529
* @param {number} sx the amount to scale the x component
2630
* @param {number} sy the amount to scale the y component
2731
*
28-
* @returns {function} a function which takes an x, y parameter, returns the
32+
* @returns {CallbackType} a function which takes an x, y parameter, returns the
2933
* scaled coordinate pair in the form [x, y]
3034
*/
3135
export function scale2d(sx, sy) {
@@ -39,7 +43,7 @@ export function scale2d(sx, sy) {
3943
* @param {function} f the first function to apply
4044
* @param {function} g the second function to apply
4145
*
42-
* @returns {function} a function which takes an x, y parameter, returns the
46+
* @returns {CallbackType} a function which takes an x, y parameter, returns the
4347
* transformed coordinate pair in the form [x, y]
4448
*/
4549
export function composeTransform(f, g) {
@@ -52,7 +56,7 @@ export function composeTransform(f, g) {
5256
*
5357
* @param {function} f the transformation function to memoize, assumes takes two arguments 'x' and 'y'
5458
*
55-
* @returns {function} a function which takes x and y arguments, and will either return the saved result
59+
* @returns {CallbackType} a function which takes x and y arguments, and will either return the saved result
5660
* if the arguments are the same on subsequent calls, or compute a new result if they are different.
5761
*/
5862
export function memoizeTransform(f) {

0 commit comments

Comments
 (0)