Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@
// the @ts-check directive. It will give you helpful autocompletion when
// implementing this exercise.

/**
* @typedef {function (number, number): [number, number]} CallbackType
*/

/**
* Create a function that returns a function making use of a closure to
* perform a repeatable 2d translation of a coordinate pair.
*
* @param {number} dx the translate x component
* @param {number} dy the translate y component
*
* @returns {function} a function which takes an x, y parameter, returns the
* @returns {CallbackType} a function which takes an x, y parameter, returns the
* translated coordinate pair in the form [x, y]
*/
export function translate2d(dx, dy) {
Expand All @@ -25,7 +29,7 @@ export function translate2d(dx, dy) {
* @param {number} sx the amount to scale the x component
* @param {number} sy the amount to scale the y component
*
* @returns {function} a function which takes an x, y parameter, returns the
* @returns {CallbackType} a function which takes an x, y parameter, returns the
* scaled coordinate pair in the form [x, y]
*/
export function scale2d(sx, sy) {
Expand All @@ -39,7 +43,7 @@ export function scale2d(sx, sy) {
* @param {function} f the first function to apply
* @param {function} g the second function to apply
Comment thread
joyalgeorgekj marked this conversation as resolved.
Outdated
*
* @returns {function} a function which takes an x, y parameter, returns the
* @returns {CallbackType} a function which takes an x, y parameter, returns the
* transformed coordinate pair in the form [x, y]
*/
export function composeTransform(f, g) {
Expand All @@ -52,7 +56,7 @@ export function composeTransform(f, g) {
*
* @param {function} f the transformation function to memoize, assumes takes two arguments 'x' and 'y'
Comment thread
joyalgeorgekj marked this conversation as resolved.
Outdated
*
* @returns {function} a function which takes x and y arguments, and will either return the saved result
* @returns {CallbackType} a function which takes x and y arguments, and will either return the saved result
* if the arguments are the same on subsequent calls, or compute a new result if they are different.
*/
export function memoizeTransform(f) {
Expand Down
Loading