From 9cf1d0e50249eaf0f23b3d4a3ba1e31ede2aa034 Mon Sep 17 00:00:00 2001 From: Connor Atherton Date: Wed, 20 Aug 2014 20:05:28 +0100 Subject: [PATCH] Modify js proto and add node snippets --- snippets/javascript/javascript.node.snippets | 50 ++++++++++++++++++++ snippets/javascript/javascript.snippets | 9 ++-- 2 files changed, 54 insertions(+), 5 deletions(-) create mode 100644 snippets/javascript/javascript.node.snippets diff --git a/snippets/javascript/javascript.node.snippets b/snippets/javascript/javascript.node.snippets new file mode 100644 index 0000000..4a42959 --- /dev/null +++ b/snippets/javascript/javascript.node.snippets @@ -0,0 +1,50 @@ +# module exports +snippet ex + module.exports = ${1}; +# require +snippet re + var ${1} = require("${2:module_name}"); +# EventEmitter +snippet on + on('${1:event_name}', function(${2:stream}) { + ${3} + }); +snippet emit + emit('${1:event_name}', ${2:args}); +snippet once + once('${1:event_name}', function(${2:stream}) { + ${3} + }); +# http. User js function snippet as handler +snippet http + http.createServer(${1:handler}).listen(${2:port_number}); +# net +snippet net + net.createServer(function(${1:socket}){ + ${1}.on('data', function('data'){ + ${2} + ]}); + ${1}.on('end', function(){ + ${3} + }); + }).listen(${4:8124}); +# Stream snippets +snippet p + pipe(${1:stream})${2} +# Express snippets +snippet eget + ${1:app}.get('${2:route}', ${3:handler}); +snippet epost + ${1:app}.post('${2:route}', ${3:handler}); +snippet eput + ${1:app}.put('${2:route}', ${3:handler}); +snippet edel + ${1:app}.delete('${2:route}', ${3:handler}); +# process snippets +snippet stdin + process.stdin +snippet stdout + process.stdout +snippet stderr + process.stderr + diff --git a/snippets/javascript/javascript.snippets b/snippets/javascript/javascript.snippets index d20d713..f4ef351 100644 --- a/snippets/javascript/javascript.snippets +++ b/snippets/javascript/javascript.snippets @@ -1,7 +1,6 @@ -# Prototype +# prototype snippet proto - ${1:class_name}.prototype.${2:method_name} = - function(${3:first_argument}) { + ${1:class_name}.prototype.${2:method_name} = function(${3:first_argument}) { ${0:// body...} }; # Function @@ -11,12 +10,12 @@ snippet fun } # Anonymous Function snippet f - function (${1}) { + function(${1}) { ${0} } # Immediate function snippet (f - (function (${1}) { + (function(${1}) { ${0} }(${2})); # if