vim-snippets/UltiSnips/javascript-node.snippets

66 lines
1.0 KiB
Plaintext
Raw Permalink Normal View History

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