Created
December 3, 2019 10:19
-
-
Save zorgick/c39f3d9b54defde51e2d46822d5c4658 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* MyNewType definition | |
* @typedef {MyNewType} MyNewType | |
* @param {number} first | |
* @param {number} second | |
* @property {function} logFirst | |
* @property {function} logSecond | |
* @returns MyNewType | |
*/ | |
var MyNewType = module.exports = (first, second) => { | |
/** | |
* logs first argument | |
* @typedef {number} logFirst | |
* @param {number} times | |
*/ | |
function logFirst(times) { | |
for (let i = 0; i < times; i++) { | |
console.log(first); | |
} | |
} | |
/** | |
* logs second argument | |
* @param {number} times | |
*/ | |
function logSecond(times) { | |
for (let i = 0; i < times; i++) { | |
console.log(second); | |
} | |
} | |
return { | |
logFirst, | |
logSecond | |
}; | |
}; | |
/** | |
* @callback LoadingCallback | |
* @param {number} status | |
* @param {string=} response | |
* @returns {void} | |
*/ | |
/** | |
* @param {string} url | |
* @param {LoadingCallback} cb | |
*/ | |
function loadData(url, cb) { | |
const xhr = new XMLHttpRequest(); | |
xhr.open('GET', url) | |
xhr.onload = () => { | |
cb(xhr.status, xhr.responseText) | |
} | |
} | |
/** | |
* @typedef {object} BrowserHistory | |
* @property {(route: string) => void} push | |
*/ | |
/** | |
* @param {BrowserHistory} history | |
* @returns {(route: string) => void} | |
*/ | |
const push = history => route => history.push(route); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment