From 374bbd8292f6ea13b7f08dd68aa942bc0c0b633b Mon Sep 17 00:00:00 2001 From: TimeForANinja Date: Tue, 4 May 2021 15:06:33 +0200 Subject: [PATCH] feat: expose version (#832) * expose version * add to typings --- README.md | 4 ++++ lib/index.js | 1 + typings/index.d.ts | 1 + 3 files changed, 6 insertions(+) diff --git a/README.md b/README.md index 9861ed29..e69bd130 100644 --- a/README.md +++ b/README.md @@ -140,6 +140,10 @@ Throws an Error if it fails to parse an ID. Same as the above `ytdl.getURLVideoID()`, but can be called with the video ID directly, in which case it returns it. This is what ytdl uses internally. Throws an Error if it fails to parse an ID. +### ytdl.version + +The version string taken directly from the package.json. + ## Limitations ytdl cannot download videos that fall into the following diff --git a/lib/index.js b/lib/index.js index a573d78e..0cfbe5ba 100644 --- a/lib/index.js +++ b/lib/index.js @@ -37,6 +37,7 @@ ytdl.cache = { watch: getInfo.watchPageCache, cookie: getInfo.cookieCache, }; +ytdl.version = require('../package.json').version; const createStream = options => { diff --git a/typings/index.d.ts b/typings/index.d.ts index f538f7ae..abb4123d 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -406,6 +406,7 @@ declare module 'ytdl-core' { function validateURL(string: string): boolean; function getURLVideoID(string: string): string | never; function getVideoID(string: string): string | never; + const version: number; } function ytdl(link: string, options?: ytdl.downloadOptions): Readable;