Created
June 30, 2016 19:41
-
-
Save augustine-tran/c0f58c6136c96d82d864a3c165e62ce4 to your computer and use it in GitHub Desktop.
My Atom snippets for NodeJS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Your snippets | |
# | |
# Atom snippets allow you to enter a simple prefix in the editor and hit tab to | |
# expand the prefix into a larger code block with templated values. | |
# | |
# You can create a new snippet in this file by typing "snip" and then hitting | |
# tab. | |
# | |
# An example CoffeeScript snippet to expand log to console.log: | |
# | |
# '.source.coffee': | |
# 'Console log': | |
# 'prefix': 'log' | |
# 'body': 'console.log $1' | |
# | |
# Each scope (e.g. '.source.coffee' above) can only be declared once. | |
# | |
# This file uses CoffeeScript Object Notation (CSON). | |
# If you are unfamiliar with CSON, you can read more about it in the | |
# Atom Flight Manual: | |
# https://atom.io/docs/latest/using-atom-basic-customization#cson | |
'.source.js': | |
'logger.debug': | |
'prefix': 'logdebug' | |
'body': "logger.debug('$1', $2)" | |
'promisify': | |
'prefix': 'promisify, pfy' | |
'body': 'const ${1:method}\$ = Promise.promisify(${2:object}.$1, {context: ${2:object}})$3' | |
'logger.error': | |
'prefix': 'logerror' | |
'body': "logger.error('$1', $2)" | |
'promise then catch': | |
'prefix': 'pfthen' | |
'body': """ | |
${1:method}(${2:parameter}) | |
.then(${3:results} => { | |
$4 | |
}) | |
.catch(err => { | |
done(err) | |
}) | |
""" | |
'it should': | |
'prefix': 'itshould' | |
'body': """ | |
it('$1', ($2) => { | |
$3 | |
}) | |
""" | |
'it should async': | |
'prefix': 'itasync' | |
'body': """ | |
it('$1', (done) => { | |
$2 | |
}) | |
""" | |
'describe': | |
'prefix': 'describe' | |
'body': """ | |
describe('$1', () => { | |
$2 | |
}) | |
""" | |
'superagent repost post': | |
'prefix': 'reqpost' | |
'body': """ | |
request(app) | |
.post($1) | |
.send($2) | |
.set('x-access-token', validToken) | |
.expect('Content-Type', /json/) | |
.expect(200) | |
.end(function (err, res) { | |
if (err) return done(err) | |
$3 | |
done(); | |
}) | |
""" | |
'superagent repost get': | |
'prefix': 'reqget' | |
'body': """ | |
request(app) | |
.get($1) | |
.set('x-access-token', validToken) | |
.expect('Content-Type', /json/) | |
.expect(200) | |
.end(function (err, res) { | |
if (err) return done(err) | |
$2 | |
done() | |
}) | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment