-
-
Save alexkonst/d8b56932f3e7a81aaaed8e6a8814575e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/** | |
* @name Parameters | |
* @type {object} | |
* @property {Record<string, string>} [headers] - Request headers | |
* @property {string|JSON|ArrayBuffer} [body] - Request body | |
* @property {"json"|"text"|"document"|"buffer"} [contentType] - Content type | |
*/ | |
/** | |
* @name ResponseObject | |
* @type {object} | |
* @property {JSON} [json] | |
* @property {string} [text] | |
* @property {string} [document] | |
* @property {ArrayBuffer} [buffer] | |
*/ | |
const myToken = '' | |
/** | |
* @type {Parameters} | |
*/ | |
const defaultConfig = { | |
headers: {Authorization: myToken} | |
} | |
/** | |
* @param {string} url | |
* @param {Parameters} params | |
* @returns {Promise<ResponseObject>} | |
*/ | |
function post(url, params) {} | |
/** | |
* @param {string} url | |
* @param {Parameters} params | |
* @returns {Promise<ResponseObject>} | |
*/ | |
function put(url, params) {} | |
// ============================ | |
/** | |
* @description Вычисляет сумму a и b для числовых значений, выполняет конкатенацию для строковых значений | |
* @template {number|bigint|string} T | |
* @param {T} a | |
* @param {T} b | |
* @returns {T} | |
* | |
* @example | |
* sum(1, 2) === 3 | |
* | |
* @example | |
* sum('1', '2') === '12' | |
*/ | |
function sum(a, b) { | |
return a + b | |
} | |
// ============================ | |
/** | |
* @class MathOperations | |
*/ | |
class MathOperations { | |
/** | |
* Умножает два числа | |
* | |
* @param {number} a | |
* @param {number} b | |
* @returns {number} | |
* | |
* @see {@link MathOperations.divide} См метод divide для деления. | |
* @see {@link MathOperations.square} См статический метод square для возведения в квадрат. | |
*/ | |
multiply(a, b) { | |
return a * b; | |
} | |
/** | |
* Делит два числа | |
* @param {number} a | |
* @param {number} b | |
* @returns {number} | |
* | |
*/ | |
divide(a, b) { | |
return a / b; | |
} | |
/** | |
* Возводит в квадрат число | |
* @param {number} x | |
* @returns {number} | |
* | |
* @see {@link MathOperations.multiply} См метод multiply для умножения. | |
*/ | |
static square(x) { | |
return x * x; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment