Skip to content

Instantly share code, notes, and snippets.

@chrisglick
Created July 22, 2018 20:14
Show Gist options
  • Save chrisglick/2fda2db0530ace02d5fde03f2cc8a152 to your computer and use it in GitHub Desktop.
Save chrisglick/2fda2db0530ace02d5fde03f2cc8a152 to your computer and use it in GitHub Desktop.
{
// Place your global snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and
// description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope
// is left empty or omitted, the snippet gets applied to all languages. 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": {
// "scope": "javascript,typescript",
// "prefix": "log",
// "body": [
// "console.log('$1');",
// "$2"
// ],
// "description": "Log output to console"
// }
"logn": {
"scope": "javascript,typescript",
"prefix": "logn",
"body": "console.log(`$1:`, $1)"
},
"Failable async": {
"scope": "javascript,typescript",
"prefix": "failasync",
"body": "const $1 = await \nif (isFailure($1)) return $1\nconst $2 = payload($1)"
},
"Failable sync": {
"scope": "javascript,typescript",
"prefix": "failsync",
"body": "const $1 = \nif (isFailure($1)) return $1\nconst $2 = payload($1)"
},
"jstr": {
"scope": "javascript,typescript",
"prefix": "jstr",
"body": "JSON.stringify($1)"
},
"assres": {
"scope": "javascript,typescript",
"prefix": "assres",
"body": "const result = $1()\nassertSuccess(result)"
},
"dassres": {
"scope": "javascript,typescript",
"prefix": "dassres",
"body": "describe(`$1()`, () => {\nit(`should $2`, () => {\nconst result = $1()\nassertSuccess(result)\n})\n})"
},
"newFunc": {
"scope": "javascript,typescript",
"prefix":"newFunc",
"body":"const $1 = () => {return success()}"
},
"describe": {
"scope": "javascript,typescript",
"prefix": "describe",
"body": "describe(`$1`, () => {\n$2\n})"
},
"itsync": {
"scope": "javascript,typescript",
"prefix": "itsync",
"body": "it(`should $1`, () => {\n$2\n})"
},
"itasync": {
"scope": "javascript,typescript",
"prefix": "itasync",
"body": "it(`should $1`, async () => {\n$2\n})"
},
"failable": {
"scope": "javascript,typescript",
"prefix": "failable",
"body": "const { $1 } = require(`@pheasantplucker/failables`)"
},
"async arrow fn": {
"scope": "javascript,typescript",
"prefix": "asyncfn",
"body": "async () => {\n\t$1\n}"
},
"sync arrow fn": {
"scope": "javascript,typescript",
"prefix": "sync",
"body": "() => {\n\t$1\n}"
},
"promise": {
"scope": "javascript,typescript",
"prefix": "promise",
"body": "new Promise((resolve) => {\n\t$1\n})"
},
"trycatch": {
"scope": "javascript,typescript",
"prefix": "try",
"body": "try {\n\t$1\n} catch (e) {\n\treturn failure(e.toString())\n}"
},
"import deepequal as equal": {
"scope": "javascript,typescript",
"prefix": "reqass",
"body": "const equal = require(\"assert\").deepEqual"
},
"if fail return failure": {
"scope": "javascript,typescript",
"prefix": "rf",
"body": "if (isFailure($1)) return $1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment