Skip to content

Commit

Permalink
chore: improve JSDoc comments
Browse files Browse the repository at this point in the history
  • Loading branch information
kravetsone committed May 11, 2024
1 parent 86a3a39 commit d6c6618
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@gramio/files",
"main": "./dist/index.js",
"version": "0.0.7",
"version": "0.0.8",
"type": "commonjs",
"description": "Set of utils for work with files and Telegram Bot API",
"keywords": [
Expand Down
6 changes: 5 additions & 1 deletion scripts/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,11 @@ fs.writeFile(
return file instanceof File || file instanceof Promise;
}
/** @codegenerated */
/**
* A set of methods with the function of checking whether a file has been passed in the parameters
*
* @codegenerated
* */
export const MEDIA_METHODS: MethodsWithMediaUpload = {${Object.entries(
methods,
)
Expand Down
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
*
* Set of utils for work with files and Telegram Bot API
*
* [Documentation](https://gramio.netlify.app/files/overview.html)
*
* @example
* ```typescript
* import { MediaInput, MediaUpload } from "@gramio/files";
Expand Down
6 changes: 5 additions & 1 deletion src/media-input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ import type {
TelegramInputMediaVideo,
} from "@gramio/types";

/** Class-helper with static methods that represents the content of a media message to be sent. */
/**
* Class-helper with static methods that represents the content of a media message to be sent.
*
* [Documentation](https://gramio.netlify.app/files/media-input.html)
*/
export class MediaInput {
/**
* Represents an animation file (GIF or H.264/MPEG-4 AVC video without sound) to be sent.
Expand Down
8 changes: 6 additions & 2 deletions src/media-methods-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,18 @@ type MethodsWithMediaUpload = {
];
};

/** Guard for check is it File or Promise */
/** Guard for check is it {@link File} or {@link Promise} */
export function isFile(file?: TelegramInputFile | object | string) {
if (!file || typeof file !== "object") return false;

return file instanceof File || file instanceof Promise;
}

/** @codegenerated */
/**
* A set of methods with the function of checking whether a {@link File} has been passed in the parameters
*
* @codegenerated
* */
export const MEDIA_METHODS: MethodsWithMediaUpload = {
setWebhook: [(params) => isFile(params.certificate), null],
sendPhoto: [(params) => isFile(params.photo), null],
Expand Down
6 changes: 5 additions & 1 deletion src/media-upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ import { basename } from "node:path";
import type { Readable } from "node:stream";
import { convertStreamToBuffer } from "./utils";

/** Class-helper with static methods for file uploading. */
/**
* Class-helper with static methods for file uploading.
*
* [Documentation](https://gramio.netlify.app/files/media-upload.html)
*/
export class MediaUpload {
/**
* Method for uploading Media File by local path.
Expand Down

0 comments on commit d6c6618

Please sign in to comment.