From 921457c529e9b915a48eea5b32211d2df2f5af21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20LES=C3=89N=C3=89CHAL?= Date: Fri, 8 Mar 2024 18:54:26 +0100 Subject: [PATCH] Add types for `mediawiki.deflate` adapted from https://github.com/wikimedia-gadgets/types-mediawiki/issues/32 --- mw/deflate.d.ts | 22 ++++++++++++++++++++++ mw/index.d.ts | 1 + 2 files changed, 23 insertions(+) create mode 100644 mw/deflate.d.ts diff --git a/mw/deflate.d.ts b/mw/deflate.d.ts new file mode 100644 index 0000000..5be4a4a --- /dev/null +++ b/mw/deflate.d.ts @@ -0,0 +1,22 @@ +declare global { + namespace mw { + /** + * Compress the content and add the 'rawdeflate,' prefix. + * + * @example + * ```js + * mw.loader.using( 'mediawiki.deflate' ).then( function () { + * var deflated = mw.deflate( myContent ); + * } ); + * ``` + * + * @param {string|ArrayBuffer} data Undeflated data + * @returns {string} Deflated data + * @see https://github.com/wikimedia/mediawiki/blob/master/resources/src/mediawiki.deflate/mw.deflate.js#L3 + * @see https://doc.wikimedia.org/mediawiki-core/master/php/classDeflate.html + */ + function deflate(data: string | ArrayBuffer): `rawdeflate,${string}`; + } +} + +export {}; diff --git a/mw/index.d.ts b/mw/index.d.ts index e5ff165..d90d606 100644 --- a/mw/index.d.ts +++ b/mw/index.d.ts @@ -3,6 +3,7 @@ import "./config"; import "./confirmCloseWindow"; import "./cookie"; import "./debug"; +import "./deflate"; import "./ForeignApi"; import "./ForeignRest"; import "./global";