vimrc/sources_non_forked/vim-snippets/UltiSnips/javascript-node.snippets

66 lines
1 KiB
Text
Raw Normal View History

2015-12-08 13:20:04 +00:00
priority -50
2019-08-22 15:36:17 +00:00
snippet #! "#!/usr/bin/env node" b
2015-12-08 13:20:04 +00:00
#!/usr/bin/env node
endsnippet
snippet vreq "assign a CommonJS-style module to a var"
2017-02-11 13:01:38 +00:00
var ${0:${1/(.+\/)*(\w+)(-|\b|$)(\..+$)?/\u$2/g}} = require('$1');
2015-12-08 13:20:04 +00:00
endsnippet
snippet ex "module.exports"
2017-02-11 13:01:38 +00:00
module.exports = $1;
2015-12-08 13:20:04 +00:00
endsnippet
snippet hcs "http.createServer"
2017-02-11 13:01:38 +00:00
http.createServer($1).listen($2);
2015-12-08 13:20:04 +00:00
endsnippet
snippet ncs "net.createServer"
net.createServer(function(${1:socket}){
2017-02-11 13:01:38 +00:00
$1.on('data', function(${3:data}){
$4
2015-12-08 13:20:04 +00:00
});
2017-02-11 13:01:38 +00:00
$1.on('end', function(){
$5
2015-12-08 13:20:04 +00:00
});
}).listen(${6:8124});
endsnippet
snippet pipe "pipe"
2017-02-11 13:01:38 +00:00
pipe(${1:stream})$2
2015-12-08 13:20:04 +00:00
endsnippet
# Express snippets
snippet eget "express GET"
2017-02-11 13:01:38 +00:00
${1:app}.get('$2', $3);
2015-12-08 13:20:04 +00:00
endsnippet
snippet epost "express POST"
2017-02-11 13:01:38 +00:00
${1:app}.post('$2', $3);
2015-12-08 13:20:04 +00:00
endsnippet
snippet eput "express PUT"
2017-02-11 13:01:38 +00:00
${1:app}.put('$2', $3);
2015-12-08 13:20:04 +00:00
endsnippet
snippet edelete "express DELETE"
2017-02-11 13:01:38 +00:00
${1:app}.delete('$2', $3);
2015-12-08 13:20:04 +00:00
endsnippet
# process snippets
snippet stdout "stdout"
process.stdout
endsnippet
snippet stdin "stdin"
process.stdin
endsnippet
snippet stderr "stderr"
process.stderr
endsnippet