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
import { spawn } from "node:child_process"; | |
import type { Readable } from "node:stream"; | |
export interface ImageResizeOptions { | |
quality?: number; | |
square?: boolean; | |
} | |
const CONVERT_ERR_MATCH_REGEX = /convert:\s(.+)\s`/gm; |
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
/** | |
* Enrich source stream items with some data | |
* | |
* @param pick Function that transform source item to pass result to enrichment transform | |
* @param enrichmentData Enrichment transformation, which returns the data stream with which the original stream will be enriched | |
* @param compose Function that enrich source item with enrichment data | |
* @type {EnrichTransform} | |
*/ | |
export const enrichTransform = (pick, enrichmentData, compose) => (source$) => { | |
return source$ |
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
import { PutObjectCommand, S3Client } from "@aws-sdk/client-s3"; | |
import mime from "mime-types"; | |
import querystring from "node:querystring"; | |
import { env } from "../env.js"; | |
/* | |
{ | |
"BUCKET_ENDPOINT": "https://storage.yandexcloud.net", | |
"BUCKET_REGION": "ru-central1", | |
"BUCKET_NAME": "my-bucket", |
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
namespace $ { | |
/** Элемент очереди на массовую загрузку */ | |
type Queue_item = { | |
id: string | |
resolve: ( value: unknown ) => void | |
reject: ( reason?: any ) => void | |
signal: AbortSignal | |
} |
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
// prettier-ignore | |
export class $my_model extends $mol_object { | |
static type() { | |
return '' | |
} | |
@$mol_mem_key | |
static item( id: string ) { |
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
import * as url from "node:url"; | |
/** | |
* Returns `__dirname` like value for ESM | |
* | |
* ```js | |
* const dirname = getDirname(import.meta.url) | |
* ``` | |
* @link https://blog.logrocket.com/alternatives-dirname-node-js-es-modules/ | |
* @param {string} fileUrl |
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
{ | |
"typescript.tsdk": "node_modules/typescript/lib", | |
"files.watcherExclude": { | |
"**/node_modules": true, | |
"**/-*": false | |
}, | |
"search.exclude": { | |
"**/node_modules": true, | |
"**/-*": true | |
}, |
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
(() => { | |
// 1. Скопировать этот код на страницу https://caiorss.github.io/bookmarklet-maker/ | |
// 2. Заполнить название закладки | |
// 3. Сюда добвить ID вашей функции в Yandex.Cloud | |
const FUNCTION_ID = "qwertyyuio1234567890"; | |
// 4. Тут указать название закладки с фильтром в разделе "Заказы покупателей" | |
const FILTER_NAME = "Все"; |
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
/** @type {TypedEntries} */ | |
export function typedEntries(obj) { | |
// @ts-expect-error ignore | |
return Object.entries(obj); | |
} | |
/** @type {TypedFromEntries} */ | |
export function typedFromEntries(entries) { | |
return Object.fromEntries(entries); | |
} |
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
// gist: https://gist.github.com/wmakeev/ede27b97b3d227258684c5e80bf7fca3 | |
import { PDFDocument } from "pdf-lib"; | |
/** | |
* Merges pdf files in one (with pdf-lib) | |
* | |
* @see https://stackoverflow.com/a/68482188 | |
* | |
* @param {ArrayBuffer[]} pdfsToMerge |