Options
All
  • Public
  • Public/Protected
  • All
Menu

Module resources

This file is part of the vscode-powertools distribution. Copyright (c) Next.e.GO Mobile SE, Aachen, Germany (https://www.e-go-mobile.com/)

vscode-powertools is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, version 3.

vscode-powertools is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Index

Variables

Variables

Const EXAMPLE_SCRIPT

EXAMPLE_SCRIPT: "\n\nconst MAX_USER_COUNT = 20;\n\n$clear();\n\nawait $withProgress(async (progress, cancelToken) => {\n progress.report({\n message: `Loading list of random users from 'randomuser.me' ...`,\n });\n\n // s. https://github.com/mkloubert/vscode-helpers#get-\n const RESPONSE = await $helpers.GET('https://randomuser.me/api?nat=de&results=' + MAX_USER_COUNT);\n if (200 !== RESPONSE.code) {\n throw new Error(`Unexpected response: [${ RESPONSE.code }] '${ RESPONSE.status }'`);\n }\n\n const RESULTS_WITH_USERS = JSON.parse(\n (await RESPONSE.readBody())\n .toString('utf8')\n );\n\n if (!RESULTS_WITH_USERS.info.results) {\n $vscode.window.showWarningMessage('No users available!');\n return;\n }\n\n const ALL_USERS = RESULTS_WITH_USERS.results;\n\n for (let i = 0; i < ALL_USERS.length; i++) {\n if (cancelToken.isCancellationRequested) {\n return; // user wants to cancel\n // from progress window\n }\n\n if ($cancel.isCancellationRequested) {\n return; // user wants to cancel\n // from console window\n }\n\n const USER = ALL_USERS[i];\n\n progress.report({\n message: `Processing user '${ USER.name.last }, ${ USER.name.first }' ...`,\n increment: 1 / ALL_USERS.length * 100.0,\n });\n\n const USER_META = [\n `gender: ${ USER.gender }`,\n `id: ${ USER.login.uuid }`,\n `mail: ${ USER.email }`,\n `country: ${ USER.nat }`,\n ];\n\n $writeMarkdown(`## [${ i + 1 }] ${ $html.encode(USER.name.last + ', ' + USER.name.first) }`);\n $writeMarkdown(\n `| Icon | Meta |\\n`\n + `| ---- | ---- |\\n`\n // icon\n + `| ![${ $html.encode(USER.name.last + ', ' + USER.name.first) }](${ USER.picture.medium }) | `\n // meta\n + `${ USER_META.map(m => $html.encode(m)).join('<br />') } |\\n`\n );\n\n await $sleep(0.5);\n }\n});\n" = ...

An example script.

Generated using TypeDoc