Skip to content

Instantly share code, notes, and snippets.

@nagdav853
Last active May 21, 2021
Embed
What would you like to do?
{"lastUpload":"2021-05-21T07:54:41.963Z","extensionVersion":"v3.4.3"}
[
{
"metadata": {
"id": "d3836729-9cc1-42c1-b2af-d50071f57d29",
"publisherId": "formulahendry.auto-close-tag",
"publisherDisplayName": "formulahendry"
},
"name": "auto-close-tag",
"publisher": "formulahendry",
"version": "0.5.10"
},
{
"metadata": {
"id": "8bd90cfe-8edd-4b92-b992-2337fdc06604",
"publisherId": "wwm.better-align",
"publisherDisplayName": "wwm"
},
"name": "better-align",
"publisher": "wwm",
"version": "1.1.7"
},
{
"metadata": {
"id": "7a0110bb-231a-4598-aa1b-0769ea46d28b",
"publisherId": "aaron-bond.better-comments",
"publisherDisplayName": "aaron-bond"
},
"name": "better-comments",
"publisher": "aaron-bond",
"version": "2.1.0"
},
{
"metadata": {
"id": "897c115a-dfbf-4c20-bafd-1c13fc5d1d80",
"publisherId": "Yummygum.city-lights-icon-vsc",
"publisherDisplayName": "Yummygum"
},
"name": "city-lights-icon-vsc",
"publisher": "Yummygum",
"version": "1.1.5"
},
{
"metadata": {
"id": "a6a0c5b2-d078-4bf5-a9ee-4e37054414b3",
"publisherId": "formulahendry.code-runner",
"publisherDisplayName": "formulahendry"
},
"name": "code-runner",
"publisher": "formulahendry",
"version": "0.11.3"
},
{
"metadata": {
"id": "e337c67b-55c2-4fef-8949-eb260e7fb7fd",
"publisherId": "Shan.code-settings-sync",
"publisherDisplayName": "Shan"
},
"name": "code-settings-sync",
"publisher": "Shan",
"version": "3.4.3"
},
{
"metadata": {
"id": "f6dbd813-b0a0-42c1-90ea-10dde9d925a7",
"publisherId": "streetsidesoftware.code-spell-checker",
"publisherDisplayName": "streetsidesoftware"
},
"name": "code-spell-checker",
"publisher": "streetsidesoftware",
"version": "1.10.4"
},
{
"metadata": {
"id": "8c1fc960-44b1-45e8-89b5-85f982fdaf27",
"publisherId": "adpyke.codesnap",
"publisherDisplayName": "adpyke"
},
"name": "codesnap",
"publisher": "adpyke",
"version": "1.2.1"
},
{
"metadata": {
"id": "121396ad-85a1-45ec-9fd1-d95028a847f5",
"publisherId": "naumovs.color-highlight",
"publisherDisplayName": "naumovs"
},
"name": "color-highlight",
"publisher": "naumovs",
"version": "2.3.0"
},
{
"metadata": {
"id": "060828aa-17ab-40d9-9e2d-f8407f5c8d04",
"publisherId": "alexdima.copy-relative-path",
"publisherDisplayName": "alexdima"
},
"name": "copy-relative-path",
"publisher": "alexdima",
"version": "0.0.2"
},
{
"metadata": {
"id": "17163a13-002c-4813-855a-f531a413d638",
"publisherId": "JosefBiehler.cypress-fixture-intellisense",
"publisherDisplayName": "JosefBiehler"
},
"name": "cypress-fixture-intellisense",
"publisher": "JosefBiehler",
"version": "1.2.0"
},
{
"metadata": {
"id": "0db1f6a4-4b91-4615-b105-20c7e6191ecd",
"publisherId": "andrew-codes.cypress-snippets",
"publisherDisplayName": "andrew-codes"
},
"name": "cypress-snippets",
"publisher": "andrew-codes",
"version": "1.2.0"
},
{
"metadata": {
"id": "46edf7dd-61d3-4721-86bc-fd04963e3791",
"publisherId": "iJS.cypress-snippets",
"publisherDisplayName": "iJS"
},
"name": "cypress-snippets",
"publisher": "iJS",
"version": "1.0.0"
},
{
"metadata": {
"id": "1ec62ca5-d7f9-4ddb-a882-e8d018c0aefd",
"publisherId": "msjsdiag.debugger-for-chrome",
"publisherDisplayName": "msjsdiag"
},
"name": "debugger-for-chrome",
"publisher": "msjsdiag",
"version": "4.12.12"
},
{
"metadata": {
"id": "532533c9-a894-4a58-9eee-bbfbe7c06f71",
"publisherId": "mikestead.dotenv",
"publisherDisplayName": "mikestead"
},
"name": "dotenv",
"publisher": "mikestead",
"version": "1.0.1"
},
{
"metadata": {
"id": "277",
"publisherId": "EditorConfig.EditorConfig",
"publisherDisplayName": "EditorConfig"
},
"name": "EditorConfig",
"publisher": "EditorConfig",
"version": "0.15.1"
},
{
"metadata": {
"id": "4de763bd-505d-4978-9575-2b7696ecf94e",
"publisherId": "eamodio.gitlens",
"publisherDisplayName": "eamodio"
},
"name": "gitlens",
"publisher": "eamodio",
"version": "11.3.0"
},
{
"metadata": {
"id": "961c6678-1125-43a1-8482-df5a0766d313",
"publisherId": "tomphilbin.gruvbox-themes",
"publisherDisplayName": "tomphilbin"
},
"name": "gruvbox-themes",
"publisher": "tomphilbin",
"version": "1.0.0"
},
{
"metadata": {
"id": "07734f09-9218-443a-abfa-a9a823d2c25a",
"publisherId": "gencer.html-slim-scss-css-class-completion",
"publisherDisplayName": "gencer"
},
"name": "html-slim-scss-css-class-completion",
"publisher": "gencer",
"version": "1.7.8"
},
{
"metadata": {
"id": "be992f3f-9f22-4b66-a1d2-ecad04c28a28",
"publisherId": "abusaidm.html-snippets",
"publisherDisplayName": "abusaidm"
},
"name": "html-snippets",
"publisher": "abusaidm",
"version": "0.2.1"
},
{
"metadata": {
"id": "0ec558c9-f7f7-4df3-b2cf-a41ddcf292dd",
"publisherId": "mkaufman.HTMLHint",
"publisherDisplayName": "mkaufman"
},
"name": "HTMLHint",
"publisher": "mkaufman",
"version": "0.8.0"
},
{
"metadata": {
"id": "c16f95f6-9b42-4a24-9bf4-245d4ea54fc5",
"publisherId": "bradgashler.htmltagwrap",
"publisherDisplayName": "bradgashler"
},
"name": "htmltagwrap",
"publisher": "bradgashler",
"version": "0.0.7"
},
{
"metadata": {
"id": "eaa2127d-cb69-4ab9-8505-a60c9ee5f28b",
"publisherId": "oderwat.indent-rainbow",
"publisherDisplayName": "oderwat"
},
"name": "indent-rainbow",
"publisher": "oderwat",
"version": "7.5.0"
},
{
"metadata": {
"id": "a2cec723-5349-460d-9de9-0fd1f8d3456f",
"publisherId": "xabikos.JavaScriptSnippets",
"publisherDisplayName": "xabikos"
},
"name": "JavaScriptSnippets",
"publisher": "xabikos",
"version": "1.8.0"
},
{
"metadata": {
"id": "74f34f8a-245e-4133-8617-a3a94b5a417e",
"publisherId": "cmstead.jsrefactor",
"publisherDisplayName": "cmstead"
},
"name": "jsrefactor",
"publisher": "cmstead",
"version": "2.20.6"
},
{
"metadata": {
"id": "6c2f1801-1e7f-45b2-9b5c-7782f1e076e8",
"publisherId": "ms-toolsai.jupyter",
"publisherDisplayName": "ms-toolsai"
},
"name": "jupyter",
"publisher": "ms-toolsai",
"version": "2021.5.745244803"
},
{
"metadata": {
"id": "b63c44fd-0457-4696-99e9-dbfdf70d77de",
"publisherId": "ritwickdey.LiveServer",
"publisherDisplayName": "ritwickdey"
},
"name": "LiveServer",
"publisher": "ritwickdey",
"version": "5.6.1"
},
{
"metadata": {
"id": "1f5eb737-5496-44a3-a8a1-36a85eee4979",
"publisherId": "magicstack.MagicPython",
"publisherDisplayName": "magicstack"
},
"name": "MagicPython",
"publisher": "magicstack",
"version": "1.1.1"
},
{
"metadata": {
"id": "98790d67-10fa-497c-9113-f6c7489207b2",
"publisherId": "yzhang.markdown-all-in-one",
"publisherDisplayName": "yzhang"
},
"name": "markdown-all-in-one",
"publisher": "yzhang",
"version": "3.4.0"
},
{
"metadata": {
"id": "9f47c6a1-da06-41ce-ba18-5e281296aa0a",
"publisherId": "stringham.move-ts",
"publisherDisplayName": "stringham"
},
"name": "move-ts",
"publisher": "stringham",
"version": "1.12.0"
},
{
"metadata": {
"id": "fa17bcf3-8d28-4673-9e23-c448c372e20c",
"publisherId": "chris-noring.node-snippets",
"publisherDisplayName": "chris-noring"
},
"name": "node-snippets",
"publisher": "chris-noring",
"version": "1.0.1"
},
{
"metadata": {
"id": "dff6b801-247e-40e9-82e8-8c9b1d19d1b8",
"publisherId": "christian-kohler.npm-intellisense",
"publisherDisplayName": "christian-kohler"
},
"name": "npm-intellisense",
"publisher": "christian-kohler",
"version": "1.3.0"
},
{
"metadata": {
"id": "79afa437-682e-4fa2-a4fd-87844832a1dc",
"publisherId": "ryu1kn.partial-diff",
"publisherDisplayName": "ryu1kn"
},
"name": "partial-diff",
"publisher": "ryu1kn",
"version": "1.4.1"
},
{
"metadata": {
"id": "a41c1549-4053-44d4-bf30-60fc809b4a86",
"publisherId": "christian-kohler.path-intellisense",
"publisherDisplayName": "christian-kohler"
},
"name": "path-intellisense",
"publisher": "christian-kohler",
"version": "2.3.0"
},
{
"metadata": {
"id": "d19b9c06-6607-4661-ae44-1c91d045ad3f",
"publisherId": "cossssmin.posthtml",
"publisherDisplayName": "cossssmin"
},
"name": "posthtml",
"publisher": "cossssmin",
"version": "0.2.1"
},
{
"metadata": {
"id": "96fa4707-6983-4489-b7c5-d5ffdfdcce90",
"publisherId": "esbenp.prettier-vscode",
"publisherDisplayName": "esbenp"
},
"name": "prettier-vscode",
"publisher": "esbenp",
"version": "6.3.2"
},
{
"metadata": {
"id": "67e66172-30c7-4478-8f5d-6eac4ae755dc",
"publisherId": "mohsen1.prettify-json",
"publisherDisplayName": "mohsen1"
},
"name": "prettify-json",
"publisher": "mohsen1",
"version": "0.0.3"
},
{
"metadata": {
"id": "1b747f06-3789-4ebd-ac99-f1fe430c3347",
"publisherId": "alefragnani.project-manager",
"publisherDisplayName": "alefragnani"
},
"name": "project-manager",
"publisher": "alefragnani",
"version": "12.1.0"
},
{
"metadata": {
"id": "f1f59ae4-9318-4f3c-a9b5-81b2eaa5f8a5",
"publisherId": "ms-python.python",
"publisherDisplayName": "ms-python"
},
"name": "python",
"publisher": "ms-python",
"version": "2021.3.680753044"
},
{
"metadata": {
"id": "e05d98bf-3735-4c1e-9fae-86ef0a52e19f",
"publisherId": "quicktype.quicktype",
"publisherDisplayName": "quicktype"
},
"name": "quicktype",
"publisher": "quicktype",
"version": "12.0.46"
},
{
"metadata": {
"id": "aae0701b-111f-49c1-9000-abd37a442f28",
"publisherId": "WallabyJs.quokka-vscode",
"publisherDisplayName": "WallabyJs"
},
"name": "quokka-vscode",
"publisher": "WallabyJs",
"version": "1.0.294"
},
{
"metadata": {
"id": "d879ccb5-cbdb-45a1-bd74-5641ad0062df",
"publisherId": "Hridoy.rails-snippets",
"publisherDisplayName": "Hridoy"
},
"name": "rails-snippets",
"publisher": "Hridoy",
"version": "1.0.8"
},
{
"metadata": {
"id": "c73ec1f3-284f-426b-8a2c-78ce20ab9e3f",
"publisherId": "Vense.rails-snippets",
"publisherDisplayName": "Vense"
},
"name": "rails-snippets",
"publisher": "Vense",
"version": "0.5.0"
},
{
"metadata": {
"id": "5d031c29-7a75-4f87-854b-5c3e679bff80",
"publisherId": "urbantrout.refactor-css",
"publisherDisplayName": "urbantrout"
},
"name": "refactor-css",
"publisher": "urbantrout",
"version": "0.4.2"
},
{
"metadata": {
"id": "7ed7bccd-f358-4c6f-88c0-1296185abaa1",
"publisherId": "chrmarti.regex",
"publisherDisplayName": "chrmarti"
},
"name": "regex",
"publisher": "chrmarti",
"version": "0.2.0"
},
{
"metadata": {
"id": "dda49fd5-1f3b-4d25-bf61-4fc41905ede5",
"publisherId": "humao.rest-client",
"publisherDisplayName": "humao"
},
"name": "rest-client",
"publisher": "humao",
"version": "0.24.4"
},
{
"metadata": {
"id": "b24a13f5-4e50-4d9a-ab0a-87f47d9fdfcb",
"publisherId": "stkb.rewrap",
"publisherDisplayName": "stkb"
},
"name": "rewrap",
"publisher": "stkb",
"version": "1.14.0"
},
{
"metadata": {
"id": "ae062c8a-c68e-4b92-9ecf-8f1d4288b05d",
"publisherId": "rebornix.ruby",
"publisherDisplayName": "rebornix"
},
"name": "ruby",
"publisher": "rebornix",
"version": "0.28.1"
},
{
"metadata": {
"id": "466468c3-1861-4ad1-bf3e-f9ad46545ebb",
"publisherId": "syler.sass-indented",
"publisherDisplayName": "syler"
},
"name": "sass-indented",
"publisher": "syler",
"version": "1.8.16"
},
{
"metadata": {
"id": "858da2eb-7042-4bfc-88f0-f3df36119baa",
"publisherId": "joloyonaha.scss-bem-support",
"publisherDisplayName": "joloyonaha"
},
"name": "scss-bem-support",
"publisher": "joloyonaha",
"version": "0.0.6"
},
{
"metadata": {
"id": "f8b5562e-a2d9-49ab-9f91-e7da91998a92",
"publisherId": "shinnn.stylelint",
"publisherDisplayName": "shinnn"
},
"name": "stylelint",
"publisher": "shinnn",
"version": "0.51.0"
},
{
"metadata": {
"id": "905ce110-dab5-4222-946d-b79642fcdec5",
"publisherId": "pivaszbs.svelte-autoimport",
"publisherDisplayName": "pivaszbs"
},
"name": "svelte-autoimport",
"publisher": "pivaszbs",
"version": "1.0.4"
},
{
"metadata": {
"id": "7a59fd8d-5ded-4506-b0f7-e00301c56865",
"publisherId": "proverbialninja.svelte-extractor",
"publisherDisplayName": "proverbialninja"
},
"name": "svelte-extractor",
"publisher": "proverbialninja",
"version": "0.0.3"
},
{
"metadata": {
"id": "ba2d692e-ab31-4861-8b19-e37fc1f859ed",
"publisherId": "ardenivanov.svelte-intellisense",
"publisherDisplayName": "ardenivanov"
},
"name": "svelte-intellisense",
"publisher": "ardenivanov",
"version": "0.7.1"
},
{
"metadata": {
"id": "c5463f77-75d9-4a25-8cc4-d8541a461285",
"publisherId": "svelte.svelte-vscode",
"publisherDisplayName": "svelte"
},
"name": "svelte-vscode",
"publisher": "svelte",
"version": "104.9.1"
},
{
"metadata": {
"id": "7da76c5d-e828-41be-a5b6-e7e48106c2a8",
"publisherId": "chrisbreiding.test-utils",
"publisherDisplayName": "chrisbreiding"
},
"name": "test-utils",
"publisher": "chrisbreiding",
"version": "1.0.2"
},
{
"metadata": {
"id": "6ad45f5a-09ec-44e5-b363-867ddc1ec674",
"publisherId": "shardulm94.trailing-spaces",
"publisherDisplayName": "shardulm94"
},
"name": "trailing-spaces",
"publisher": "shardulm94",
"version": "0.3.1"
},
{
"metadata": {
"id": "6bc1e3ad-c0e2-46b6-bbad-246c5f59215b",
"publisherId": "pmneo.tsimporter",
"publisherDisplayName": "pmneo"
},
"name": "tsimporter",
"publisher": "pmneo",
"version": "2.0.1"
},
{
"metadata": {
"id": "6623619a-676d-4cde-943f-a3c193b44fc0",
"publisherId": "ChakrounAnas.turbo-console-log",
"publisherDisplayName": "ChakrounAnas"
},
"name": "turbo-console-log",
"publisher": "ChakrounAnas",
"version": "2.1.3"
},
{
"metadata": {
"id": "71a89264-6924-42d2-87f4-5429f031ab05",
"publisherId": "tgreen7.vs-code-node-require",
"publisherDisplayName": "tgreen7"
},
"name": "vs-code-node-require",
"publisher": "tgreen7",
"version": "1.4.7"
},
{
"metadata": {
"id": "75815b09-4ae2-49db-80e4-d7ed9c612eba",
"publisherId": "gluons.vscode-atom-javascript-snippet",
"publisherDisplayName": "gluons"
},
"name": "vscode-atom-javascript-snippet",
"publisher": "gluons",
"version": "0.2.1"
},
{
"metadata": {
"id": "37d7747f-e652-4eac-83de-f2939f7e2121",
"publisherId": "anseki.vscode-color",
"publisherDisplayName": "anseki"
},
"name": "vscode-color",
"publisher": "anseki",
"version": "0.4.5"
},
{
"metadata": {
"id": "0b8f8d63-11a2-4194-969c-ca7488b3413a",
"publisherId": "pranaygp.vscode-css-peek",
"publisherDisplayName": "pranaygp"
},
"name": "vscode-css-peek",
"publisher": "pranaygp",
"version": "4.1.3"
},
{
"metadata": {
"id": "b12981ce-d25d-4220-a458-2dd70369abab",
"publisherId": "Shelex.vscode-cy-helper",
"publisherDisplayName": "Shelex"
},
"name": "vscode-cy-helper",
"publisher": "Shelex",
"version": "1.2.2"
},
{
"metadata": {
"id": "4b41a5a8-170e-4156-b2c0-10efb270abbc",
"publisherId": "batisteo.vscode-django",
"publisherDisplayName": "batisteo"
},
"name": "vscode-django",
"publisher": "batisteo",
"version": "1.6.0"
},
{
"metadata": {
"id": "583b2b34-2c1e-4634-8c0b-0b82e283ea3a",
"publisherId": "dbaeumer.vscode-eslint",
"publisherDisplayName": "dbaeumer"
},
"name": "vscode-eslint",
"publisher": "dbaeumer",
"version": "2.1.8"
},
{
"metadata": {
"id": "06986be2-5abf-4d35-b0ab-8858e2dedeb0",
"publisherId": "robertoachar.vscode-essentials-snippets",
"publisherDisplayName": "robertoachar"
},
"name": "vscode-essentials-snippets",
"publisher": "robertoachar",
"version": "2.0.0"
},
{
"metadata": {
"id": "c727ab43-8d12-4f26-9648-f1d91035c9b6",
"publisherId": "NuclleaR.vscode-extension-auto-import",
"publisherDisplayName": "NuclleaR"
},
"name": "vscode-extension-auto-import",
"publisher": "NuclleaR",
"version": "1.4.3"
},
{
"metadata": {
"id": "99279c0a-5f4b-48b8-8207-e1731428d584",
"publisherId": "tnrich.vscode-extension-open-cypress",
"publisherDisplayName": "tnrich"
},
"name": "vscode-extension-open-cypress",
"publisher": "tnrich",
"version": "0.0.10"
},
{
"metadata": {
"id": "c5f4d87f-a524-462c-ac01-923eb19cf3e9",
"publisherId": "firefox-devtools.vscode-firefox-debug",
"publisherDisplayName": "firefox-devtools"
},
"name": "vscode-firefox-debug",
"publisher": "firefox-devtools",
"version": "2.9.3"
},
{
"metadata": {
"id": "aaee577c-f062-495a-9816-0cbd442f1d25",
"publisherId": "ecmel.vscode-html-css",
"publisherDisplayName": "ecmel"
},
"name": "vscode-html-css",
"publisher": "ecmel",
"version": "1.9.1"
},
{
"metadata": {
"id": "c46b0018-f317-4b6c-a785-d2039b27338f",
"publisherId": "wix.vscode-import-cost",
"publisherDisplayName": "wix"
},
"name": "vscode-import-cost",
"publisher": "wix",
"version": "2.15.0"
},
{
"metadata": {
"id": "3a1fe682-5a7a-4953-9ba9-77529a973d04",
"publisherId": "sburg.vscode-javascript-booster",
"publisherDisplayName": "sburg"
},
"name": "vscode-javascript-booster",
"publisher": "sburg",
"version": "0.12.3"
},
{
"metadata": {
"id": "03b20f74-9504-4130-a12f-af9808985b37",
"publisherId": "Rubymaniac.vscode-paste-and-indent",
"publisherDisplayName": "Rubymaniac"
},
"name": "vscode-paste-and-indent",
"publisher": "Rubymaniac",
"version": "0.0.8"
},
{
"metadata": {
"id": "b200e7e8-4217-4da9-b8db-5606db56d867",
"publisherId": "ckolkman.vscode-postgres",
"publisherDisplayName": "ckolkman"
},
"name": "vscode-postgres",
"publisher": "ckolkman",
"version": "1.1.17"
},
{
"metadata": {
"id": "364d2426-116a-433a-a5d8-a5098dc3afbd",
"publisherId": "ms-python.vscode-pylance",
"publisherDisplayName": "ms-python"
},
"name": "vscode-pylance",
"publisher": "ms-python",
"version": "2021.4.1"
},
{
"metadata": {
"id": "708cfcd8-e0c6-49ca-9af6-b27a342d247b",
"publisherId": "wingrunr21.vscode-ruby",
"publisherDisplayName": "wingrunr21"
},
"name": "vscode-ruby",
"publisher": "wingrunr21",
"version": "0.28.0"
},
{
"metadata": {
"id": "beb68b20-7c55-471c-9b63-3486f9423566",
"publisherId": "mrmlnc.vscode-scss",
"publisherDisplayName": "mrmlnc"
},
"name": "vscode-scss",
"publisher": "mrmlnc",
"version": "0.9.1"
},
{
"metadata": {
"id": "28fcf0b8-26a5-4e99-9b8d-02e990366c6f",
"publisherId": "tombonnike.vscode-status-bar-format-toggle",
"publisherDisplayName": "tombonnike"
},
"name": "vscode-status-bar-format-toggle",
"publisher": "tombonnike",
"version": "2.0.0"
},
{
"metadata": {
"id": "a42d3dd1-f528-407c-a110-d5e35c7ca4c2",
"publisherId": "fivethree.vscode-svelte-snippets",
"publisherDisplayName": "fivethree"
},
"name": "vscode-svelte-snippets",
"publisher": "fivethree",
"version": "0.5.0"
},
{
"metadata": {
"id": "2fd56207-78ef-49d4-95d2-9b801eee4dbf",
"publisherId": "rangav.vscode-thunder-client",
"publisherDisplayName": "rangav"
},
"name": "vscode-thunder-client",
"publisher": "rangav",
"version": "1.2.2"
},
{
"metadata": {
"id": "2061917f-f76a-458a-8da9-f162de22b97e",
"publisherId": "redhat.vscode-yaml",
"publisherDisplayName": "redhat"
},
"name": "vscode-yaml",
"publisher": "redhat",
"version": "0.17.0"
},
{
"metadata": {
"id": "876e8f93-74d0-4f4f-91b7-34a09f19f444",
"publisherId": "VisualStudioExptTeam.vscodeintellicode",
"publisherDisplayName": "VisualStudioExptTeam"
},
"name": "vscodeintellicode",
"publisher": "VisualStudioExptTeam",
"version": "1.2.12"
}
]
// Place your key bindings in this file to override the defaultsauto[]
[
{
"key": "ctrl+shift+t",
"command": "-workbench.action.reopenClosedEditor"
},
{
"key": "ctrl+0",
"command": "workbench.action.terminal.toggleTerminal"
},
{
"key": "ctrl+shift+[Equal]",
"command": "editor.togglequotes"
},
{
"key": "ctrl+shift+1",
"command": "-editor.togglequotes"
},
{
"key": "ctrl+0",
"command": "-workbench.action.focusSideBar"
}
]
{
"workbench.startupEditor": "newUntitledFile",
"window.titleBarStyle": "custom",
"workbench.colorCustomizations": {
"window.activeBorder": "#393c4b",
"window.inactiveBorder": "#151712"
},
"gitlens.views.repositories.location": "gitlens",
"gitlens.views.fileHistory.location": "gitlens",
"gitlens.views.lineHistory.location": "gitlens",
"gitlens.views.compare.location": "gitlens",
"gitlens.views.search.location": "gitlens",
"telemetry.enableCrashReporter": false,
"editor.fontFamily": "\"JetBrainsMono Nerd Font\"",
"editor.wordWrap": "on",
"vetur.validation.template": false,
"vetur.completion.scaffoldSnippetSources": {
"workspace": "💼",
"user": "🗒️",
"vetur": ""
},
"auto-close-tag.enableAutoCloseTag": true,
"auto-close-tag.enableAutoCloseSelfClosingTag": true,
"auto-close-tag.activationOnLanguage": [
"xml",
"html",
"php",
"blade",
"ejs",
"jinja",
"javascript",
"javascriptreact",
"typescript",
"typescriptreact",
"plaintext",
"markdown",
"vue",
"liquid",
"erb",
"lang-cfml",
"cfml",
"HTML (Eex)"
],
"editor.formatOnPaste": true,
"editor.formatOnSave": true,
"editor.formatOnType": true,
"emmet.includeLanguages": {
// "javascript": "javascriptreact",
"erb": "html",
"liquid": "html",
"vue-html": "html",
"scss": "scss"
// "typescript": "typescriptreact"
},
"emmet.excludeLanguages": ["javascript"],
"quokka.suppressExpirationNotifications": true,
"editor.tabCompletion": "on",
"editor.tabSize": 2,
"editor.fontLigatures": true,
"files.associations": {
"*.tidal": "haskell"
},
"cSpell.enableFiletypes": [
"asciidoc",
"c",
"cpp",
"csharp",
"css",
"git-commit",
"go",
"handlebars",
"haskell",
"html",
"jade",
"java",
"javascript",
"javascriptreact",
"json",
"jsonc",
"latex",
"less",
"markdown",
"php",
"plaintext",
"pug",
"python",
"restructuredtext",
"rust",
"scala",
"scss",
"sql",
"text",
"typescript",
"typescriptreact",
"vue",
"yaml",
"yml"
],
"editor.quickSuggestions": {
"strings": true
},
"liveServer.settings.donotShowInfoMsg": true,
"liveServer.settings.AdvanceCustomBrowserCmdLine": "brave --remote-debugging-port=5500",
"editor.wordWrapColumn": 60,
"editor.renderWhitespace": "none",
"editor.minimap.maxColumn": 240,
"svelte.language-server.runtime": "/usr/bin/node",
"vueStyle.formatOnSave": true,
"[jsonc]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"editor.suggestSelection": "first",
"vsintellicode.modify.editor.suggestSelection": "choseToUpdateConfiguration",
"sync.gist": "7a5c6a2e709d577a89251bec626a9fa5",
"editor.smoothScrolling": true,
"smoothtype.autoReload": true,
"window.menuBarVisibility": "toggle",
"indentRainbow.colors": [
"rgba(16,16,16,0.1)",
"rgba(16,16,16,0.3)",
"rgba(16,16,16,0.6)",
"rgba(16,16,16,0.4)",
"rgba(16,16,16,0.2)"
],
"editor.minimap.scale": 2,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"vim.easymotion": true,
"vim.incsearch": true,
"vim.useSystemClipboard": true,
"vim.useCtrlKeys": true,
"vim.hlsearch": true,
"workbench.iconTheme": "city-lights-icons-vsc",
"sqltools.useNodeRuntime": true,
"eslint.run": "onSave",
"window.zoomLevel": 0,
"editor.fontSize": 16,
"python.jediEnabled": false,
"dart.flutterSdkPath": "/home/adalbertsen/flutter",
"lua.preferLuaCheckErrors": true,
"ruby.rubocop.executePath": "/home/adalbertsen/.gem/ruby/2.7.0/bin/rubocop/",
"solargraph.commandPath": "/home/adalbertsen/.gem/ruby/2.7.0/bin/solargraph",
"ruby.rubocop.configFilePath": "/home/adalbertsen/.gem/ruby/2.7.0/gems/rubocop-0.83.0/config/default.yml",
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[html]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"editor.renameOnType": true,
"liquid.format": true,
"[markdown]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"workbench.colorTheme": "Gruvbox Dark (Hard)",
"python.languageServer": "Microsoft",
"[svelte]": {
"editor.defaultFormatter": "svelte.svelte-vscode"
}
}
{
// Place your snippets for javascript here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
// same ids are connected.
// Example:
// "Print to console": {
// "prefix": "log",
// "body": [
// "console.log('$1');",
// "$2"
// ],
// "description": "Log output to console"
// }
}
{
"all": {
"prefix": "30s_all",
"body": [
"const all = (arr, fn = Boolean) => arr.every(fn);"
],
"description": "Returns `true` if the provided predicate function returns `true` for all elements in a collection, `false` otherwise.\n\nUse `Array.prototype.every()` to test if all elements in the collection return `true` based on `fn`.\nOmit the second argument, `fn`, to use `Boolean` as a default.\n"
},
"allEqual": {
"prefix": "30s_allEqual",
"body": [
"const allEqual = arr => arr.every(val => val === arr[0]);"
],
"description": "Check if all elements in an array are equal.\n\nUse `Array.prototype.every()` to check if all the elements of the array are the same as the first one.\nElements in the array are compared using the strict comparison operator, which does not account for `NaN` self-inequality.\n"
},
"any": {
"prefix": "30s_any",
"body": [
"const any = (arr, fn = Boolean) => arr.some(fn);"
],
"description": "Returns `true` if the provided predicate function returns `true` for at least one element in a collection, `false` otherwise.\n\nUse `Array.prototype.some()` to test if any elements in the collection return `true` based on `fn`.\nOmit the second argument, `fn`, to use `Boolean` as a default.\n"
},
"approximatelyEqual": {
"prefix": "30s_approximatelyEqual",
"body": [
"const approximatelyEqual = (v1, v2, epsilon = 0.001) => Math.abs(v1 - v2) < epsilon;"
],
"description": "Checks if two numbers are approximately equal to each other.\n\nUse `Math.abs()` to compare the absolute difference of the two values to `epsilon`.\nOmit the third parameter, `epsilon`, to use a default value of `0.001`.\n"
},
"arrayToCSV": {
"prefix": "30s_arrayToCSV",
"body": [
"const arrayToCSV = (arr, delimiter = ',') =>",
" arr",
" .map(v => v.map(x => (isNaN(x) ? `\"${x.replace(/\"/g, '\"\"')}\"` : x)).join(delimiter))",
" .join('\\n');"
],
"description": "Converts a 2D array to a comma-separated values (CSV) string.\n\nUse `Array.prototype.map()` and `Array.prototype.join(delimiter)` to combine individual 1D arrays (rows) into strings.\nUse `Array.prototype.join('\\n')` to combine all rows into a CSV string, separating each row with a newline.\nOmit the second argument, `delimiter`, to use a default delimiter of `,`.\n"
},
"arrayToHtmlList": {
"prefix": "30s_arrayToHtmlList",
"body": [
"const arrayToHtmlList = (arr, listID) =>",
" (el => (",
" (el = document.querySelector('#' + listID)),",
" (el.innerHTML += arr.map(item => `<li>${item}</li>`).join(''))",
" ))();"
],
"description": "Converts the given array elements into `<li>` tags and appends them to the list of the given id.\n\nUse `Array.prototype.map()`, `document.querySelector()`, and an anonymous inner closure to create a list of html tags.\n"
},
"ary": {
"prefix": "30s_ary",
"body": [
"const ary = (fn, n) => (...args) => fn(...args.slice(0, n));"
],
"description": "Creates a function that accepts up to `n` arguments, ignoring any additional arguments.\n\nCall the provided function, `fn`, with up to `n` arguments, using `Array.prototype.slice(0,n)` and the spread operator (`...`).\n"
},
"atob": {
"prefix": "30s_atob",
"body": [
"const atob = str => Buffer.from(str, 'base64').toString('binary');"
],
"description": "Decodes a string of data which has been encoded using base-64 encoding.\n\nCreate a `Buffer` for the given string with base-64 encoding and use `Buffer.toString('binary')` to return the decoded string.\n"
},
"attempt": {
"prefix": "30s_attempt",
"body": [
"const attempt = (fn, ...args) => {",
" try {",
" return fn(...args);",
" } catch (e) {",
" return e instanceof Error ? e : new Error(e);",
" }",
"};"
],
"description": "Attempts to invoke a function with the provided arguments, returning either the result or the caught error object.\n\nUse a `try... catch` block to return either the result of the function or an appropriate error.\n"
},
"average": {
"prefix": "30s_average",
"body": [
"const average = (...nums) => nums.reduce((acc, val) => acc + val, 0) / nums.length;"
],
"description": "Returns the average of two or more numbers.\n\nUse `Array.prototype.reduce()` to add each value to an accumulator, initialized with a value of `0`, divide by the `length` of the array.\n"
},
"averageBy": {
"prefix": "30s_averageBy",
"body": [
"const averageBy = (arr, fn) =>",
" arr.map(typeof fn === 'function' ? fn : val => val[fn]).reduce((acc, val) => acc + val, 0) /",
" arr.length;"
],
"description": "Returns the average of an array, after mapping each element to a value using the provided function.\n\nUse `Array.prototype.map()` to map each element to the value returned by `fn`, `Array.prototype.reduce()` to add each value to an accumulator, initialized with a value of `0`, divide by the `length` of the array.\n"
},
"bifurcate": {
"prefix": "30s_bifurcate",
"body": [
"const bifurcate = (arr, filter) =>",
" arr.reduce((acc, val, i) => (acc[filter[i] ? 0 : 1].push(val), acc), [[], []]);"
],
"description": "Splits values into two groups. If an element in `filter` is truthy, the corresponding element in the collection belongs to the first group; otherwise, it belongs to the second group.\n\nUse `Array.prototype.reduce()` and `Array.prototype.push()` to add elements to groups, based on `filter`.\n"
},
"bifurcateBy": {
"prefix": "30s_bifurcateBy",
"body": [
"const bifurcateBy = (arr, fn) =>",
" arr.reduce((acc, val, i) => (acc[fn(val, i) ? 0 : 1].push(val), acc), [[], []]);"
],
"description": "Splits values into two groups according to a predicate function, which specifies which group an element in the input collection belongs to. If the predicate function returns a truthy value, the collection element belongs to the first group; otherwise, it belongs to the second group.\n\nUse `Array.prototype.reduce()` and `Array.prototype.push()` to add elements to groups, based on the value returned by `fn` for each element.\n"
},
"bind": {
"prefix": "30s_bind",
"body": [
"const bind = (fn, context, ...boundArgs) => (...args) => fn.apply(context, [...boundArgs, ...args]);"
],
"description": "Creates a function that invokes `fn` with a given context, optionally adding any additional supplied parameters to the beginning of the arguments.\n\nReturn a `function` that uses `Function.prototype.apply()` to apply the given `context` to `fn`.\nUse `Array.prototype.concat()` to prepend any additional supplied parameters to the arguments.\n"
},
"bindAll": {
"prefix": "30s_bindAll",
"body": [
"const bindAll = (obj, ...fns) =>",
" fns.forEach(",
" fn => (",
" (f = obj[fn]),",
" (obj[fn] = function() {",
" return f.apply(obj);",
" })",
" )",
" );"
],
"description": "Binds methods of an object to the object itself, overwriting the existing method.\n\nUse `Array.prototype.forEach()` to return a `function` that uses `Function.prototype.apply()` to apply the given context (`obj`) to `fn` for each function specified.\n"
},
"bindKey": {
"prefix": "30s_bindKey",
"body": [
"const bindKey = (context, fn, ...boundArgs) => (...args) =>",
" context[fn].apply(context, [...boundArgs, ...args]);"
],
"description": "Creates a function that invokes the method at a given key of an object, optionally adding any additional supplied parameters to the beginning of the arguments.\n\nReturn a `function` that uses `Function.prototype.apply()` to bind `context[fn]` to `context`.\nUse the spread operator (`...`) to prepend any additional supplied parameters to the arguments.\n"
},
"binomialCoefficient": {
"prefix": "30s_binomialCoefficient",
"body": [
"const binomialCoefficient = (n, k) => {",
" if (Number.isNaN(n) || Number.isNaN(k)) return NaN;",
" if (k < 0 || k > n) return 0;",
" if (k === 0 || k === n) return 1;",
" if (k === 1 || k === n - 1) return n;",
" if (n - k < k) k = n - k;",
" let res = n;",
" for (let j = 2; j <= k; j++) res *= (n - j + 1) / j;",
" return Math.round(res);",
"};"
],
"description": "Evaluates the binomial coefficient of two integers `n` and `k`.\n\nUse `Number.isNaN()` to check if any of the two values is `NaN`.\nCheck if `k` is less than `0`, greater than or equal to `n`, equal to `1` or `n - 1` and return the appropriate result.\nCheck if `n - k` is less than `k` and switch their values accordingly.\nLoop from `2` through `k` and calculate the binomial coefficient.\nUse `Math.round()` to account for rounding errors in the calculation.\n"
},
"bottomVisible": {
"prefix": "30s_bottomVisible",
"body": [
"const bottomVisible = () =>",
" document.documentElement.clientHeight + window.scrollY >=",
" (document.documentElement.scrollHeight || document.documentElement.clientHeight);"
],
"description": "Returns `true` if the bottom of the page is visible, `false` otherwise.\n\nUse `scrollY`, `scrollHeight` and `clientHeight` to determine if the bottom of the page is visible.\n"
},
"btoa": {
"prefix": "30s_btoa",
"body": [
"const btoa = str => Buffer.from(str, 'binary').toString('base64');"
],
"description": "Creates a base-64 encoded ASCII string from a String object in which each character in the string is treated as a byte of binary data.\n\nCreate a `Buffer` for the given string with binary encoding and use `Buffer.toString('base64')` to return the encoded string.\n"
},
"byteSize": {
"prefix": "30s_byteSize",
"body": [
"const byteSize = str => new Blob([str]).size;"
],
"description": "Returns the length of a string in bytes.\n\nConvert a given string to a [`Blob` Object](https://developer.mozilla.org/en-US/docs/Web/API/Blob) and find its `size`.\n"
},
"call": {
"prefix": "30s_call",
"body": [
"const call = (key, ...args) => context => context[key](...args);"
],
"description": "Given a key and a set of arguments, call them when given a context. Primarily useful in composition.\n\nUse a closure to call a stored key with stored arguments.\n"
},
"capitalize": {
"prefix": "30s_capitalize",
"body": [
"const capitalize = ([first, ...rest], lowerRest = false) =>",
" first.toUpperCase() + (lowerRest ? rest.join('').toLowerCase() : rest.join(''));"
],
"description": "Capitalizes the first letter of a string.\n\nUse array destructuring and `String.prototype.toUpperCase()` to capitalize first letter, `...rest` to get array of characters after first letter and then `Array.prototype.join('')` to make it a string again.\nOmit the `lowerRest` parameter to keep the rest of the string intact, or set it to `true` to convert to lowercase.\n"
},
"capitalizeEveryWord": {
"prefix": "30s_capitalizeEveryWord",
"body": [
"const capitalizeEveryWord = str => str.replace(/\\b[a-z]/g, char => char.toUpperCase());"
],
"description": "Capitalizes the first letter of every word in a string.\n\nUse `String.prototype.replace()` to match the first character of each word and `String.prototype.toUpperCase()` to capitalize it.\n"
},
"castArray": {
"prefix": "30s_castArray",
"body": [
"const castArray = val => (Array.isArray(val) ? val : [val]);"
],
"description": "Casts the provided value as an array if it's not one.\n\nUse `Array.prototype.isArray()` to determine if `val` is an array and return it as-is or encapsulated in an array accordingly.\n"
},
"chainAsync": {
"prefix": "30s_chainAsync",
"body": [
"const chainAsync = fns => {",
" let curr = 0;",
" const last = fns[fns.length - 1];",
" const next = () => {",
" const fn = fns[curr++];",
" fn === last ? fn() : fn(next);",
" };",
" next();",
"};"
],
"description": "Chains asynchronous functions.\n\nLoop through an array of functions containing asynchronous events, calling `next` when each asynchronous event has completed.\n"
},
"checkProp": {
"prefix": "30s_checkProp",
"body": [
"const checkProp = (predicate, prop) => obj => !!predicate(obj[prop]);"
],
"description": "Given a `predicate` function and a `prop` string, this curried function will then take an `object` to inspect by calling the property and passing it to the predicate.\n\nSummon `prop` on `obj`, pass it to a provided `predicate` function and return a masked boolean.\n"
},
"chunk": {
"prefix": "30s_chunk",
"body": [
"const chunk = (arr, size) =>",
" Array.from({ length: Math.ceil(arr.length / size) }, (v, i) =>",
" arr.slice(i * size, i * size + size)",
" );"
],
"description": "Chunks an array into smaller arrays of a specified size.\n\nUse `Array.from()` to create a new array, that fits the number of chunks that will be produced.\nUse `Array.prototype.slice()` to map each element of the new array to a chunk the length of `size`.\nIf the original array can't be split evenly, the final chunk will contain the remaining elements.\n"
},
"clampNumber": {
"prefix": "30s_clampNumber",
"body": [
"const clampNumber = (num, a, b) => Math.max(Math.min(num, Math.max(a, b)), Math.min(a, b));"
],
"description": "Clamps `num` within the inclusive range specified by the boundary values `a` and `b`.\n\nIf `num` falls within the range, return `num`.\nOtherwise, return the nearest number in the range.\n"
},
"cloneRegExp": {
"prefix": "30s_cloneRegExp",
"body": [
"const cloneRegExp = regExp => new RegExp(regExp.source, regExp.flags);"
],
"description": "Clones a regular expression.\n\nUse `new RegExp()`, `RegExp.source` and `RegExp.flags` to clone the given regular expression.\n"
},
"coalesce": {
"prefix": "30s_coalesce",
"body": [
"const coalesce = (...args) => args.find(_ => ![undefined, null].includes(_));"
],
"description": "Returns the first non-null/undefined argument.\n\nUse `Array.prototype.find()` to return the first non `null`/`undefined` argument.\n"
},
"coalesceFactory": {
"prefix": "30s_coalesceFactory",
"body": [
"const coalesceFactory = valid => (...args) => args.find(valid);"
],
"description": "Returns a customized coalesce function that returns the first argument that returns `true` from the provided argument validation function.\n\nUse `Array.prototype.find()` to return the first argument that returns `true` from the provided argument validation function.\n"
},
"collectInto": {
"prefix": "30s_collectInto",
"body": [
"const collectInto = fn => (...args) => fn(args);"
],
"description": "Changes a function that accepts an array into a variadic function.\n\nGiven a function, return a closure that collects all inputs into an array-accepting function.\n"
},
"colorize": {
"prefix": "30s_colorize",
"body": [
"const colorize = (...args) => ({",
" black: `\\x1b[30m${args.join(' ')}`,",
" red: `\\x1b[31m${args.join(' ')}`,",
" green: `\\x1b[32m${args.join(' ')}`,",
" yellow: `\\x1b[33m${args.join(' ')}`,",
" blue: `\\x1b[34m${args.join(' ')}`,",
" magenta: `\\x1b[35m${args.join(' ')}`,",
" cyan: `\\x1b[36m${args.join(' ')}`,",
" white: `\\x1b[37m${args.join(' ')}`,",
" bgBlack: `\\x1b[40m${args.join(' ')}\\x1b[0m`,",
" bgRed: `\\x1b[41m${args.join(' ')}\\x1b[0m`,",
" bgGreen: `\\x1b[42m${args.join(' ')}\\x1b[0m`,",
" bgYellow: `\\x1b[43m${args.join(' ')}\\x1b[0m`,",
" bgBlue: `\\x1b[44m${args.join(' ')}\\x1b[0m`,",
" bgMagenta: `\\x1b[45m${args.join(' ')}\\x1b[0m`,",
" bgCyan: `\\x1b[46m${args.join(' ')}\\x1b[0m`,",
" bgWhite: `\\x1b[47m${args.join(' ')}\\x1b[0m`",
"});"
],
"description": "Add special characters to text to print in color in the console (combined with `console.log()`).\n\nUse template literals and special characters to add the appropriate color code to the string output.\nFor background colors, add a special character that resets the background color at the end of the string.\n"
},
"compact": {
"prefix": "30s_compact",
"body": [
"const compact = arr => arr.filter(Boolean);"
],
"description": "Removes falsy values from an array.\n\nUse `Array.prototype.filter()` to filter out falsy values (`false`, `null`, `0`, `\"\"`, `undefined`, and `NaN`).\n"
},
"compactWhitespace": {
"prefix": "30s_compactWhitespace",
"body": [
"const compactWhitespace = str => str.replace(/\\s{2,}/g, ' ');"
],
"description": "Returns a string with whitespaces compacted.\n\nUse `String.prototype.replace()` with a regular expression to replace all occurrences of 2 or more whitespace characters with a single space.\n"
},
"compose": {
"prefix": "30s_compose",
"body": [
"const compose = (...fns) => fns.reduce((f, g) => (...args) => f(g(...args)));"
],
"description": "Performs right-to-left function composition.\n\nUse `Array.prototype.reduce()` to perform right-to-left function composition.\nThe last (rightmost) function can accept one or more arguments; the remaining functions must be unary.\n"
},
"composeRight": {
"prefix": "30s_composeRight",
"body": [
"const composeRight = (...fns) => fns.reduce((f, g) => (...args) => g(f(...args)));"
],
"description": "Performs left-to-right function composition.\n\nUse `Array.prototype.reduce()` to perform left-to-right function composition.\nThe first (leftmost) function can accept one or more arguments; the remaining functions must be unary.\n"
},
"converge": {
"prefix": "30s_converge",
"body": [
"const converge = (converger, fns) => (...args) => converger(...fns.map(fn => fn.apply(null, args)));"
],
"description": "Accepts a converging function and a list of branching functions and returns a function that applies each branching function to the arguments and the results of the branching functions are passed as arguments to the converging function.\n\nUse `Array.prototype.map()` and `Function.prototype.apply()` to apply each function to the given arguments.\nUse the spread operator (`...`) to call `coverger` with the results of all other functions.\n"
},
"copyToClipboard": {
"prefix": "30s_copyToClipboard",
"body": [
"const copyToClipboard = str => {",
" const el = document.createElement('textarea');",
" el.value = str;",
" el.setAttribute('readonly', '');",
" el.style.position = 'absolute';",
" el.style.left = '-9999px';",
" document.body.appendChild(el);",
" const selected =",
" document.getSelection().rangeCount > 0 ? document.getSelection().getRangeAt(0) : false;",
" el.select();",
" document.execCommand('copy');",
" document.body.removeChild(el);",
" if (selected) {",
" document.getSelection().removeAllRanges();",
" document.getSelection().addRange(selected);",
" }",
"};"
],
"description": "⚠️ **NOTICE:** The same functionality can be easily implemented by using the new asynchronous Clipboard API, which is still experimental but should be used in the future instead of this snippet. Find out more about it [here](https://github.com/w3c/clipboard-apis/blob/master/explainer.adoc#writing-to-the-clipboard).\n\nCopy a string to the clipboard. \nOnly works as a result of user action (i.e. inside a `click` event listener).\n\nCreate a new `<textarea>` element, fill it with the supplied data and add it to the HTML document.\nUse `Selection.getRangeAt()`to store the selected range (if any).\nUse `document.execCommand('copy')` to copy to the clipboard.\nRemove the `<textarea>` element from the HTML document.\nFinally, use `Selection().addRange()` to recover the original selected range (if any).\n"
},
"countBy": {
"prefix": "30s_countBy",
"body": [
"const countBy = (arr, fn) =>",
" arr.map(typeof fn === 'function' ? fn : val => val[fn]).reduce((acc, val) => {",
" acc[val] = (acc[val] || 0) + 1;",
" return acc;",
" }, {});"
],
"description": "Groups the elements of an array based on the given function and returns the count of elements in each group.\n\nUse `Array.prototype.map()` to map the values of an array to a function or property name.\nUse `Array.prototype.reduce()` to create an object, where the keys are produced from the mapped results.\n"
},
"counter": {
"prefix": "30s_counter",
"body": [
"const counter = (selector, start, end, step = 1, duration = 2000) => {",
" let current = start,",
" _step = (end - start) * step < 0 ? -step : step,",
" timer = setInterval(() => {",
" current += _step;",
" document.querySelector(selector).innerHTML = current;",
" if (current >= end) document.querySelector(selector).innerHTML = end;",
" if (current >= end) clearInterval(timer);",
" }, Math.abs(Math.floor(duration / (end - start))));",
" return timer;",
"};"
],
"description": "Creates a counter with the specified range, step and duration for the specified selector.\n\nCheck if `step` has the proper sign and change it accordingly.\nUse `setInterval()` in combination with `Math.abs()` and `Math.floor()` to calculate the time between each new text draw.\nUse `document.querySelector().innerHTML` to update the value of the selected element.\nOmit the fourth parameter, `step`, to use a default step of `1`.\nOmit the fifth parameter, `duration`, to use a default duration of `2000`ms.\n"
},
"countOccurrences": {
"prefix": "30s_countOccurrences",
"body": [
"const countOccurrences = (arr, val) => arr.reduce((a, v) => (v === val ? a + 1 : a), 0);"
],
"description": "Counts the occurrences of a value in an array.\n\nUse `Array.prototype.reduce()` to increment a counter each time you encounter the specific value inside the array.\n"
},
"createDirIfNotExists": {
"prefix": "30s_createDirIfNotExists",
"body": [
"const fs = require('fs');",
"const createDirIfNotExists = dir => (!fs.existsSync(dir) ? fs.mkdirSync(dir) : undefined);"
],
"description": "Creates a directory, if it does not exist.\n\nUse `fs.existsSync()` to check if the directory exists, `fs.mkdirSync()` to create it.\n"
},
"createElement": {
"prefix": "30s_createElement",
"body": [
"const createElement = str => {",
" const el = document.createElement('div');",
" el.innerHTML = str;",
" return el.firstElementChild;",
"};"
],
"description": "Creates an element from a string (without appending it to the document). \nIf the given string contains multiple elements, only the first one will be returned.\n\nUse `document.createElement()` to create a new element.\nSet its `innerHTML` to the string supplied as the argument. \nUse `ParentNode.firstElementChild` to return the element version of the string.\n"
},
"createEventHub": {
"prefix": "30s_createEventHub",
"body": [
"const createEventHub = () => ({",
" hub: Object.create(null),",
" emit(event, data) {",
" (this.hub[event] || []).forEach(handler => handler(data));",
" },",
" on(event, handler) {",
" if (!this.hub[event]) this.hub[event] = [];",
" this.hub[event].push(handler);",
" },",
" off(event, handler) {",
" const i = (this.hub[event] || []).findIndex(h => h === handler);",
" if (i > -1) this.hub[event].splice(i, 1);",
" if (this.hub[event].length === 0) delete this.hub[event];",
" }",
"});"
],
"description": "Creates a pub/sub ([publish–subscribe](https://en.wikipedia.org/wiki/Publish%E2%80%93subscribe_pattern)) event hub with `emit`, `on`, and `off` methods.\n\nUse `Object.create(null)` to create an empty `hub` object that does not inherit properties from `Object.prototype`.\nFor `emit`, resolve the array of handlers based on the `event` argument and then run each one with `Array.prototype.forEach()` by passing in the data as an argument.\nFor `on`, create an array for the event if it does not yet exist, then use `Array.prototype.push()` to add the handler\nto the array.\nFor `off`, use `Array.prototype.findIndex()` to find the index of the handler in the event array and remove it using `Array.prototype.splice()`.\n"
},
"CSVToArray": {
"prefix": "30s_CSVToArray",
"body": [
"const CSVToArray = (data, delimiter = ',', omitFirstRow = false) =>",
" data",
" .slice(omitFirstRow ? data.indexOf('\\n') + 1 : 0)",
" .split('\\n')",
" .map(v => v.split(delimiter));"
],
"description": "Converts a comma-separated values (CSV) string to a 2D array.\n\nUse `Array.prototype.slice()` and `Array.prototype.indexOf('\\n')` to remove the first row (title row) if `omitFirstRow` is `true`.\nUse `String.prototype.split('\\n')` to create a string for each row, then `String.prototype.split(delimiter)` to separate the values in each row.\nOmit the second argument, `delimiter`, to use a default delimiter of `,`.\nOmit the third argument, `omitFirstRow`, to include the first row (title row) of the CSV string.\n"
},
"CSVToJSON": {
"prefix": "30s_CSVToJSON",
"body": [
"const CSVToJSON = (data, delimiter = ',') => {",
" const titles = data.slice(0, data.indexOf('\\n')).split(delimiter);",
" return data",
" .slice(data.indexOf('\\n') + 1)",
" .split('\\n')",
" .map(v => {",
" const values = v.split(delimiter);",
" return titles.reduce((obj, title, index) => ((obj[title] = values[index]), obj), {});",
" });",
"};"
],
"description": "Converts a comma-separated values (CSV) string to a 2D array of objects.\nThe first row of the string is used as the title row.\n\nUse `Array.prototype.slice()` and `Array.prototype.indexOf('\\n')` and `String.prototype.split(delimiter)` to separate the first row (title row) into values.\nUse `String.prototype.split('\\n')` to create a string for each row, then `Array.prototype.map()` and `String.prototype.split(delimiter)` to separate the values in each row.\nUse `Array.prototype.reduce()` to create an object for each row's values, with the keys parsed from the title row.\nOmit the second argument, `delimiter`, to use a default delimiter of `,`.\n"
},
"currentURL": {
"prefix": "30s_currentURL",
"body": [
"const currentURL = () => window.location.href;"
],
"description": "Returns the current URL.\n\nUse `window.location.href` to get current URL.\n"
},
"curry": {
"prefix": "30s_curry",
"body": [
"const curry = (fn, arity = fn.length, ...args) =>",
" arity <= args.length ? fn(...args) : curry.bind(null, fn, arity, ...args);"
],
"description": "Curries a function.\n\nUse recursion.\nIf the number of provided arguments (`args`) is sufficient, call the passed function `fn`.\nOtherwise, return a curried function `fn` that expects the rest of the arguments.\nIf you want to curry a function that accepts a variable number of arguments (a variadic function, e.g. `Math.min()`), you can optionally pass the number of arguments to the second parameter `arity`.\n"
},
"dayOfYear": {
"prefix": "30s_dayOfYear",
"body": [
"const dayOfYear = date =>",
" Math.floor((date - new Date(date.getFullYear(), 0, 0)) / 1000 / 60 / 60 / 24);"
],
"description": "Gets the day of the year from a `Date` object.\n\nUse `new Date()` and `Date.prototype.getFullYear()` to get the first day of the year as a `Date` object, subtract it from the provided `date` and divide with the milliseconds in each day to get the result.\nUse `Math.floor()` to appropriately round the resulting day count to an integer.\n"
},
"debounce": {
"prefix": "30s_debounce",
"body": [
"const debounce = (fn, ms = 0) => {",
" let timeoutId;",
" return function(...args) {",
" clearTimeout(timeoutId);",
" timeoutId = setTimeout(() => fn.apply(this, args), ms);",
" };",
"};"
],
"description": "Creates a debounced function that delays invoking the provided function until at least `ms` milliseconds have elapsed since the last time it was invoked.\n\nEach time the debounced function is invoked, clear the current pending timeout with `clearTimeout()` and use `setTimeout()` to create a new timeout that delays invoking the function until at least `ms` milliseconds has elapsed. Use `Function.prototype.apply()` to apply the `this` context to the function and provide the necessary arguments.\nOmit the second argument, `ms`, to set the timeout at a default of 0 ms.\n"
},
"decapitalize": {
"prefix": "30s_decapitalize",
"body": [
"const decapitalize = ([first, ...rest], upperRest = false) =>",
" first.toLowerCase() + (upperRest ? rest.join('').toUpperCase() : rest.join(''));"
],
"description": "Decapitalizes the first letter of a string.\n\nUse array destructuring and `String.toLowerCase()` to decapitalize first letter, `...rest` to get array of characters after first letter and then `Array.prototype.join('')` to make it a string again.\nOmit the `upperRest` parameter to keep the rest of the string intact, or set it to `true` to convert to uppercase.\n"
},
"deepClone": {
"prefix": "30s_deepClone",
"body": [
"const deepClone = obj => {",
" let clone = Object.assign({}, obj);",
" Object.keys(clone).forEach(",
" key => (clone[key] = typeof obj[key] === 'object' ? deepClone(obj[key]) : obj[key])",
" );",
" return Array.isArray(obj) && obj.length",
" ? (clone.length = obj.length) && Array.from(clone)",
" : Array.isArray(obj)",
" ? Array.from(obj)",
" : clone;",
"};"
],
"description": "Creates a deep clone of an object.\n\nUse recursion.\nUse `Object.assign()` and an empty object (`{}`) to create a shallow clone of the original.\nUse `Object.keys()` and `Array.prototype.forEach()` to determine which key-value pairs need to be deep cloned.\n"
},
"deepFlatten": {
"prefix": "30s_deepFlatten",
"body": [
"const deepFlatten = arr => [].concat(...arr.map(v => (Array.isArray(v) ? deepFlatten(v) : v)));"
],
"description": "Deep flattens an array.\n\nUse recursion.\nUse `Array.prototype.concat()` with an empty array (`[]`) and the spread operator (`...`) to flatten an array.\nRecursively flatten each element that is an array.\n"
},
"deepFreeze": {
"prefix": "30s_deepFreeze",
"body": [
"const deepFreeze = obj =>",
" Object.keys(obj).forEach(prop =>",
" !(obj[prop] instanceof Object) || Object.isFrozen(obj[prop]) ? null : deepFreeze(obj[prop])",
" ) || Object.freeze(obj);"
],
"description": "Deep freezes an object.\n\nCalls `Object.freeze(obj)` recursively on all unfrozen properties of passed object that are `instanceof` object.\n"
},
"deepGet": {
"prefix": "30s_deepGet",
"body": [
"const deepGet = (obj, keys) => keys.reduce((xs, x) => (xs && xs[x] ? xs[x] : null), obj);"
],
"description": "Returns the target value in a nested JSON object, based on the `keys` array.\n\nCompare the keys you want in the nested JSON object as an `Array`.\nUse `Array.prototype.reduce()` to get value from nested JSON object one by one. \nIf the key exists in object, return target value, otherwise, return `null`.\n"
},
"deepMapKeys": {
"prefix": "30s_deepMapKeys",
"body": [
"const deepMapKeys = (obj, f) =>",
" Array.isArray(obj)",
" ? obj.map(val => deepMapKeys(val, f))",
" : typeof obj === 'object'",
" ? Object.keys(obj).reduce((acc, current) => {",
" const val = obj[current];",
" acc[f(current)] =",
" val !== null && typeof val === 'object' ? deepMapKeys(val, f) : (acc[f(current)] = val);",
" return acc;",
" }, {})",
" : obj;"
],
"description": "Deep maps an object's keys.\n\nCreates an object with the same values as the provided object and keys generated by running the provided function for each key.\nUse `Object.keys(obj)` to iterate over the object's keys. \nUse `Array.prototype.reduce()` to create a new object with the same values and mapped keys using `fn`.\n"
},
"defaults": {
"prefix": "30s_defaults",
"body": [
"const defaults = (obj, ...defs) => Object.assign({}, obj, ...defs.reverse(), obj);"
],
"description": "Assigns default values for all properties in an object that are `undefined`.\n\nUse `Object.assign()` to create a new empty object and copy the original one to maintain key order, use `Array.prototype.reverse()` and the spread operator `...` to combine the default values from left to right, finally use `obj` again to overwrite properties that originally had a value.\n"
},
"defer": {
"prefix": "30s_defer",
"body": [
"const defer = (fn, ...args) => setTimeout(fn, 1, ...args);"
],
"description": "Defers invoking a function until the current call stack has cleared.\n\nUse `setTimeout()` with a timeout of 1ms to add a new event to the browser event queue and allow the rendering engine to complete its work. Use the spread (`...`) operator to supply the function with an arbitrary number of arguments.\n"
},
"degreesToRads": {
"prefix": "30s_degreesToRads",
"body": [
"const degreesToRads = deg => (deg * Math.PI) / 180.0;"
],
"description": "Converts an angle from degrees to radians.\n\nUse `Math.PI` and the degree to radian formula to convert the angle from degrees to radians.\n"
},
"delay": {
"prefix": "30s_delay",
"body": [
"const delay = (fn, wait, ...args) => setTimeout(fn, wait, ...args);"
],
"description": "Invokes the provided function after `wait` milliseconds.\n\nUse `setTimeout()` to delay execution of `fn`.\nUse the spread (`...`) operator to supply the function with an arbitrary number of arguments.\n"
},
"detectDeviceType": {
"prefix": "30s_detectDeviceType",
"body": [
"const detectDeviceType = () =>",
" /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)",
" ? 'Mobile'",
" : 'Desktop';"
],
"description": "Detects whether the website is being opened in a mobile device or a desktop/laptop.\n\nUse a regular expression to test the `navigator.userAgent` property to figure out if the device is a mobile device or a desktop/laptop.\n"
},
"difference": {
"prefix": "30s_difference",
"body": [
"const difference = (a, b) => {",
" const s = new Set(b);",
" return a.filter(x => !s.has(x));",
"};"
],
"description": "Returns the difference between two arrays.\n\nCreate a `Set` from `b`, then use `Array.prototype.filter()` on `a` to only keep values not contained in `b`.\n"
},
"differenceBy": {
"prefix": "30s_differenceBy",
"body": [
"const differenceBy = (a, b, fn) => {",
" const s = new Set(b.map(fn));",
" return a.map(fn).filter(el => !s.has(el));",
"};"
],
"description": "Returns the difference between two arrays, after applying the provided function to each array element of both.\n\nCreate a `Set` by applying `fn` to each element in `b`, then use `Array.prototype.map()` to apply `fn` to each element in `a`, then `Array.prototype.filter()`\n"
},
"differenceWith": {
"prefix": "30s_differenceWith",
"body": [
"const differenceWith = (arr, val, comp) => arr.filter(a => val.findIndex(b => comp(a, b)) === -1);"
],
"description": "Filters out all values from an array for which the comparator function does not return `true`.\n\nUse `Array.prototype.filter()` and `Array.prototype.findIndex()` to find the appropriate values.\n"
},
"dig": {
"prefix": "30s_dig",
"body": [
"const dig = (obj, target) =>",
" target in obj",
" ? obj[target]",
" : Object.values(obj).reduce((acc, val) => {",
" if (acc !== undefined) return acc;",
" if (typeof val === 'object') return dig(val, target);",
" }, undefined);"
],
"description": "Returns the target value in a nested JSON object, based on the given key.\n\nUse the `in` operator to check if `target` exists in `obj`.\nIf found, return the value of `obj[target]`, otherwise use `Object.values(obj)` and `Array.prototype.reduce()` to recursively call `dig` on each nested object until the first matching key/value pair is found.\n"
},
"digitize": {
"prefix": "30s_digitize",
"body": [
"const digitize = n => [...`${n}`].map(i => parseInt(i));"
],
"description": "Converts a number to an array of digits.\n\nConvert the number to a string, using the spread operator (`...`) to build an array.\nUse `Array.prototype.map()` and `parseInt()` to transform each value to an integer.\n"
},
"distance": {
"prefix": "30s_distance",
"body": [
"const distance = (x0, y0, x1, y1) => Math.hypot(x1 - x0, y1 - y0);"
],
"description": "Returns the distance between two points.\n\nUse `Math.hypot()` to calculate the Euclidean distance between two points.\n"
},
"drop": {
"prefix": "30s_drop",
"body": [
"const drop = (arr, n = 1) => arr.slice(n);"
],
"description": "Returns a new array with `n` elements removed from the left.\n\nUse `Array.prototype.slice()` to remove the specified number of elements from the left.\n"
},
"dropRight": {
"prefix": "30s_dropRight",
"body": [
"const dropRight = (arr, n = 1) => arr.slice(0, -n);"
],
"description": "Returns a new array with `n` elements removed from the right.\n\nUse `Array.prototype.slice()` to remove the specified number of elements from the right.\n"
},
"dropRightWhile": {
"prefix": "30s_dropRightWhile",
"body": [
"const dropRightWhile = (arr, func) => {",
" let rightIndex = arr.length;",
" while (rightIndex-- && !func(arr[rightIndex]));",
" return arr.slice(0, rightIndex + 1);",
"};"
],
"description": "Removes elements from the end of an array until the passed function returns `true`. Returns the remaining elements in the array.\n\nLoop through the array, using `Array.prototype.slice()` to drop the last element of the array until the returned value from the function is `true`.\nReturns the remaining elements.\n"
},
"dropWhile": {
"prefix": "30s_dropWhile",
"body": [
"const dropWhile = (arr, func) => {",
" while (arr.length > 0 && !func(arr[0])) arr = arr.slice(1);",
" return arr;",
"};"
],
"description": "Removes elements in an array until the passed function returns `true`. Returns the remaining elements in the array.\n\nLoop through the array, using `Array.prototype.slice()` to drop the first element of the array until the returned value from the function is `true`.\nReturns the remaining elements.\n"
},
"elementContains": {
"prefix": "30s_elementContains",
"body": [
"const elementContains = (parent, child) => parent !== child && parent.contains(child);"
],
"description": "Returns `true` if the `parent` element contains the `child` element, `false` otherwise.\n\nCheck that `parent` is not the same element as `child`, use `parent.contains(child)` to check if the `parent` element contains the `child` element.\n"
},
"elementIsVisibleInViewport": {
"prefix": "30s_elementIsVisibleInViewport",
"body": [
"const elementIsVisibleInViewport = (el, partiallyVisible = false) => {",
" const { top, left, bottom, right } = el.getBoundingClientRect();",
" const { innerHeight, innerWidth } = window;",
" return partiallyVisible",
" ? ((top > 0 && top < innerHeight) || (bottom > 0 && bottom < innerHeight)) &&",
" ((left > 0 && left < innerWidth) || (right > 0 && right < innerWidth))",
" : top >= 0 && left >= 0 && bottom <= innerHeight && right <= innerWidth;",
"};"
],
"description": "Returns `true` if the element specified is visible in the viewport, `false` otherwise.\n\nUse `Element.getBoundingClientRect()` and the `window.inner(Width|Height)` values\nto determine if a given element is visible in the viewport.\nOmit the second argument to determine if the element is entirely visible, or specify `true` to determine if\nit is partially visible.\n"
},
"elo": {
"prefix": "30s_elo",
"body": [
"const elo = ([...ratings], kFactor = 32, selfRating) => {",
" const [a, b] = ratings;",
" const expectedScore = (self, opponent) => 1 / (1 + 10 ** ((opponent - self) / 400));",
" const newRating = (rating, i) =>",
" (selfRating || rating) + kFactor * (i - expectedScore(i ? a : b, i ? b : a));",
" if (ratings.length === 2) return [newRating(a, 1), newRating(b, 0)];",
"",
" for (let i = 0, len = ratings.length; i < len; i++) {",
" let j = i;",
" while (j < len - 1) {",
" j++;",
" [ratings[i], ratings[j]] = elo([ratings[i], ratings[j]], kFactor);",
" }",
" }",
" return ratings;",
"};"
],
"description": "Computes the new ratings between two or more opponents using the [Elo rating system](https://en.wikipedia.org/wiki/Elo_rating_system). It takes an array\nof pre-ratings and returns an array containing post-ratings.\nThe array should be ordered from best performer to worst performer (winner -> loser).\n\nUse the exponent `**` operator and math operators to compute the expected score (chance of winning).\nof each opponent and compute the new rating for each.\nLoop through the ratings, using each permutation to compute the post-Elo rating for each player in a pairwise fashion. \nOmit the second argument to use the default `kFactor` of 32.\n"
},
"equals": {
"prefix": "30s_equals",
"body": [
"const equals = (a, b) => {",
" if (a === b) return true;",
" if (a instanceof Date && b instanceof Date) return a.getTime() === b.getTime();",
" if (!a || !b || (typeof a !== 'object' && typeof b !== 'object')) return a === b;",
" if (a === null || a === undefined || b === null || b === undefined) return false;",
" if (a.prototype !== b.prototype) return false;",
" let keys = Object.keys(a);",
" if (keys.length !== Object.keys(b).length) return false;",
" return keys.every(k => equals(a[k], b[k]));",
"};"
],
"description": "Performs a deep comparison between two values to determine if they are equivalent.\n\nCheck if the two values are identical, if they are both `Date` objects with the same time, using `Date.getTime()` or if they are both non-object values with an equivalent value (strict comparison).\nCheck if only one value is `null` or `undefined` or if their prototypes differ.\nIf none of the above conditions are met, use `Object.keys()` to check if both values have the same number of keys, then use `Array.prototype.every()` to check if every key in the first value exists in the second one and if they are equivalent by calling this method recursively.\n"
},
"escapeHTML": {
"prefix": "30s_escapeHTML",
"body": [
"const escapeHTML = str =>",
" str.replace(",
" /[&<>'\"]/g,",
" tag =>",
" ({",
" '&': '&amp;',",
" '<': '&lt;',",
" '>': '&gt;',",
" \"'\": '&#39;',",
" '\"': '&quot;'",
" }[tag] || tag)",
" );"
],
"description": "Escapes a string for use in HTML.\n\nUse `String.prototype.replace()` with a regexp that matches the characters that need to be escaped, using a callback function to replace each character instance with its associated escaped character using a dictionary (object).\n"
},
"escapeRegExp": {
"prefix": "30s_escapeRegExp",
"body": [
"const escapeRegExp = str => str.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');"
],
"description": "Escapes a string to use in a regular expression.\n\nUse `String.prototype.replace()` to escape special characters.\n"
},
"everyNth": {
"prefix": "30s_everyNth",
"body": [
"const everyNth = (arr, nth) => arr.filter((e, i) => i % nth === nth - 1);"
],
"description": "Returns every nth element in an array.\n\nUse `Array.prototype.filter()` to create a new array that contains every nth element of a given array.\n"
},
"extendHex": {
"prefix": "30s_extendHex",
"body": [
"const extendHex = shortHex =>",
" '#' +",
" shortHex",
" .slice(shortHex.startsWith('#') ? 1 : 0)",
" .split('')",
" .map(x => x + x)",
" .join('');"
],
"description": "Extends a 3-digit color code to a 6-digit color code.\n\nUse `Array.prototype.map()`, `String.prototype.split()` and `Array.prototype.join()` to join the mapped array for converting a 3-digit RGB notated hexadecimal color-code to the 6-digit form.\n`Array.prototype.slice()` is used to remove `#` from string start since it's added once.\n"
},
"factorial": {
"prefix": "30s_factorial",
"body": [
"const factorial = n =>",
" n < 0",
" ? (() => {",
" throw new TypeError('Negative numbers are not allowed!');",
" })()",
" : n <= 1",
" ? 1",
" : n * factorial(n - 1);"
],
"description": "Calculates the factorial of a number.\n\nUse recursion.\nIf `n` is less than or equal to `1`, return `1`.\nOtherwise, return the product of `n` and the factorial of `n - 1`.\nThrows an exception if `n` is a negative number.\n"
},
"fibonacci": {
"prefix": "30s_fibonacci",
"body": [
"const fibonacci = n =>",
" Array.from({ length: n }).reduce(",
" (acc, val, i) => acc.concat(i > 1 ? acc[i - 1] + acc[i - 2] : i),",
" []",
" );"
],
"description": "Generates an array, containing the Fibonacci sequence, up until the nth term.\n\nCreate an empty array of the specific length, initializing the first two values (`0` and `1`).\nUse `Array.prototype.reduce()` to add values into the array, using the sum of the last two values, except for the first two.\n"
},
"filterFalsy": {
"prefix": "30s_filterFalsy",
"body": [
"const filterFalsy = arr => arr.filter(Boolean);"
],
"description": "Filters out the falsy values in an array.\n\nUse `Array.prototype.filter()` to get an array containing only truthy values.\n"
},
"filterNonUnique": {
"prefix": "30s_filterNonUnique",
"body": [
"const filterNonUnique = arr => arr.filter(i => arr.indexOf(i) === arr.lastIndexOf(i));"
],
"description": "Filters out the non-unique values in an array.\n\nUse `Array.prototype.filter()` for an array containing only the unique values.\n"
},
"filterNonUniqueBy": {
"prefix": "30s_filterNonUniqueBy",
"body": [
"const filterNonUniqueBy = (arr, fn) =>",
" arr.filter((v, i) => arr.every((x, j) => (i === j) === fn(v, x, i, j)));"
],
"description": "Filters out the non-unique values in an array, based on a provided comparator function.\n\nUse `Array.prototype.filter()` and `Array.prototype.every()` for an array containing only the unique values, based on the comparator function, `fn`.\nThe comparator function takes four arguments: the values of the two elements being compared and their indexes.\n"
},
"findKey": {
"prefix": "30s_findKey",
"body": [
"const findKey = (obj, fn) => Object.keys(obj).find(key => fn(obj[key], key, obj));"
],
"description": "Returns the first key that satisfies the provided testing function. Otherwise `undefined` is returned.\n\nUse `Object.keys(obj)` to get all the properties of the object, `Array.prototype.find()` to test the provided function for each key-value pair. The callback receives three arguments - the value, the key and the object.\n"
},
"findLast": {
"prefix": "30s_findLast",
"body": [
"const findLast = (arr, fn) => arr.filter(fn).pop();"
],
"description": "Returns the last element for which the provided function returns a truthy value.\n\nUse `Array.prototype.filter()` to remove elements for which `fn` returns falsy values, `Array.prototype.pop()` to get the last one.\n"
},
"findLastIndex": {
"prefix": "30s_findLastIndex",
"body": [
"const findLastIndex = (arr, fn) =>",
" (arr",
" .map((val, i) => [i, val])",
" .filter(([i, val]) => fn(val, i, arr))",
" .pop() || [-1])[0];"
],
"description": "Returns the index of the last element for which the provided function returns a truthy value.\n\nUse `Array.prototype.map()` to map each element to an array with its index and value.\nUse `Array.prototype.filter()` to remove elements for which `fn` returns falsy values, `Array.prototype.pop()` to get the last one.\n`-1` is the default value when not found.\n"
},
"findLastKey": {
"prefix": "30s_findLastKey",
"body": [
"const findLastKey = (obj, fn) =>",
" Object.keys(obj)",
" .reverse()",
" .find(key => fn(obj[key], key, obj));"
],
"description": "Returns the last key that satisfies the provided testing function.\nOtherwise `undefined` is returned.\n\nUse `Object.keys(obj)` to get all the properties of the object, `Array.prototype.reverse()` to reverse their order and `Array.prototype.find()` to test the provided function for each key-value pair.\nThe callback receives three arguments - the value, the key and the object.\n"
},
"flatten": {
"prefix": "30s_flatten",
"body": [
"const flatten = (arr, depth = 1) =>",
" arr.reduce((a, v) => a.concat(depth > 1 && Array.isArray(v) ? flatten(v, depth - 1) : v), []);"
],
"description": "Flattens an array up to the specified depth.\n\nUse recursion, decrementing `depth` by 1 for each level of depth.\nUse `Array.prototype.reduce()` and `Array.prototype.concat()` to merge elements or arrays.\nBase case, for `depth` equal to `1` stops recursion.\nOmit the second argument, `depth` to flatten only to a depth of `1` (single flatten).\n"
},
"flattenObject": {
"prefix": "30s_flattenObject",
"body": [
"const flattenObject = (obj, prefix = '') =>",
" Object.keys(obj).reduce((acc, k) => {",
" const pre = prefix.length ? prefix + '.' : '';",
" if (typeof obj[k] === 'object') Object.assign(acc, flattenObject(obj[k], pre + k));",
" else acc[pre + k] = obj[k];",
" return acc;",
" }, {});"
],
"description": "Flatten an object with the paths for keys.\n\nUse recursion.\nUse `Object.keys(obj)` combined with `Array.prototype.reduce()` to convert every leaf node to a flattened path node.\nIf the value of a key is an object, the function calls itself with the appropriate `prefix` to create the path using `Object.assign()`.\nOtherwise, it adds the appropriate prefixed key-value pair to the accumulator object.\nYou should always omit the second argument, `prefix`, unless you want every key to have a prefix.\n"
},
"flip": {
"prefix": "30s_flip",
"body": [
"const flip = fn => (first, ...rest) => fn(...rest, first);"
],
"description": "Flip takes a function as an argument, then makes the first argument the last.\n\nReturn a closure that takes variadic inputs, and splices the last argument to make it the first argument before applying the rest.\n"
},
"forEachRight": {
"prefix": "30s_forEachRight",
"body": [
"const forEachRight = (arr, callback) =>",
" arr",
" .slice(0)",
" .reverse()",
" .forEach(callback);"
],
"description": "Executes a provided function once for each array element, starting from the array's last element.\n\nUse `Array.prototype.slice(0)` to clone the given array, `Array.prototype.reverse()` to reverse it and `Array.prototype.forEach()` to iterate over the reversed array.\n"
},
"formatDuration": {
"prefix": "30s_formatDuration",
"body": [
"const formatDuration = ms => {",
" if (ms < 0) ms = -ms;",
" const time = {",
" day: Math.floor(ms / 86400000),",
" hour: Math.floor(ms / 3600000) % 24,",
" minute: Math.floor(ms / 60000) % 60,",
" second: Math.floor(ms / 1000) % 60,",
" millisecond: Math.floor(ms) % 1000",
" };",
" return Object.entries(time)",
" .filter(val => val[1] !== 0)",
" .map(([key, val]) => `${val} ${key}${val !== 1 ? 's' : ''}`)",
" .join(', ');",
"};"
],
"description": "Returns the human readable format of the given number of milliseconds.\n\nDivide `ms` with the appropriate values to obtain the appropriate values for `day`, `hour`, `minute`, `second` and `millisecond`.\nUse `Object.entries()` with `Array.prototype.filter()` to keep only non-zero values.\nUse `Array.prototype.map()` to create the string for each value, pluralizing appropriately.\nUse `String.prototype.join(', ')` to combine the values into a string.\n"
},
"formToObject": {
"prefix": "30s_formToObject",
"body": [
"const formToObject = form =>",
" Array.from(new FormData(form)).reduce(",
" (acc, [key, value]) => ({",
" ...acc,",
" [key]: value",
" }),",
" {}",
" );"
],
"description": "Encode a set of form elements as an `object`.\n\nUse the `FormData` constructor to convert the HTML `form` to `FormData`, `Array.from()` to convert to an array.\nCollect the object from the array, using `Array.prototype.reduce()`.\n"
},
"forOwn": {
"prefix": "30s_forOwn",
"body": [
"const forOwn = (obj, fn) => Object.keys(obj).forEach(key => fn(obj[key], key, obj));"
],
"description": "Iterates over all own properties of an object, running a callback for each one.\n\nUse `Object.keys(obj)` to get all the properties of the object, `Array.prototype.forEach()` to run the provided function for each key-value pair. The callback receives three arguments - the value, the key and the object.\n"
},
"forOwnRight": {
"prefix": "30s_forOwnRight",
"body": [
"const forOwnRight = (obj, fn) =>",
" Object.keys(obj)",
" .reverse()",
" .forEach(key => fn(obj[key], key, obj));"
],
"description": "Iterates over all own properties of an object in reverse, running a callback for each one.\n\nUse `Object.keys(obj)` to get all the properties of the object, `Array.prototype.reverse()` to reverse their order and `Array.prototype.forEach()` to run the provided function for each key-value pair. The callback receives three arguments - the value, the key and the object.\n"
},
"fromCamelCase": {
"prefix": "30s_fromCamelCase",
"body": [
"const fromCamelCase = (str, separator = '_') =>",
" str",
" .replace(/([a-z\\d])([A-Z])/g, '$1' + separator + '$2')",
" .replace(/([A-Z]+)([A-Z][a-z\\d]+)/g, '$1' + separator + '$2')",
" .toLowerCase();"
],
"description": "Converts a string from camelcase.\n\nUse `String.prototype.replace()` to remove underscores, hyphens, and spaces and convert words to camelcase.\nOmit the second argument to use a default `separator` of `_`.\n"
},
"functionName": {
"prefix": "30s_functionName",
"body": [
"const functionName = fn => (console.debug(fn.name), fn);"
],
"description": "Logs the name of a function.\n\nUse `console.debug()` and the `name` property of the passed method to log the method's name to the `debug` channel of the console.\n"
},
"functions": {
"prefix": "30s_functions",
"body": [
"const functions = (obj, inherited = false) =>",
" (inherited",
" ? [...Object.keys(obj), ...Object.keys(Object.getPrototypeOf(obj))]",
" : Object.keys(obj)",
" ).filter(key => typeof obj[key] === 'function');"
],
"description": "Returns an array of function property names from own (and optionally inherited) enumerable properties of an object.\n\nUse `Object.keys(obj)` to iterate over the object's own properties.\nIf `inherited` is `true`, use `Object.get.PrototypeOf(obj)` to also get the object's inherited properties.\nUse `Array.prototype.filter()` to keep only those properties that are functions.\nOmit the second argument, `inherited`, to not include inherited properties by default.\n"
},
"gcd": {
"prefix": "30s_gcd",
"body": [
"const gcd = (...arr) => {",
" const _gcd = (x, y) => (!y ? x : gcd(y, x % y));",
" return [...arr].reduce((a, b) => _gcd(a, b));",
"};"
],
"description": "Calculates the greatest common divisor between two or more numbers/arrays.\n\nThe inner `_gcd` function uses recursion.\nBase case is when `y` equals `0`. In this case, return `x`.\nOtherwise, return the GCD of `y` and the remainder of the division `x/y`.\n"
},
"geometricProgression": {
"prefix": "30s_geometricProgression",
"body": [
"const geometricProgression = (end, start = 1, step = 2) =>",
" Array.from({ length: Math.floor(Math.log(end / start) / Math.log(step)) + 1 }).map(",
" (v, i) => start * step ** i",
" );"
],
"description": "Initializes an array containing the numbers in the specified range where `start` and `end` are inclusive and the ratio between two terms is `step`.\nReturns an error if `step` equals `1`.\n\nUse `Array.from()`, `Math.log()` and `Math.floor()` to create an array of the desired length, `Array.prototype.map()` to fill with the desired values in a range.\nOmit the second argument, `start`, to use a default value of `1`.\nOmit the third argument, `step`, to use a default value of `2`.\n"
},
"get": {
"prefix": "30s_get",
"body": [
"const get = (from, ...selectors) =>",
" [...selectors].map(s =>",
" s",
" .replace(/\\[([^\\[\\]]*)\\]/g, '.$1.')",
" .split('.')",
" .filter(t => t !== '')",
" .reduce((prev, cur) => prev && prev[cur], from)",
" );"
],
"description": "Retrieve a set of properties indicated by the given selectors from an object.\n\nUse `Array.prototype.map()` for each selector, `String.prototype.replace()` to replace square brackets with dots, `String.prototype.split('.')` to split each selector, `Array.prototype.filter()` to remove empty values and `Array.prototype.reduce()` to get the value indicated by it.\n"
},
"getColonTimeFromDate": {
"prefix": "30s_getColonTimeFromDate",
"body": [
"const getColonTimeFromDate = date => date.toTimeString().slice(0, 8);"
],
"description": "Returns a string of the form `HH:MM:SS` from a `Date` object.\n\nUse `Date.prototype.toTimeString()` and `String.prototype.slice()` to get the `HH:MM:SS` part of a given `Date` object.\n"
},
"getDaysDiffBetweenDates": {
"prefix": "30s_getDaysDiffBetweenDates",
"body": [
"const getDaysDiffBetweenDates = (dateInitial, dateFinal) =>",
" (dateFinal - dateInitial) / (1000 * 3600 * 24);"
],
"description": "Returns the difference (in days) between two dates.\n\nCalculate the difference (in days) between two `Date` objects.\n"
},
"getImages": {
"prefix": "30s_getImages",
"body": [
"const getImages = (el, includeDuplicates = false) => {",
" const images = [...el.getElementsByTagName('img')].map(img => img.getAttribute('src'));",
" return includeDuplicates ? images : [...new Set(images)];",
"};"
],
"description": "Fetches all images from within an element and puts them into an array\n\nUse `Element.prototype.getElementsByTagName()` to fetch all `<img>` elements inside the provided element, `Array.prototype.map()` to map every `src` attribute of their respective `<img>` element, then create a `Set` to eliminate duplicates and return the array.\n"
},
"getMeridiemSuffixOfInteger": {
"prefix": "30s_getMeridiemSuffixOfInteger",
"body": [
"const getMeridiemSuffixOfInteger = num =>",
" num === 0 || num === 24",
" ? 12 + 'am'",
" : num === 12",
" ? 12 + 'pm'",
" : num < 12",
" ? (num % 12) + 'am'",
" : (num % 12) + 'pm';"
],
"description": "Converts an integer to a suffixed string, adding `am` or `pm` based on its value.\n\nUse the modulo operator (`%`) and conditional checks to transform an integer to a stringified 12-hour format with meridiem suffix.\n"
},
"getScrollPosition": {
"prefix": "30s_getScrollPosition",
"body": [
"const getScrollPosition = (el = window) => ({",
" x: el.pageXOffset !== undefined ? el.pageXOffset : el.scrollLeft,",
" y: el.pageYOffset !== undefined ? el.pageYOffset : el.scrollTop",
"});"
],
"description": "Returns the scroll position of the current page.\n\nUse `pageXOffset` and `pageYOffset` if they are defined, otherwise `scrollLeft` and `scrollTop`.\nYou can omit `el` to use a default value of `window`.\n"
},
"getStyle": {
"prefix": "30s_getStyle",
"body": [
"const getStyle = (el, ruleName) => getComputedStyle(el)[ruleName];"
],
"description": "Returns the value of a CSS rule for the specified element.\n\nUse `Window.getComputedStyle()` to get the value of the CSS rule for the specified element.\n"
},
"getType": {
"prefix": "30s_getType",
"body": [
"const getType = v =>",
" v === undefined ? 'undefined' : v === null ? 'null' : v.constructor.name.toLowerCase();"
],
"description": "Returns the native type of a value.\n\nReturns lowercased constructor name of value, `\"undefined\"` or `\"null\"` if value is `undefined` or `null`.\n"
},
"getURLParameters": {
"prefix": "30s_getURLParameters",
"body": [
"const getURLParameters = url =>",
" (url.match(/([^?=&]+)(=([^&]*))/g) || []).reduce(",
" (a, v) => ((a[v.slice(0, v.indexOf('='))] = v.slice(v.indexOf('=') + 1)), a),",
" {}",
" );"
],
"description": "Returns an object containing the parameters of the current URL.\n\nUse `String.match()` with an appropriate regular expression to get all key-value pairs, `Array.prototype.reduce()` to map and combine them into a single object.\nPass `location.search` as the argument to apply to the current `url`.\n"
},
"groupBy": {
"prefix": "30s_groupBy",
"body": [
"const groupBy = (arr, fn) =>",
" arr.map(typeof fn === 'function' ? fn : val => val[fn]).reduce((acc, val, i) => {",
" acc[val] = (acc[val] || []).concat(arr[i]);",
" return acc;",
" }, {});"
],
"description": "Groups the elements of an array based on the given function.\n\nUse `Array.prototype.map()` to map the values of an array to a function or property name.\nUse `Array.prototype.reduce()` to create an object, where the keys are produced from the mapped results.\n"
},
"hammingDistance": {
"prefix": "30s_hammingDistance",
"body": [
"const hammingDistance = (num1, num2) => ((num1 ^ num2).toString(2).match(/1/g) || '').length;"
],
"description": "Calculates the Hamming distance between two values.\n\nUse XOR operator (`^`) to find the bit difference between the two numbers, convert to a binary string using `toString(2)`.\nCount and return the number of `1`s in the string, using `match(/1/g)`.\n"
},
"hasClass": {
"prefix": "30s_hasClass",
"body": [
"const hasClass = (el, className) => el.classList.contains(className);"
],
"description": "Returns `true` if the element has the specified class, `false` otherwise.\n\nUse `element.classList.contains()` to check if the element has the specified class.\n"
},
"hasFlags": {
"prefix": "30s_hasFlags",
"body": [
"const hasFlags = (...flags) =>",
" flags.every(flag => process.argv.includes(/^-{1,2}/.test(flag) ? flag : '--' + flag));"
],
"description": "Check if the current process's arguments contain the specified flags.\n\nUse `Array.prototype.every()` and `Array.prototype.includes()` to check if `process.argv` contains all the specified flags.\nUse a regular expression to test if the specified flags are prefixed with `-` or `--` and prefix them accordingly.\n"
},
"hashBrowser": {
"prefix": "30s_hashBrowser",
"body": [
"const hashBrowser = val =>",
" crypto.subtle.digest('SHA-256', new TextEncoder('utf-8').encode(val)).then(h => {",
" let hexes = [],",
" view = new DataView(h);",
" for (let i = 0; i < view.byteLength; i += 4)",
" hexes.push(('00000000' + view.getUint32(i).toString(16)).slice(-8));",
" return hexes.join('');",
" });"
],
"description": "Creates a hash for a value using the [SHA-256](https://en.wikipedia.org/wiki/SHA-2) algorithm. Returns a promise.\n\nUse the [SubtleCrypto](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto) API to create a hash for the given value.\n"
},
"hashNode": {
"prefix": "30s_hashNode",
"body": [
"const crypto = require('crypto');",
"const hashNode = val =>",
" new Promise(resolve =>",
" setTimeout(",
" () =>",
" resolve(",
" crypto",
" .createHash('sha256')",
" .update(val)",
" .digest('hex')",
" ),",
" 0",
" )",
" );"
],
"description": "Creates a hash for a value using the [SHA-256](https://en.wikipedia.org/wiki/SHA-2) algorithm. Returns a promise.\n\nUse `crypto` API to create a hash for the given value, `setTimeout` to prevent blocking on a long operation, and a `Promise` to give it a familiar interface.\n"
},
"head": {
"prefix": "30s_head",
"body": [
"const head = arr => arr[0];"
],
"description": "Returns the head of a list.\n\nUse `arr[0]` to return the first element of the passed array.\n"
},
"hexToRGB": {
"prefix": "30s_hexToRGB",
"body": [
"const hexToRGB = hex => {",
" let alpha = false,",
" h = hex.slice(hex.startsWith('#') ? 1 : 0);",
" if (h.length === 3) h = [...h].map(x => x + x).join('');",
" else if (h.length === 8) alpha = true;",
" h = parseInt(h, 16);",
" return (",
" 'rgb' +",
" (alpha ? 'a' : '') +",
" '(' +",
" (h >>> (alpha ? 24 : 16)) +",
" ', ' +",
" ((h & (alpha ? 0x00ff0000 : 0x00ff00)) >>> (alpha ? 16 : 8)) +",
" ', ' +",
" ((h & (alpha ? 0x0000ff00 : 0x0000ff)) >>> (alpha ? 8 : 0)) +",
" (alpha ? `, ${h & 0x000000ff}` : '') +",
" ')'",
" );",
"};"
],
"description": "Converts a color code to a `rgb()` or `rgba()` string if alpha value is provided.\n\nUse bitwise right-shift operator and mask bits with `&` (and) operator to convert a hexadecimal color code (with or without prefixed with `#`) to a string with the RGB values. If it's 3-digit color code, first convert to 6-digit version. If an alpha value is provided alongside 6-digit hex, give `rgba()` string in return.\n"
},
"hide": {
"prefix": "30s_hide",
"body": [
"const hide = (...el) => [...el].forEach(e => (e.style.display = 'none'));"
],
"description": "Hides all the elements specified.\n\nUse `NodeList.prototype.forEach()` to apply `display: none` to each element specified.\n"
},
"httpGet": {
"prefix": "30s_httpGet",
"body": [
"const httpGet = (url, callback, err = console.error) => {",
" const request = new XMLHttpRequest();",
" request.open('GET', url, true);",
" request.onload = () => callback(request.responseText);",
" request.onerror = () => err(request);",
" request.send();",
"};"
],
"description": "Makes a `GET` request to the passed URL.\n\nUse [`XMLHttpRequest`](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Using_XMLHttpRequest) web api to make a `get` request to the given `url`.\nHandle the `onload` event, by calling the given `callback` the `responseText`.\nHandle the `onerror` event, by running the provided `err` function.\nOmit the third argument, `err`, to log errors to the console's `error` stream by default.\n"
},
"httpPost": {
"prefix": "30s_httpPost",
"body": [
"const httpPost = (url, data, callback, err = console.error) => {",
" const request = new XMLHttpRequest();",
" request.open('POST', url, true);",
" request.setRequestHeader('Content-type', 'application/json; charset=utf-8');",
" request.onload = () => callback(request.responseText);",
" request.onerror = () => err(request);",
" request.send(data);",
"};"
],
"description": "Makes a `POST` request to the passed URL.\n\nUse [`XMLHttpRequest`](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Using_XMLHttpRequest) web api to make a `post` request to the given `url`.\nSet the value of an `HTTP` request header with `setRequestHeader` method.\nHandle the `onload` event, by calling the given `callback` the `responseText`.\nHandle the `onerror` event, by running the provided `err` function.\nOmit the third argument, `data`, to send no data to the provided `url`.\nOmit the fourth argument, `err`, to log errors to the console's `error` stream by default.\n"
},
"httpsRedirect": {
"prefix": "30s_httpsRedirect",
"body": [
"const httpsRedirect = () => {",
" if (location.protocol !== 'https:') location.replace('https://' + location.href.split('//')[1]);",
"};"
],
"description": "Redirects the page to HTTPS if its currently in HTTP. Also, pressing the back button doesn't take it back to the HTTP page as its replaced in the history.\n\nUse `location.protocol` to get the protocol currently being used. If it's not HTTPS, use `location.replace()` to replace the existing page with the HTTPS version of the page. Use `location.href` to get the full address, split it with `String.prototype.split()` and remove the protocol part of the URL.\n"
},
"hz": {
"prefix": "30s_hz",
"body": [
"const hz = (fn, iterations = 100) => {",
" const before = performance.now();",
" for (let i = 0; i < iterations; i++) fn();",
" return (1000 * iterations) / (performance.now() - before);",
"};"
],
"description": "Returns the number of times a function executed per second. \n`hz` is the unit for `hertz`, the unit of frequency defined as one cycle per second.\n\nUse `performance.now()` to get the difference in milliseconds before and after the iteration loop to calculate the time elapsed executing the function `iterations` times. \nReturn the number of cycles per second by converting milliseconds to seconds and dividing it by the time elapsed. \nOmit the second argument, `iterations`, to use the default of 100 iterations.\n"
},
"indentString": {
"prefix": "30s_indentString",
"body": [
"const indentString = (str, count, indent = ' ') => str.replace(/^/gm, indent.repeat(count));"
],
"description": "Indents each line in the provided string.\n\nUse `String.replace` and a regular expression to add the character specified by `indent` `count` times at the start of each line.\nOmit the third parameter, `indent`, to use a default indentation character of `' '`.\n"
},
"indexOfAll": {
"prefix": "30s_indexOfAll",
"body": [
"const indexOfAll = (arr, val) => arr.reduce((acc, el, i) => (el === val ? [...acc, i] : acc), []);"
],
"description": "Returns all indices of `val` in an array.\nIf `val` never occurs, returns `[]`.\n\nUse `Array.prototype.reduce()` to loop over elements and store indices for matching elements.\nReturn the array of indices.\n"
},
"initial": {
"prefix": "30s_initial",
"body": [
"const initial = arr => arr.slice(0, -1);"
],
"description": "Returns all the elements of an array except the last one.\n\nUse `arr.slice(0,-1)` to return all but the last element of the array.\n"
},
"initialize2DArray": {
"prefix": "30s_initialize2DArray",
"body": [
"const initialize2DArray = (w, h, val = null) =>",
" Array.from({ length: h }).map(() => Array.from({ length: w }).fill(val));"
],
"description": "Initializes a 2D array of given width and height and value.\n\nUse `Array.prototype.map()` to generate h rows where each is a new array of size w initialize with value. If the value is not provided, default to `null`.\n"
},
"initializeArrayWithRange": {
"prefix": "30s_initializeArrayWithRange",
"body": [
"const initializeArrayWithRange = (end, start = 0, step = 1) =>",
" Array.from({ length: Math.ceil((end - start + 1) / step) }, (v, i) => i * step + start);"
],
"description": "Initializes an array containing the numbers in the specified range where `start` and `end` are inclusive with their common difference `step`.\n\nUse `Array.from()` to create an array of the desired length, `(end - start + 1)/step`, and a map function to fill it with the desired values in the given range.\nYou can omit `start` to use a default value of `0`.\nYou can omit `step` to use a default value of `1`.\n"
},
"initializeArrayWithRangeRight": {
"prefix": "30s_initializeArrayWithRangeRight",
"body": [
"const initializeArrayWithRangeRight = (end, start = 0, step = 1) =>",
" Array.from({ length: Math.ceil((end + 1 - start) / step) }).map(",
" (v, i, arr) => (arr.length - i - 1) * step + start",
" );"
],
"description": "Initializes an array containing the numbers in the specified range (in reverse) where `start` and `end` are inclusive with their common difference `step`.\n\nUse `Array.from(Math.ceil((end+1-start)/step))` to create an array of the desired length(the amounts of elements is equal to `(end-start)/step` or `(end+1-start)/step` for inclusive end), `Array.prototype.map()` to fill with the desired values in a range.\nYou can omit `start` to use a default value of `0`.\nYou can omit `step` to use a default value of `1`.\n"
},
"initializeArrayWithValues": {
"prefix": "30s_initializeArrayWithValues",
"body": [
"const initializeArrayWithValues = (n, val = 0) => Array(n).fill(val);"
],
"description": "Initializes and fills an array with the specified values.\n\nUse `Array(n)` to create an array of the desired length, `fill(v)` to fill it with the desired values.\nYou can omit `val` to use a default value of `0`.\n"
},
"initializeNDArray": {
"prefix": "30s_initializeNDArray",
"body": [
"const initializeNDArray = (val, ...args) =>",
" args.length === 0",
" ? val",
" : Array.from({ length: args[0] }).map(() => initializeNDArray(val, ...args.slice(1)));"
],
"description": "Create a n-dimensional array with given value.\n\nUse recursion.\nUse `Array.prototype.map()` to generate rows where each is a new array initialized using `initializeNDArray`.\n"
},
"inRange": {
"prefix": "30s_inRange",
"body": [
"const inRange = (n, start, end = null) => {",
" if (end && start > end) [end, start] = [start, end];",
" return end == null ? n >= 0 && n < start : n >= start && n < end;",
"};"
],
"description": "Checks if the given number falls within the given range.\n\nUse arithmetic comparison to check if the given number is in the specified range.\nIf the second parameter, `end`, is not specified, the range is considered to be from `0` to `start`.\n"
},
"insertAfter": {
"prefix": "30s_insertAfter",
"body": [
"const insertAfter = (el, htmlString) => el.insertAdjacentHTML('afterend', htmlString);"
],
"description": "Inserts an HTML string after the end of the specified element.\n\nUse `el.insertAdjacentHTML()` with a position of `'afterend'` to parse `htmlString` and insert it after the end of `el`.\n"
},
"insertBefore": {
"prefix": "30s_insertBefore",
"body": [
"const insertBefore = (el, htmlString) => el.insertAdjacentHTML('beforebegin', htmlString);"
],
"description": "Inserts an HTML string before the start of the specified element.\n\nUse `el.insertAdjacentHTML()` with a position of `'beforebegin'` to parse `htmlString` and insert it before the start of `el`.\n"
},
"intersection": {
"prefix": "30s_intersection",
"body": [
"const intersection = (a, b) => {",
" const s = new Set(b);",
" return a.filter(x => s.has(x));",
"};"
],
"description": "Returns a list of elements that exist in both arrays.\n\nCreate a `Set` from `b`, then use `Array.prototype.filter()` on `a` to only keep values contained in `b`.\n"
},
"intersectionBy": {
"prefix": "30s_intersectionBy",
"body": [
"const intersectionBy = (a, b, fn) => {",
" const s = new Set(b.map(fn));",
" return a.filter(x => s.has(fn(x)));",
"};"
],
"description": "Returns a list of elements that exist in both arrays, after applying the provided function to each array element of both.\n\nCreate a `Set` by applying `fn` to all elements in `b`, then use `Array.prototype.filter()` on `a` to only keep elements, which produce values contained in `b` when `fn` is applied to them.\n"
},
"intersectionWith": {
"prefix": "30s_intersectionWith",
"body": [
"const intersectionWith = (a, b, comp) => a.filter(x => b.findIndex(y => comp(x, y)) !== -1);"
],
"description": "Returns a list of elements that exist in both arrays, using a provided comparator function.\n\nUse `Array.prototype.filter()` and `Array.prototype.findIndex()` in combination with the provided comparator to determine intersecting values.\n"
},
"invertKeyValues": {
"prefix": "30s_invertKeyValues",
"body": [
"const invertKeyValues = (obj, fn) =>",
" Object.keys(obj).reduce((acc, key) => {",
" const val = fn ? fn(obj[key]) : obj[key];",
" acc[val] = acc[val] || [];",
" acc[val].push(key);",
" return acc;",
" }, {});"
],
"description": "Inverts the key-value pairs of an object, without mutating it. The corresponding inverted value of each inverted key is an array of keys responsible for generating the inverted value. If a function is supplied, it is applied to each inverted key.\n\nUse `Object.keys()` and `Array.prototype.reduce()` to invert the key-value pairs of an object and apply the function provided (if any).\nOmit the second argument, `fn`, to get the inverted keys without applying a function to them.\n"
},
"is": {
"prefix": "30s_is",
"body": [
"const is = (type, val) => ![, null].includes(val) && val.constructor === type;"
],
"description": "Checks if the provided value is of the specified type.\n\nEnsure the value is not `undefined` or `null` using `Array.prototype.includes()`, and compare the `constructor` property on the value with `type` to check if the provided value is of the specified `type`.\n"
},
"isAbsoluteURL": {
"prefix": "30s_isAbsoluteURL",
"body": [
"const isAbsoluteURL = str => /^[a-z][a-z0-9+.-]*:/.test(str);"
],
"description": "Returns `true` if the given string is an absolute URL, `false` otherwise.\n\nUse a regular expression to test if the string is an absolute URL.\n"
},
"isAfterDate": {
"prefix": "30s_isAfterDate",
"body": [
"const isAfterDate = (dateA, dateB) => dateA > dateB;"
],
"description": "Check if a date is after another date.\n\nUse the greater than operator (`>`) to check if the first date comes after the second one.\n"
},
"isAnagram": {
"prefix": "30s_isAnagram",
"body": [
"const isAnagram = (str1, str2) => {",
" const normalize = str =>",
" str",
" .toLowerCase()",
" .replace(/[^a-z0-9]/gi, '')",
" .split('')",
" .sort()",
" .join('');",
" return normalize(str1) === normalize(str2);",
"};"
],
"description": "Checks if a string is an anagram of another string (case-insensitive, ignores spaces, punctuation and special characters).\n\nUse `String.toLowerCase()`, `String.prototype.replace()` with an appropriate regular expression to remove unnecessary characters, `String.prototype.split('')`, `Array.prototype.sort()` and `Array.prototype.join('')` on both strings to normalize them, then check if their normalized forms are equal.\n"
},
"isArrayLike": {
"prefix": "30s_isArrayLike",
"body": [
"const isArrayLike = obj => obj != null && typeof obj[Symbol.iterator] === 'function';"
],
"description": "Checks if the provided argument is array-like (i.e. is iterable).\n\nCheck if the provided argument is not `null` and that its `Symbol.iterator` property is a function.\n"
},
"isBeforeDate": {
"prefix": "30s_isBeforeDate",
"body": [
"const isBeforeDate = (dateA, dateB) => dateA < dateB;"
],
"description": "Check if a date is before another date.\n\nUse the less than operator (`<`) to check if the first date comes before the second one.\n"
},
"isBoolean": {
"prefix": "30s_isBoolean",
"body": [
"const isBoolean = val => typeof val === 'boolean';"
],
"description": "Checks if the given argument is a native boolean element.\n\nUse `typeof` to check if a value is classified as a boolean primitive.\n"
},
"isBrowser": {
"prefix": "30s_isBrowser",
"body": [
"const isBrowser = () => ![typeof window, typeof document].includes('undefined');"
],
"description": "Determines if the current runtime environment is a browser so that front-end modules can run on the server (Node) without throwing errors.\n\nUse `Array.prototype.includes()` on the `typeof` values of both `window` and `document` (globals usually only available in a browser environment unless they were explicitly defined), which will return `true` if one of them is `undefined`.\n`typeof` allows globals to be checked for existence without throwing a `ReferenceError`.\nIf both of them are not `undefined`, then the current environment is assumed to be a browser.\n"
},
"isBrowserTabFocused": {
"prefix": "30s_isBrowserTabFocused",
"body": [
"const isBrowserTabFocused = () => !document.hidden;"
],
"description": "Returns `true` if the browser tab of the page is focused, `false` otherwise.\n\nUse the `Document.hidden` property, introduced by the Page Visibility API to check if the browser tab of the page is visible or hidden.\n"
},
"isDivisible": {
"prefix": "30s_isDivisible",
"body": [
"const isDivisible = (dividend, divisor) => dividend % divisor === 0;"
],
"description": "Checks if the first numeric argument is divisible by the second one.\n\nUse the modulo operator (`%`) to check if the remainder is equal to `0`.\n"
},
"isDuplexStream": {
"prefix": "30s_isDuplexStream",
"body": [
"const isDuplexStream = val =>",
" val !== null &&",
" typeof val === 'object' &&",
" typeof val.pipe === 'function' &&",
" typeof val._read === 'function' &&",
" typeof val._readableState === 'object' &&",
" typeof val._write === 'function' &&",
" typeof val._writableState === 'object';"
],
"description": "Checks if the given argument is a duplex (readable and writable) stream.\n\nCheck if the value is different from `null`, use `typeof` to check if a value is of type `object` and the `pipe` property is of type `function`.\nAdditionally check if the `typeof` the `_read`, `_write` and `_readableState`, `_writableState` properties are `function` and `object` respectively.\n"
},
"isEmpty": {
"prefix": "30s_isEmpty",
"body": [
"const isEmpty = val => val == null || !(Object.keys(val) || val).length;"
],
"description": "Returns true if the a value is an empty object, collection, has no enumerable properties or is any type that is not considered a collection.\n\nCheck if the provided value is `null` or if its `length` is equal to `0`.\n"
},
"isEven": {
"prefix": "30s_isEven",
"body": [
"const isEven = num => num % 2 === 0;"
],
"description": "Returns `true` if the given number is even, `false` otherwise.\n\nChecks whether a number is odd or even using the modulo (`%`) operator.\nReturns `true` if the number is even, `false` if the number is odd.\n"
},
"isFunction": {
"prefix": "30s_isFunction",
"body": [
"const isFunction = val => typeof val === 'function';"
],
"description": "Checks if the given argument is a function.\n\nUse `typeof` to check if a value is classified as a function primitive.\n"
},
"isLowerCase": {
"prefix": "30s_isLowerCase",
"body": [
"const isLowerCase = str => str === str.toLowerCase();"
],
"description": "Checks if a string is lower case.\n\nConvert the given string to lower case, using `String.toLowerCase()` and compare it to the original.\n"
},
"isNegativeZero": {
"prefix": "30s_isNegativeZero",
"body": [
"const isNegativeZero = val => val === 0 && 1 / val === -Infinity;"
],