{"id":13550317,"url":"https://github.com/mkloubert/vscode-helpers","last_synced_at":"2025-04-28T10:50:50.765Z","repository":{"id":30539994,"uuid":"124478659","full_name":"mkloubert/vscode-helpers","owner":"mkloubert","description":"Helper functions and classes for Visual Studio Code extensions.","archived":false,"fork":false,"pushed_at":"2024-09-01T09:26:46.000Z","size":761,"stargazers_count":59,"open_issues_count":5,"forks_count":8,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-26T23:18:20.565Z","etag":null,"topics":["classes","ecmascript","extensions","functions","helpers","javascript","modules","nodejs","npm","toolbox","tools","typescript","vscode"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/vscode-helpers","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mkloubert.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null},"funding":{"custom":["https://paypal.me/MarcelKloubert"]}},"created_at":"2018-03-09T02:51:20.000Z","updated_at":"2025-03-27T10:08:01.000Z","dependencies_parsed_at":"2024-01-08T08:02:06.407Z","dependency_job_id":"3c1b3e96-663b-44ef-bfe1-b09c69575f98","html_url":"https://github.com/mkloubert/vscode-helpers","commit_stats":{"total_commits":110,"total_committers":2,"mean_commits":55.0,"dds":"0.018181818181818188","last_synced_commit":"0979927df94100f5a99762fd07eddf1f942fab9e"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkloubert%2Fvscode-helpers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkloubert%2Fvscode-helpers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkloubert%2Fvscode-helpers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkloubert%2Fvscode-helpers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mkloubert","download_url":"https://codeload.github.com/mkloubert/vscode-helpers/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251299884,"owners_count":21567326,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["classes","ecmascript","extensions","functions","helpers","javascript","modules","nodejs","npm","toolbox","tools","typescript","vscode"],"created_at":"2024-08-01T12:01:31.537Z","updated_at":"2025-04-28T10:50:50.741Z","avatar_url":"https://github.com/mkloubert.png","language":"TypeScript","funding_links":["https://paypal.me/MarcelKloubert"],"categories":["TypeScript"],"sub_categories":[],"readme":"[![npm](https://img.shields.io/npm/v/vscode-helpers.svg)](https://www.npmjs.com/package/vscode-helpers)\r\n[![npm](https://img.shields.io/npm/dt/vscode-helpers.svg?label=npm%20downloads)](https://www.npmjs.com/package/vscode-helpers)\r\n\r\n# vscode-helpers\r\n\r\nHelper functions and classes for [Visual Studio Code extensions](https://code.visualstudio.com/docs/extensions/overview).\r\n\r\n## Table of contents\r\n\r\n1. [Install](#install-)\r\n2. [Usage](#usage-)\r\n3. [Examples](#examples-)\r\n   * [Functions](#functions-)\r\n     * [applyFuncFor](#applyfuncfor-)\r\n     * [asArray](#asarray-)\r\n     * [asBuffer](#asbuffer-)\r\n     * [asLocalTime](#aslocaltime-)\r\n     * [asUTC](#asutc-)\r\n     * [buildWorkflow](#buildworkflow-)\r\n     * [cloneObject](#cloneobject-)\r\n     * [cloneObjectFlat](#cloneobjectflat-)\r\n     * [compareValues](#comparevalues-)\r\n     * [compareValuesBy](#comparevaluesby-)\r\n     * [createChromeClient](#createchromeclient-)\r\n     * [createCompletedAction](#createcompletedaction-)\r\n     * [createDevToolsClient](#createdevtoolsclient-)\r\n     * [createDirectoryIfNeeded](#createdirectoryifneeded-)\r\n     * [createGitClient](#creategitclient-)\r\n     * [createGitClientSync](#creategitclientsync-)\r\n     * [createInterval](#createinterval-)\r\n     * [createLogger](#createlogger-)\r\n     * [createQueue](#createqueue-)\r\n     * [createTimeout](#createtimeout-)\r\n     * [DELETE](#delete-)\r\n     * [doesMatch](#doesmatch-)\r\n     * [execFile](#execfile-)\r\n     * [exists](#exists-)\r\n     * [fastGlob](#fastglob-)\r\n     * [fastGlobSync](#fastglobsync-)\r\n     * [filterExtensionNotifications](#filterextensionnotifications-)\r\n     * [forEachAsync](#foreachasync-)\r\n     * [format](#format-)\r\n     * [formatArray](#formatarray-)\r\n     * [from](#from-)\r\n     * [fromMarkdown](#frommarkdown-)\r\n     * [GET](#get-)\r\n     * [getExtensionNotifications](#getextensionnotifications-)\r\n     * [getExtensionRoot](#getextensionroot-)\r\n     * [getPackageFile](#getpackagefile-)\r\n     * [getPackageFileSync](#getpackagefilesync-)\r\n     * [glob](#glob-)\r\n     * [globSync](#globsync-)\r\n     * [guid](#guid-)\r\n     * [invokeAfter](#invokeafter-)\r\n     * [isBinaryContent](#isbinarycontent-)\r\n     * [isBinaryContentSync](#isbinarycontentsync-)\r\n     * [isBlockDevice](#isblockdevice-)\r\n     * [isBlockDeviceSync](#isblockdevicesync-)\r\n     * [isCharacterDevice](#ischaracterdevice-)\r\n     * [isCharacterDeviceSync](#ischaracterdevicesync-)\r\n     * [isDirectory](#isdirectory-)\r\n     * [isDirectorySync](#isdirectorysync-)\r\n     * [isEmptyString](#isemptystring-)\r\n     * [isFIFO](#isfifo-)\r\n     * [isFIFOSync](#isfifosync-)\r\n     * [isFile](#isfile-)\r\n     * [isFileSync](#isfilesync-)\r\n     * [isSocket](#issocket-)\r\n     * [isSocketSync](#issocketsync-)\r\n     * [isSymbolicLink](#issymboliclink-)\r\n     * [isSymbolicLinkSync](#issymboliclinksync-)\r\n     * [loadModule](#loadmodule-)\r\n     * [makeNonDisposable](#makenondisposable-)\r\n     * [normalizeString](#normalizestring-)\r\n     * [now](#now-)\r\n     * [openAndShowTextDocument](#openandshowtextdocument-)\r\n     * [PATCH](#patch-)\r\n     * [POST](#post-)\r\n     * [PUT](#put-)\r\n     * [randomBytes](#randombytes-)\r\n     * [range](#range-)\r\n     * [registerWorkspaceWatcher](#registerworkspacewatcher-)\r\n     * [readAll](#readall-)\r\n     * [repeat](#repeat-)\r\n     * [request](#request-)\r\n     * [setExtensionRoot](#setextensionroot-)\r\n     * [size](#size-)\r\n     * [sizeSync](#sizeSync-)\r\n     * [sleep](#sleep-)\r\n     * [startWatch](#startwatch-)\r\n     * [tempFile](#tempfile-)\r\n     * [tempFileSync](#tempfilesync-)\r\n     * [toArray](#toarray-)\r\n     * [toBooleanSafe](#tobooleansafe-)\r\n     * [toEOL](#toeol-)\r\n     * [toStringSafe](#tostringsafe-)\r\n     * [tryClearInterval](#tryclearinterval-)\r\n     * [tryClearTimeout](#trycleartimeout-)\r\n     * [tryDispose](#trydispose-)\r\n     * [tryDisposeAndDelete](#trydisposeanddelete-)\r\n     * [tryCreateGitClient](#trycreategitclient-)\r\n     * [tryCreateGitClientSync](#trycreategitclientsync-)\r\n     * [tryRemoveAllListeners](#tryremovealllisteners-)\r\n     * [tryRemoveListener](#tryremovelistener-)\r\n     * [using](#using-)\r\n     * [usingSync](#usingsync-)\r\n     * [utcNow](#utcnow-)\r\n     * [uuid](#uuid-)\r\n     * [waitWhile](#waitwhile-)\r\n     * [withProgress](#withprogress-)\r\n   * [Classes](#classes-)\r\n     * [CacheProviderBase](#cacheproviderbase-)\r\n     * [DisposableBase](#disposablebase-)\r\n     * [MemoryCache](#memorycache-)\r\n     * [StopWatch](#stopwatch-)\r\n     * [WorkspaceBase](#workspacebase-)\r\n   * [Constants and variables](#constants-and-variables-)\r\n     * [EVENTS](#events-)\r\n     * [IS_*](#is_-)\r\n     * [QUEUE](#queue-)\r\n     * [SESSION](#session-)\r\n4. [Branches](#branches-)     \r\n5. [Support and contribute](#support-and-contribute-)\r\n6. [Documentation](#documentation-)\r\n\r\n## Install [[\u0026uarr;](#table-of-contents)]\r\n\r\nFrom your project, run the following command:\r\n\r\n```bash\r\nnpm install --save vscode-helpers\r\n```\r\n\r\n## Usage [[\u0026uarr;](#table-of-contents)]\r\n\r\n```typescript\r\n// plain JavaScript\r\nconst vscode_helpers = require('vscode-helpers');\r\n\r\n// the TypeScript way\r\nimport * as vscode_helpers from 'vscode-helpers';\r\n```\r\n\r\n## Examples [[\u0026uarr;](#table-of-contents)]\r\n\r\nAn example of a [multi-root workspace](https://code.visualstudio.com/docs/editor/multi-root-workspaces) ready extension (`extension.ts`):\r\n\r\n```typescript\r\n'use strict';\r\n\r\nimport * as Path from 'path';\r\nimport * as vscode from 'vscode';\r\nimport * as vscode_helpers from 'vscode-helpers';\r\n\r\nclass MyWorkspace extends vscode_helpers.WorkspaceBase {\r\n    private _configSrc: vscode_helpers.WorkspaceConfigSource;\r\n\r\n    // this is important for 'onDidChangeConfiguration' (s. below)\r\n    public get configSource() {\r\n        return this._configSrc;\r\n    }    \r\n\r\n    public async initialize() {\r\n        // initialize your workspace here\r\n\r\n        this._configSrc = {\r\n            section: 'my.extension',\r\n            resource: Uri.file( Path.join(this.rootPath,\r\n                                          '.vscode/settings.json') ),\r\n        };\r\n    }\r\n\r\n    public async onDidChangeConfiguration(e) {\r\n        const NEW_CONFIG = vscode.workspace.getConfiguration(\r\n            this.configSource.section,\r\n            this.configSource.resource\r\n        );\r\n\r\n        // handle new config here\r\n    }\r\n}\r\n\r\nlet workspaceWatcher: vscode_helpers.WorkspaceWatcherContext\u003cMyWorkspace\u003e;\r\n\r\nexport async function activate(context: vscode.ExtensionContext) {\r\n    context.subscriptions.push(\r\n        workspaceWatcher = \r\n            vscode_helpers.registerWorkspaceWatcher\u003cMyWorkspace\u003e(context, async (ev, folder) =\u003e {\r\n                if (ev === vscode_helpers.WorkspaceWatcherEvent.Added) {\r\n                    const NEW_WORKSPACE = new MyWorkspace(folder);\r\n\r\n                    await NEW_WORKSPACE.initialize();\r\n\r\n                    return NEW_WORKSPACE;\r\n                }            \r\n            }),\r\n    );\r\n\r\n    await workspaceWatcher.reload();\r\n}\r\n\r\nexport async function deactivate() {\r\n    //TODO\r\n}\r\n```\r\n\r\n### Functions [[\u0026uarr;](#examples-)]\r\n\r\n#### applyFuncFor [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nconst OBJ = { factor: 1000 };\r\n\r\nfunction myTestFunc(a, b) {\r\n    return (a + b) * this.factor;\r\n}\r\n\r\nconst APPLIED_FUNC = vscode_helpers.applyFuncFor(\r\n    myTestFunc, OBJ\r\n);\r\n\r\nAPPLIED_FUNC(5979, 23979);  // 29958000\r\n```\r\n\r\n#### asArray [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nconst ARR_1 = vscode_helpers.asArray([ 0, 1, null, 3, 4, undefined ]);  // [ 0, 1, 3, 4 ]\r\nconst ARR_2 = vscode_helpers.asArray([ 0, 1, null, 3, 4, undefined ], false);  // [ 0, 1, null, 3, 4, undefined ]\r\nconst ARR_3 = vscode_helpers.asArray( 5979 );  // [ 5979 ]\r\nconst ARR_4 = vscode_helpers.asArray( null );  // [ ]\r\n```\r\n\r\n#### asBuffer [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nimport * as fs from 'fs';\r\n\r\nconst STREAM = fs.createReadStream('./my-file.txt');\r\n\r\nasBuffer( STREAM ).then((data: Buffer) =\u003e {\r\n    // all data read\r\n}, (err) =\u003e {\r\n    // error\r\n});\r\n```\r\n\r\n#### asLocalTime [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nimport * as Moment from 'moment';\r\n\r\nlet utcNow = Moment.utc();\r\nlet localNow = vscode_helpers.asLocalTime( utcNow );  // can also be a string\r\n                                                      // or Date object\r\n```\r\n\r\n#### asUTC [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nimport * as Moment from 'moment';\r\n\r\nlet localNow = Moment();\r\nlet utcNow = vscode_helpers.asUTC( localNow );  // can also be a string\r\n                                                // or Date object\r\n```\r\n\r\n#### buildWorkflow [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nconst WORKFLOW = vscode_helpers.buildWorkflow()\r\n    .next((prevValue: undefined, context: vscode_helpers.WorkflowActionContext) =\u003e {\r\n              context.value = 1000;\r\n\r\n              return 5979;\r\n          })\r\n    .next((prevValue: number, context: vscode_helpers.WorkflowActionContext) =\u003e {\r\n              return prevValue + 23979;  // prevValue === 5979\r\n          })\r\n    .next((prevValue: number, context: vscode_helpers.WorkflowActionContext) =\u003e {\r\n              // prevValue === 29958\r\n              // context.value === 1000\r\n              return '' + (prevValue * context.value);\r\n          });\r\n\r\nWORKFLOW.start().then((result: string) =\u003e {\r\n    // result === '29958000'\r\n}, (err) =\u003e {\r\n    // this only happens on error\r\n});\r\n```\r\n\r\n#### cloneObject [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nconst CLONED_OBJ = vscode_helpers.cloneObject({\r\n    mk: 23979,\r\n    tm: 5979,\r\n});\r\n```\r\n\r\n#### cloneObjectFlat [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nconst CLONED_OBJ = vscode_helpers.cloneObjectFlat({\r\n    mk: 23979,\r\n    tm: function(a) {\r\n        return a * (5979 * this.mk);\r\n    },\r\n});\r\n\r\nCLONED_OBJ.mk = 1000;\r\nCLONED_OBJ.tm(2000);  // 11.958.000.000 === 2000 * (5979 * 1000)\r\n```\r\n\r\n#### compareValues [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nconst VAL_1 = 1;\r\nconst VAL_2 = 2;\r\n\r\n// SORTED_VALUES[0] === VAL_2\r\n// SORTED_VALUES[1] === VAL_1\r\nconst SORTED_VALUES = [ VAL_1, VAL_2 ].sort((x, y) =\u003e {\r\n    return vscode_helpers.compareValues(y, x);\r\n});\r\n```\r\n\r\n#### compareValuesBy [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nconst OBJ_1 = { sortValue: 1 };\r\nconst OBJ_2 = { sortValue: 2 };\r\n\r\n// SORTED_OBJS[0] === OBJ_2\r\n// SORTED_OBJS[1] === OBJ_1\r\nconst SORTED_OBJS = [ OBJ_1, OBJ_2 ].sort((x, y) =\u003e {\r\n    return vscode_helpers.compareValuesBy(y, x,\r\n                                          i =\u003e i.sortValue);\r\n});\r\n```\r\n\r\n#### createChromeClient [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nconst CLIENT = vscode_helpers.createChromeClient({\r\n    host: 'localhost',\r\n    port: 9222,\r\n});\r\n\r\nconst PAGES = await CLIENT.getPages();\r\nfor (const P of PAGES) {\r\n    //TODO\r\n}\r\n```\r\n\r\n#### createCompletedAction [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nimport * as fs from 'fs';\r\n\r\nfunction loadMyFileAsync() {\r\n    return new Promise\u003cBuffer\u003e(async (resolve, reject) =\u003e {\r\n        const COMPLETED = vscode_helpers.createCompletedAction(resolve, reject);\r\n\r\n        fs.readFile('./MyFile.txt', (err: NodeJS.ErrnoException, data: Buffer) =\u003e {\r\n            COMPLETED(err, data);\r\n        });\r\n    });\r\n}\r\n```\r\n\r\n#### createDevToolsClient [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nconst CLIENT = vscode_helpers.createDevToolsClient({\r\n    host: 'localhost',\r\n    port: 9222,\r\n});\r\n\r\nconst PAGES = await CLIENT.getPages();\r\nfor (const P of PAGES) {\r\n    //TODO\r\n}\r\n```\r\n\r\n#### createDirectoryIfNeeded [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nvscode_helpers.createDirectoryIfNeeded('/dir/to/create').then((hasBeenCreated: boolean) =\u003e {\r\n    // hasBeenCreated === (false), if directory already exists\r\n}, (err) =\u003e {\r\n    // error\r\n});\r\n```\r\n\r\n#### createGitClient [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\ntry {\r\n    const CLIENT = await vscode_helpers.createGitClient();\r\n\r\n    const STD_OUT: string = (await CLIENT.exec([ '--version' ])).stdOut;\r\n\r\n    console.log( STD_OUT );\r\n} catch (e) {\r\n    // no git client found\r\n}\r\n```\r\n\r\n#### createGitClientSync [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\ntry {\r\n    const CLIENT = vscode_helpers.createGitClientSync();\r\n\r\n    console.log(\r\n        CLIENT.execSync([ '--version' ]);\r\n    );\r\n} catch (e) {\r\n    // no git client found\r\n}\r\n```\r\n\r\n#### createInterval [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nconst INTERVAL = vscode_helpers.createInterval(() =\u003e {\r\n    //TODO\r\n}, 1000);\r\n\r\nINTERVAL.dispose();  // same as 'clearInterval'\r\n```\r\n\r\n#### createLogger [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nimport * as fs from 'fs';\r\n\r\nconst LOGGER = vscode_helpers.createLogger((log) =\u003e {\r\n    fs.appendFileSync('./logFile.txt', log.message + \"\\r\\n\", 'utf8');\r\n});\r\n\r\nLOGGER.info('Hello, LOG!');\r\n```\r\n\r\n#### createQueue [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\n/**\r\n * (Default) Options:\r\n * \r\n * {\r\n *     autoStart: true,\r\n *     concurrency: 1,\r\n * }\r\n */\r\nconst MY_QUEUE = vscode_helpers.createQueue();\r\n\r\nvscode_helpers.range(0, 23979).forEach((x) =\u003e {\r\n\r\n    MY_QUEUE.add(async () =\u003e {\r\n        return await vscode_helpers.invokeAfter(() =\u003e {\r\n            return x * 5979;\r\n        }, 100));\r\n    }).then((result: number) =\u003e {\r\n        // succeeded\r\n\r\n        console.log( `MY_QUEUE result of '${ x }': ${ result }` );\r\n    }).catch((err) =\u003e {\r\n        // error\r\n    });\r\n\r\n});\r\n```\r\n\r\n#### createTimeout [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nconst TIMEOUT = vscode_helpers.createTimeout(() =\u003e {\r\n    //TODO\r\n}, 10000);\r\n\r\nTIMEOUT.dispose();  // same as 'clearTimeout'\r\n```\r\n\r\n#### DELETE [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nconst RESULT = await vscode_helpers.DELETE('https://example.com/api/users/19861222');\r\n```\r\n\r\n#### doesMatch [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nvscode_helpers.doesMatch('my-file.txt', '*.txt');  // (true)\r\nvscode_helpers.doesMatch('my-picture.jpg', [ '*.txt' ]);  // (false)\r\nvscode_helpers.doesMatch('my-picture.jpg', [ '*.txt', '*.jpg' ]);  // (true)\r\n```\r\n\r\n#### execFile [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nconst RESULT = await vscode_helpers.execFile('/path/to/execiutable', [ '--version' ]);\r\n\r\nconst STD_ERR = RESULT.stdErr;\r\nconst STD_OUT = RESULT.stdOut;\r\n```\r\n\r\n#### exists [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nvscode_helpers.exists('/path/of/thing/to/check', (doesExist: boolean) =\u003e {\r\n    //TODO    \r\n}, (err) =\u003e {\r\n    // error\r\n});\r\n```\r\n\r\n#### fastGlob [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nconst MATCHES = await vscode_helpers.fastGlob([ '**/*.txt' ], {\r\n    cwd: '/path/to/directory',\r\n    ignore: [ '/log/**/*' ],\r\n});\r\n```\r\n\r\n#### fastGlobSync [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nconst MATCHES = vscode_helpers.fastGlobSync([ '**/*.txt' ], {\r\n    cwd: '/path/to/directory',\r\n    ignore: [ '/log/**/*' ],\r\n});\r\n```\r\n\r\n#### filterExtensionNotifications [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nconst ALL_NOTIFICATIONS: vscode_helpers.ExtensionNotification[] =\r\n    await vscode_helpers.getExtensionNotifications('https://mkloubert.github.io/notifications/vscode-deploy-reloaded.json');\r\n\r\nconst FILTERED_NOTIFICATION = vscode_helpers.filterExtensionNotifications(\r\n    ALL_NOTIFICATIONS, {\r\n        'version': '1.0.0'  // version of the current extension\r\n    }\r\n);\r\n\r\nfor (const NOTE of FILTERED_NOTIFICATION) {\r\n    console.log(\r\n        NOTE.title\r\n    );\r\n}\r\n```\r\n\r\n#### forEachAsync [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nvscode_helpers.forEachAsync([ 5979, 23979 ], async (item, index) =\u003e {\r\n    // [index === 0] =\u003e item === 5979\r\n    // [index === 1] =\u003e item === 23979\r\n\r\n    return item * 1000;\r\n}).then((lastResult) =\u003e {\r\n    // lastResult === 23979000\r\n}, (err) =\u003e {\r\n    // error\r\n});\r\n```\r\n\r\n#### format [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\n// \"MK:23979 + TM: '5979'\"\r\nlet str_1 = vscode_helpers.format(\r\n    'MK:{1} + TM:{0:trim,surround,leading_space}',\r\n    5979,\r\n    23979\r\n);\r\n```\r\n\r\n#### formatArray [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\n// \"MK:23979 + TM: '5979'\"\r\nlet str_1 = vscode_helpers.formatArray(\r\n    'MK:{1} + TM:{0:trim,surround,leading_space}',\r\n    [ 5979, 23979 ]\r\n);\r\n```\r\n\r\n#### from [[\u0026uarr;](#functions-)]\r\n\r\ns. [node-enumerable](https://github.com/mkloubert/node-enumerable)\r\n\r\n```typescript\r\nlet seq = vscode_helpers.from([ 1, 2, 3 ])  // can also be a generator\r\n                                            // or string\r\n                        .select(x =\u003e '' + x)\r\n                        .where(x =\u003e x !== '2')\r\n                        .reverse();\r\n\r\nfor (const ITEM of seq) {\r\n    // [0] '3'\r\n    // [1] '1'\r\n}\r\n```\r\n\r\n#### fromMarkdown [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nlet htmlFromMarkdown = vscode_helpers.fromMarkdown(\r\n    'Vessel     | Captain\\n-----------|-------------\\nNCC-1701   | James T Kirk\\nNCC-1701 A | James T Kirk\\nNCC-1701 D | Picard'\r\n);\r\n```\r\n\r\n#### GET [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nconst RESULT = await vscode_helpers.GET('https://example.com/api/users/5979');\r\n\r\nconst USER_DATA = JSON.parse(\r\n    (await RESULT.readBody()).toString('utf8')\r\n);\r\n```\r\n\r\n#### getExtensionNotifications [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nconst NOTIFICATIONS: vscode_helpers.ExtensionNotification[] =\r\n    await vscode_helpers.getExtensionNotifications('https://mkloubert.github.io/notifications/vscode-deploy-reloaded.json');\r\n\r\nfor (const NOTE of NOTIFICATIONS) {\r\n    console.log(\r\n        NOTE.title\r\n    );\r\n}\r\n```\r\n\r\n#### getExtensionRoot [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nconsole.log(\r\n    vscode_helpers.getExtensionRoot()\r\n);\r\n```\r\n\r\n#### getPackageFile [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nconst PACKAGE_JSON: vscode_helpers.PackageFile = \r\n    await vscode_helpers.getPackageFile();\r\n\r\nconsole.log(\r\n    PACKAGE_JSON.name + ' ' + PACKAGE_JSON.version\r\n);\r\n```\r\n\r\n#### getPackageFileSync [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nconst PACKAGE_JSON: vscode_helpers.PackageFile = \r\n    vscode_helpers.getPackageFileSync();\r\n\r\nconsole.log(\r\n    PACKAGE_JSON.name + ' ' + PACKAGE_JSON.version\r\n);\r\n```\r\n\r\n#### glob [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nvscode_helpers.glob([ '**/*.txt' ], {\r\n    cwd: '/path/to/directory',\r\n    ignore: [ '/log/**/*' ],\r\n    root: '/path/to/directory',\r\n}).then((matches: string[]) =\u003e {\r\n    // 'matches' contains the found files\r\n}, (err) =\u003e {\r\n    // error\r\n});\r\n```\r\n\r\n#### globSync [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nlet matches: string[] = vscode_helpers.globSync([ '**/*.txt' ], {\r\n    cwd: '/path/to/directory',\r\n    ignore: [ '/log/**/*' ],\r\n    root: '/path/to/directory',\r\n});\r\n```\r\n\r\n#### guid [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nlet guid_v4_1 = vscode_helpers.guid();\r\nlet guid_v4_2 = vscode_helpers.guid('4');\r\nlet guid_v4_3 = vscode_helpers.guid('v4');\r\n\r\nlet guid_v5_1 = vscode_helpers.guid('5');\r\nlet guid_v5_2 = vscode_helpers.guid('v5');\r\n\r\nlet guid_v1_1 = vscode_helpers.guid('1');\r\nlet guid_v1_2 = vscode_helpers.guid('v1');\r\n```\r\n\r\n#### invokeAfter [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nvscode_helpers.invokeAfter(() =\u003e {\r\n    // this is invoked after 5979 milliseconds\r\n    return 23979;\r\n}, 5979).then((res) =\u003e {\r\n    // res === 23979\r\n}, (err) =\u003e {\r\n    // is invoked on error\r\n});\r\n```\r\n#### isBinaryContent [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nimport * as fs from 'fs';\r\n\r\nvscode_helpers.isBinaryContent( fs.readFileSync('./myPic.jpg') ).then((isBinary) =\u003e {\r\n    // should be (true)\r\n}, (err) =\u003e {\r\n    // error\r\n});\r\nvscode_helpers.isBinaryContent( fs.readFileSync('./myText.txt') ).then((isBinary) =\u003e {\r\n    // should be (false)\r\n}, (err) =\u003e {\r\n    // error\r\n});\r\n```\r\n\r\n#### isBinaryContentSync [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nimport * as fs from 'fs';\r\n\r\n// should be (true)\r\nvscode_helpers.isBinaryContentSync( fs.readFileSync('./myPic.jpeg') );\r\n// should be (false)\r\nvscode_helpers.isBinaryContentSync( fs.readFileSync('./myText.txt') );\r\n```\r\n\r\n#### isBlockDevice [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nvscode_helpers.isBlockDevice('/path/to/check').then((isABlockDevice) =\u003e {\r\n    // TODO\r\n}, (err) =\u003e {\r\n    // error\r\n})\r\n```\r\n\r\n#### isBlockDeviceSync [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nconst IS_A_BLOCK_DEVICE: boolean = vscode_helpers.isBlockDeviceSync('/path/to/check');\r\n```\r\n\r\n#### isCharacterDevice [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nvscode_helpers.isCharacterDevice('/path/to/check').then((isACharacterDevice) =\u003e {\r\n    // TODO\r\n}, (err) =\u003e {\r\n    // error\r\n})\r\n```\r\n\r\n#### isCharacterDeviceSync [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nconst IS_A_CHARACTER_DEVICE: boolean = vscode_helpers.isCharacterDeviceSync('/path/to/check');\r\n```\r\n\r\n#### isDirectory [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nvscode_helpers.isDirectory('/path/to/check').then((isADirectory) =\u003e {\r\n    // TODO\r\n}, (err) =\u003e {\r\n    // error\r\n})\r\n```\r\n\r\n#### isDirectorySync [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nconst IS_A_DIRECTORY: boolean = vscode_helpers.isDirectorySync('/path/to/check');\r\n```\r\n\r\n#### isEmptyString [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nvscode_helpers.isEmptyString( null );  // (true)\r\nvscode_helpers.isEmptyString( undefined );  // (true)\r\nvscode_helpers.isEmptyString( '123' );  // (false)\r\n```\r\n\r\n#### isFIFO [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nvscode_helpers.isFIFO('/path/to/check').then((isAFIFO) =\u003e {\r\n    // TODO\r\n}, (err) =\u003e {\r\n    // error\r\n})\r\n```\r\n\r\n#### isFIFOSync [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nconst IS_A_FIFO: boolean = vscode_helpers.isFIFOSync('/path/to/check');\r\n```\r\n\r\n#### isFile [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nvscode_helpers.isFile('/path/to/check').then((isAFile) =\u003e {\r\n    // TODO\r\n}, (err) =\u003e {\r\n    // error\r\n})\r\n```\r\n\r\n#### isFileSync [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nconst IS_A_FILE: boolean = vscode_helpers.isFileSync('/path/to/check');\r\n```\r\n\r\n#### isSocket [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nvscode_helpers.isSocket('/path/to/check').then((isASocket) =\u003e {\r\n    // TODO\r\n}, (err) =\u003e {\r\n    // error\r\n})\r\n```\r\n\r\n#### isSocketSync [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nconst IS_A_SOCKET: boolean = vscode_helpers.isSocketSync('/path/to/check');\r\n```\r\n\r\n#### isSymbolicLink [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nvscode_helpers.isSymbolicLink('/path/to/check').then((isASymbolicLink) =\u003e {\r\n    // TODO\r\n}, (err) =\u003e {\r\n    // error\r\n})\r\n```\r\n\r\n#### isSymbolicLinkSync [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nconst IS_A_SYMBOLIC_LINK: boolean = vscode_helpers.isSymbolicLinkSync('/path/to/check');\r\n```\r\n\r\n#### loadModule [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\ninterface MyModule {\r\n    execute(): any;\r\n}\r\n\r\nlet mod = vscode_helpers.loadModule\u003cMyModule\u003e('/path/to/module.js');\r\n\r\nlet modResult = mod.execute();\r\n```\r\n\r\n### makeNonDisposable [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nconst OBJ = {\r\n    dispose: () =\u003e {\r\n        console.log('Disposed!');\r\n    }\r\n};\r\n\r\nconst OBJ_1 = vscode_helpers.makeNonDisposable( OBJ, false );\r\nOBJ_1.dispose();  // does nothing\r\n\r\nconst OBJ_2 = vscode_helpers.makeNonDisposable( OBJ );\r\nOBJ_2.dispose();  // throws an exception\r\n```\r\n\r\n#### normalizeString [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nconst str_1 = vscode_helpers.normalizeString('aBc');  // 'abc'\r\nconst str_2 = vscode_helpers.normalizeString(null);  // ''\r\nconst str_3 = vscode_helpers.normalizeString('aBc', s =\u003e s.toUpperCase());  // 'ABC'\r\n```\r\n\r\n#### now [[\u0026uarr;](#functions-)]\r\n\r\ns. [Moment Timezone](https://momentjs.com/timezone/) for more information about using (optional) timezones.\r\n\r\n```typescript\r\nconst NOW = vscode_helpers.now('America/New_York')  // optional\r\n                          .format('DD.MM.YYYY HH:mm:ss');\r\n```\r\n\r\n#### openAndShowTextDocument [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\n// empty (plain text)\r\nconst EDITOR_1 = await vscode_helpers.openAndShowTextDocument();\r\n\r\n// from file\r\nconst EDITOR_2 = await vscode_helpers.openAndShowTextDocument('/path/to/file');\r\n\r\n// with initial content\r\nconst EDITOR_3 = await vscode_helpers.openAndShowTextDocument({\r\n    language: 'typescript',\r\n    content: `interface Pet {\r\n    name: string;\r\n    owner: string;\r\n}`,\r\n});\r\n```\r\n\r\n#### PATCH [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nconst RESULT = await vscode_helpers.PATCH('https://example.com/api/users/23979', JSON.stringify({\r\n    displayName: 'Marcel Kloubert',\r\n}), {\r\n    'Content-Type': 'application/json; charset=utf8',\r\n});\r\n```\r\n\r\n#### POST [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nconst RESULT = await vscode_helpers.POST('https://example.com/api/users/23979', JSON.stringify({\r\n    displayName: 'Marcel Kloubert',\r\n    userName: 'mkloubert',\r\n    country: 'Germany',\r\n}), {\r\n    'Content-Type': 'application/json; charset=utf8',\r\n});\r\n```\r\n\r\n#### PUT [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nconst RESULT = await vscode_helpers.PUT('https://example.com/api/users/23979', JSON.stringify({\r\n    displayName: 'Marcel Kloubert',\r\n}), {\r\n    'Content-Type': 'application/json; charset=utf8',\r\n});\r\n```\r\n\r\n#### randomBytes [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nvscode_helpers.randomBytes(5979).then((bytes: Buffer) =\u003e {\r\n    // 5979 random bytes are stored\r\n    // in 'bytes' now\r\n}, (err) =\u003e {\r\n    // error\r\n});\r\n```\r\n\r\n#### range [[\u0026uarr;](#functions-)]\r\n\r\ns. [node-enumerable](https://github.com/mkloubert/node-enumerable)\r\n\r\n```typescript\r\nvscode_helpers.range(1, 5).forEach((x) =\u003e {\r\n    // x[0] === 1\r\n    // x[1] === 2\r\n    // x[2] === 3\r\n    // x[3] === 4\r\n    // x[4] === 5\r\n});\r\n```\r\n\r\n#### readAll [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nimport * as fs from 'fs';\r\n\r\nconst STREAM = fs.createReadStream('./my-file.txt');\r\n\r\nreadAll( STREAM ).then((data: Buffer) =\u003e {\r\n    // all data read\r\n}, (err) =\u003e {\r\n    // error\r\n});\r\n```\r\n\r\n#### registerWorkspaceWatcher [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nimport * as Path from 'path';\r\nimport { ConfigurationChangeEvent, Uri } from 'vscode';\r\n\r\nclass MyWorkspace extends vscode_helpers.WorkspaceBase {\r\n    private _configSrc: vscode_helpers.WorkspaceConfigSource;\r\n\r\n    // this is important for 'onDidChangeConfiguration' (s. below)\r\n    public get configSource() {\r\n        return this._configSrc;\r\n    }    \r\n\r\n    public async initialize() {\r\n        // initialize your workspace here\r\n\r\n        this._configSrc = {\r\n            section: 'my.extension',\r\n            resource: Uri.file( Path.join(this.rootPath,\r\n                                          '.vscode/settings.json') ),\r\n        };\r\n    }\r\n\r\n    public async onDidChangeConfiguration(e: ConfigurationChangeEvent) {\r\n        // is invoked when workspace config changed\r\n    }\r\n}\r\n\r\nvscode_helpers.registerWorkspaceWatcher(async (event, folder, workspace?) =\u003e {\r\n    if (event == vscode_helpers.WorkspaceWatcherEvent.Added) {\r\n        const NEW_WORKSPACE = new MyWorkspace( folder );\r\n        \r\n        await NEW_WORKSPACE.initialize();\r\n        \r\n        return NEW_WORKSPACE;\r\n    }\r\n});\r\n```\r\n\r\n#### repeat [[\u0026uarr;](#functions-)]\r\n\r\ns. [node-enumerable](https://github.com/mkloubert/node-enumerable)\r\n\r\n```typescript\r\n// 5979 'TM' strings\r\nvscode_helpers.repeat('TM', 5979).forEach((x) =\u003e {\r\n    //TODO\r\n});\r\n```\r\n\r\n#### request [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nconst RESULT = await vscode_helpers.request('POST', 'https://example.com/api/users/23979', JSON.stringify({\r\n    displayName: 'Marcel Kloubert',\r\n    userName: 'mkloubert',\r\n    country: 'Germany',\r\n}), {\r\n    'Content-Type': 'application/json; charset=utf8',\r\n});\r\n```\r\n\r\n#### setExtensionRoot [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nvscode_helpers.setExtensionRoot(\r\n    __dirname\r\n);\r\n\r\nconsole.log(\r\n    vscode_helpers.getExtensionRoot()\r\n);\r\n```\r\n\r\n#### size [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nvscode_helpers.size('/path/to/a/file').then((fileSize: number) =\u003e {\r\n    // 'fileSize' stores the file size in bytes\r\n}, (err) =\u003e {\r\n    // ERROR\r\n});\r\n\r\n// use 'stat()' function instead\r\n// s. https://nodejs.org/api/fs.html#fs_fs_stat_path_callback\r\nvscode_helpers.size('/path/to/a/file', false).then((fileSize: number) =\u003e {    \r\n}, (err) =\u003e {\r\n});\r\n```\r\n\r\n#### sizeSync [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nconst FILESIZE_1 = vscode_helpers.sizeSync('/path/to/a/file');\r\n\r\n// use 'statSync()' function instead\r\n// s. https://nodejs.org/api/fs.html#fs_fs_statsync_path\r\nconst FILESIZE_2 = vscode_helpers.sizeSync('/path/to/a/file', false);\r\n```\r\n\r\n#### sleep [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nvscode_helpers.sleep(23979).then(() =\u003e {\r\n    // 23979 milliseconds gone\r\n}, (err) =\u003e {\r\n    // is invoked on error\r\n});\r\n```\r\n\r\n#### startWatch [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nconst WATCH = vscode_helpers.startWatch();\r\n\r\nvscode_helpers.sleep(1000).then(() =\u003e {\r\n    const MS = WATCH.stop();  // 'MS' should be a least 1000    \r\n});\r\n```\r\n\r\n#### toBooleanSafe [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nconst bool_1 = vscode_helpers.toBooleanSafe( true );  // (true)\r\nconst bool_2 = vscode_helpers.toBooleanSafe( null );  // (false)\r\nconst bool_3 = vscode_helpers.toBooleanSafe( undefined, true );  // (true)\r\n```\r\n\r\n#### tempFile [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nvscode_helpers.tempFile((pathToTempFile: string) =\u003e {\r\n    //TODO\r\n\r\n    return 5979;\r\n}).then((result) =\u003e {\r\n    // result === 5979\r\n}, (err) =\u003e {\r\n    // ERROR!\r\n});\r\n```\r\n\r\n#### tempFileSync [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nlet result = vscode_helpers.tempFileSync((pathToTempFile: string) =\u003e {\r\n    //TODO\r\n\r\n    return 23979;\r\n});\r\n\r\n// result === 23979\r\n```\r\n\r\n#### toArray [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nlet myGenerator = function* () {\r\n    yield 5979;\r\n    yield 23979;\r\n};\r\n\r\nlet arr_1 = vscode_helpers.toArray( myGenerator() );\r\nlet arr_2 = vscode_helpers.toArray( [ 19861222, 'PZSUX' ] );  // new array\r\n```\r\n\r\n#### toEOL [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nimport { EndOfLine } from 'vscode';\r\n\r\nconst eol_1 = vscode_helpers.toEOL();  // system's EOL\r\nconst eol_2 = vscode_helpers.toEOL( EndOfLine.CRLF );  // \\r\\n\r\n```\r\n\r\n#### toStringSafe [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nconst str_1 = vscode_helpers.toStringSafe( 123 );  // '123'\r\nconst str_2 = vscode_helpers.toStringSafe( null );  // ''\r\nconst str_3 = vscode_helpers.toStringSafe( undefined, 'abc' );  // 'abc'\r\n```\r\n\r\n#### tryClearInterval [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nlet timer = setInterval(() =\u003e {\r\n    // do something\r\n}, 5979);\r\n\r\nvscode_helpers.tryClearInterval( timer );\r\n```\r\n\r\n#### tryClearTimeout [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nlet timer = setTimeout(() =\u003e {\r\n    // do something\r\n}, 23979);\r\n\r\nvscode_helpers.tryClearTimeout( timer );\r\n```\r\n\r\n#### tryCreateGitClient [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nconst CLIENT = await vscode_helpers.tryCreateGitClient();\r\n\r\nif (false !== CLIENT) {\r\n    const STD_OUT: string = (await CLIENT.exec([ '--version' ])).stdOut;\r\n\r\n    console.log( STD_OUT );\r\n} else {\r\n    // no git client found\r\n}\r\n```\r\n\r\n#### tryCreateGitClientSync [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nconst CLIENT = vscode_helpers.tryCreateGitClientSync();\r\n\r\nif (false !== CLIENT) {\r\n    console.log(\r\n        CLIENT.execSync([ '--version' ]);\r\n    );\r\n} else {\r\n    // no git client found\r\n}\r\n```\r\n\r\n#### tryDispose [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nconst OBJ = {\r\n    dispose: () =\u003e {\r\n        throw new Error( 'Could not dispose!' );\r\n    }\r\n};\r\n\r\n// (false)\r\nvscode_helpers.tryDispose( OBJ );\r\n```\r\n\r\n#### tryDisposeAndDelete [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nconst OBJ = {\r\n    dispose: () =\u003e {\r\n        //TODO\r\n    }\r\n};\r\n\r\nconst PARENT = { 'obj_key': OBJ };\r\n\r\nvscode_helpers.tryDisposeAndDelete( PARENT, 'obj_key' );\r\n// 'PARENT' should not contain an object in 'obj_key' anymore\r\n```\r\n\r\n#### tryRemoveAllListeners [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nimport * as fs from 'fs';\r\n\r\nconst STREAM = fs.createReadStream('./my-file.txt');\r\n\r\nSTREAM.once('error', (err) =\u003e {\r\n    //TODO\r\n\r\n    vscode_helpers.tryRemoveAllListeners(STREAM);\r\n});\r\n\r\nSTREAM.once('end', () =\u003e {\r\n    vscode_helpers.tryRemoveAllListeners(STREAM);\r\n});\r\n\r\nSTREAM.on('data', (chunk) =\u003e {\r\n    //TODO\r\n});\r\n```\r\n\r\n#### tryRemoveListener [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nimport * as fs from 'fs';\r\n\r\nconst STREAM = fs.createReadStream('./my-file.txt');\r\n\r\nconst DATA_LISTENER = (chunk) =\u003e {\r\n    //TODO\r\n};\r\n\r\nSTREAM.on('data', DATA_LISTENER);\r\n\r\nSTREAM.once('end', () =\u003e {\r\n    vscode_helpers.tryRemoveListener(STREAM,\r\n                                     'data', DATA_LISTENER);\r\n});\r\n```\r\n\r\n#### using [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nconst MY_OBJECT = {\r\n    value: 5979,\r\n\r\n    dispose: function() {\r\n        console.log(\"I have been disposed with value \" + this.value);\r\n    }\r\n};\r\n\r\nvscode_helpers.using(MY_OBJECT, (obj) =\u003e {\r\n    return obj.value + 23979;\r\n}).then((result) =\u003e {\r\n    // result === 29958\r\n}, (err) =\u003e {\r\n    // on error\r\n});\r\n```\r\n\r\n#### usingSync [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nconst MY_OBJECT = {\r\n    value: 23979,\r\n\r\n    dispose: function() {\r\n        console.log(\"I have been disposed with value \" + this.value);\r\n    }\r\n};\r\n\r\n// RESULT === 29958\r\nconst RESULT = vscode_helpers.usingSync(MY_OBJECT, (obj) =\u003e {\r\n    return obj.value + 5979;\r\n});\r\n```\r\n\r\n#### utcNow [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nconst UTC_NOW = vscode_helpers.utcNow()\r\n                              .format('DD.MM.YYYY HH:mm:ss');\r\n```\r\n\r\n#### uuid [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nlet uuid_v4_1 = vscode_helpers.uuid();\r\nlet uuid_v4_2 = vscode_helpers.uuid('4');\r\nlet uuid_v4_3 = vscode_helpers.uuid('v4');\r\n\r\nlet uuid_v5_1 = vscode_helpers.uuid('5');\r\nlet uuid_v5_2 = vscode_helpers.uuid('v5');\r\n\r\nlet uuid_v1_1 = vscode_helpers.uuid('1');\r\nlet uuid_v1_2 = vscode_helpers.uuid('v1');\r\n```\r\n\r\n#### waitWhile [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nlet counter = 5979;\r\n\r\nvscode_helpers.waitWhile(() =\u003e {\r\n    return --counter \u003c 1;\r\n}, {\r\n    timeUntilNextCheck: 100,\r\n    timeout: 60000,\r\n}).then((isTimeout: boolean) =\u003e {\r\n    // counter === 0\r\n}, (err) =\u003e {\r\n    // error occurred\r\n});\r\n```\r\n\r\n#### withProgress [[\u0026uarr;](#functions-)]\r\n\r\n```typescript\r\nimport { ProgressLocation } from 'vscode';\r\n\r\nvscode_helpers.withProgress((context) =\u003e {\r\n    let res = 0;\r\n\r\n    context.increment = 10;  // increment by 10% after each update\r\n\r\n    for (let i = 0; i \u003c 10; i++) {\r\n        context.message = `Task ${i + 1} of 10 ...`;\r\n\r\n        // do something\r\n\r\n        ++res;\r\n    }\r\n\r\n    return res;\r\n}, {\r\n    location: ProgressLocation.Window,\r\n    title: 'My operation',\r\n}).then((res) =\u003e {\r\n    // res === 10\r\n}, (err) =\u003e {\r\n    // error\r\n});\r\n```\r\n\r\n### Classes [[\u0026uarr;](#examples-)]\r\n\r\n#### CacheProviderBase [[\u0026uarr;](#classes-)]\r\n\r\n```typescript\r\nclass MyCache extends vscode_helpers.CacheProviderBase {\r\n    // implement abstract members here\r\n}\r\n```\r\n\r\n#### DisposableBase [[\u0026uarr;](#classes-)]\r\n\r\n```typescript\r\nclass MyDisposable extends vscode_helpers.MyDisposable {\r\n    protected onDispose() {\r\n        // your custom logic\r\n    }\r\n}\r\n\r\nvscode_helpers.tryDispose( new MyDisposable() );\r\n```\r\n\r\n#### MemoryCache [[\u0026uarr;](#classes-)]\r\n\r\n```typescript\r\nconst CACHE = new vscode_helpers.MemoryCache();\r\n\r\nCACHE.get('a', 23979);  // 23979\r\nCACHE.set('a', 5979);  // 5979\r\nCACHE.has('a');  // (true)\r\nCACHE.unset('a');\r\nCACHE.has('a');  // (false)\r\n```\r\n\r\n#### StopWatch [[\u0026uarr;](#classes-)]\r\n\r\n```typescript\r\nconst WATCH = new vscode_helpers.StopWatch();\r\nWATCH.start();\r\n\r\nvscode_helpers.sleep(1000).then(() =\u003e {\r\n    const MS = WATCH.stop();  // 'MS' should be a least 1000    \r\n});\r\n```\r\n\r\n#### WorkspaceBase [[\u0026uarr;](#classes-)]\r\n\r\n```typescript\r\nimport { ConfigurationChangeEvent, Uri } from 'vscode';\r\n\r\nclass MyWorkspace extends vscode_helpers.WorkspaceBase {\r\n    private _configSrc: vscode_helpers.WorkspaceConfigSource;\r\n\r\n    // this is important for 'onDidChangeConfiguration' (s. below)\r\n    public get configSource() {\r\n        return this._configSrc;\r\n    }    \r\n\r\n    public async initialize() {\r\n        // initialize your workspace here\r\n\r\n        this._configSrc = {\r\n            section: 'my.extension',\r\n            resource: Uri.file( Path.join(this.rootPath,\r\n                                          '.vscode/settings.json') ),\r\n        };\r\n    }\r\n\r\n    public async onDidChangeConfiguration(e: ConfigurationChangeEvent) {\r\n        // is invoked when workspace config changed\r\n    }\r\n}\r\n```\r\n\r\n### Constants and variables [[\u0026uarr;](#examples-)]\r\n\r\n#### EVENTS [[\u0026uarr;](#constants-and-variables-)]\r\n\r\n```typescript\r\nvscode_helpers.EVENTS.on('myEvent', (a, b) =\u003e {\r\n    console.log('myEvent: ' + (a + b));\r\n});\r\n\r\nvscode_helpers.EVENTS\r\n              .emit('myEvent', 5979, 23979);\r\n```\r\n\r\n#### IS_* [[\u0026uarr;](#constants-and-variables-)]\r\n\r\n```typescript\r\nvscode_helpers.IS_AIX;  // AIX\r\nvscode_helpers.IS_FREE_BSD;  // Free BSD\r\nvscode_helpers.IS_LINUX;  // Linux\r\nvscode_helpers.IS_MAC;  // Mac OS\r\nvscode_helpers.IS_OPEN_BSD;  // Open BSD\r\nvscode_helpers.IS_SUNOS;  // Sun OS\r\nvscode_helpers.IS_WINDOWS;  // Windows\r\n```\r\n\r\n#### QUEUE [[\u0026uarr;](#constants-and-variables-)]\r\n\r\n```typescript\r\nvscode_helpers.range(0, 5979).forEach((x) =\u003e {\r\n\r\n    vscode_helpers.QUEUE.add(async () =\u003e {\r\n        return await vscode_helpers.invokeAfter(() =\u003e {\r\n            return x * 23979;\r\n        }, 100));\r\n    }).then((result: number) =\u003e {\r\n        // succeeded\r\n\r\n        console.log( `QUEUE result of '${ x }': ${ result }` );\r\n    }).catch((err) =\u003e {\r\n        // error\r\n    });\r\n\r\n});\r\n```\r\n\r\n#### SESSION [[\u0026uarr;](#constants-and-variables-)]\r\n\r\n```typescript\r\nlet var_1 = vscode_helpers.SESSION['a'];  // undefined (at the beginning)\r\n\r\nvscode_helpers.SESSION['a'] = 5979;\r\nlet var_2 = vscode_helpers.SESSION['a'];  // 5979\r\n\r\ndelete vscode_helpers.SESSION['a'];\r\nlet var_3 = vscode_helpers.SESSION['a'];  // undefined\r\n```\r\n\r\n## Branches [[\u0026uarr;](#table-of-contents)]\r\n\r\n| Name | minimum Visual Studio Code version |\r\n| ---- | --------- |\r\n| [v10](https://github.com/mkloubert/vscode-helpers/tree/v10) (current) | `^1.62.0` |\r\n| [v9](https://github.com/mkloubert/vscode-helpers/tree/v9) | `^1.62.0` |\r\n| [v8](https://github.com/mkloubert/vscode-helpers/tree/v8) | `^1.50.0` |\r\n| [v7](https://github.com/mkloubert/vscode-helpers/tree/v7) | `^1.42.0` |\r\n| [v6](https://github.com/mkloubert/vscode-helpers/tree/v6) | `^1.38.0` |\r\n| [v5](https://github.com/mkloubert/vscode-helpers/tree/v5) | `^1.36.0` |\r\n| [v4](https://github.com/mkloubert/vscode-helpers/tree/v4) | `^1.30.0` |\r\n| [v3](https://github.com/mkloubert/vscode-helpers/tree/v3) | `^1.30.0` |\r\n| [v2](https://github.com/mkloubert/vscode-helpers/tree/v2) | `^1.23.0` |\r\n| [v1](https://github.com/mkloubert/vscode-helpers/tree/v1) | `^1.22.0` |\r\n| [beta](https://github.com/mkloubert/vscode-helpers/tree/beta) | `^1.20.0` |\r\n\r\n## Support and contribute [[\u0026uarr;](#table-of-contents)]\r\n\r\nIf you like the module, you can support the project by sending a [donation via PayPal](https://paypal.me/MarcelKloubert) to [me](https://github.com/mkloubert).\r\n\r\nTo contribute, you can [open an issue](https://github.com/mkloubert/vscode-helpers/issues) and/or fork this repository.\r\n\r\nTo work with the code:\r\n\r\n* clone [this repository](https://github.com/mkloubert/vscode-helpers)\r\n* create and change to a new branch, like `git checkout -b my_new_feature`\r\n* run `npm install` from your project folder\r\n* open that project folder in Visual Studio Code\r\n* now you can edit and debug there\r\n* commit your changes to your new branch and sync it with your forked GitHub repo\r\n* make a [pull request](https://github.com/mkloubert/vscode-helpers/pulls)\r\n\r\n## Documentation [[\u0026uarr;](#table-of-contents)]\r\n\r\nThe API documentation can be found [here](https://mkloubert.github.io/vscode-helpers/).\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmkloubert%2Fvscode-helpers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmkloubert%2Fvscode-helpers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmkloubert%2Fvscode-helpers/lists"}