Skip to content

Instantly share code, notes, and snippets.

@uiur
Created May 27, 2015 03:02
Show Gist options
  • Save uiur/968669b0ca8bd1ce70f8 to your computer and use it in GitHub Desktop.
Save uiur/968669b0ca8bd1ce70f8 to your computer and use it in GitHub Desktop.
Atom javascript snippets that comform to JavaScript Standard Style
'.source.js':
'Prototype':
'prefix': 'proto'
'body': '${1:class_name}.prototype.${2:method_name} = function (${3:first_argument}) {\n\t${0:// body...}\n}'
'Function':
'prefix': 'fun'
'body': 'function ${1:function_name} (${2:argument}) {\n\t${0:// body...}\n}'
'Generator':
'prefix': 'gen',
'body': 'function* ${1:function_name} (${2:argument}) {\n\t${0:// body...}\n}'
'Immediately-Invoked Function Expression':
'prefix': 'iife'
'body': '(function() {\n\t${1:\'use strict\';\n}\t$2\n}())'
'log':
'prefix': 'log'
'body': 'console.log($1)$0'
'warn':
'prefix': 'warn'
'body': 'console.warn($1)$0'
'error':
'prefix': 'error'
'body': 'console.error($1)$0'
'inspect':
'prefix': 'inspect'
'body': 'console.log(require(\'util\').inspect($0, { depth: null }))'
'new Promise':
'prefix': 'prom'
'body': 'new Promise(function(resolve, reject) {\n\t$1\n})$0'
'setInterval function':
'prefix': 'interval'
'body': 'setInterval(${2:function () {\n\t$3\n}}, ${1:10})'
'setTimeout function':
'prefix': 'timeout'
'body': 'setTimeout(${2:function () {\n\t$3\n}}, ${1:10})'
'CommonJS require':
'prefix': 'req'
'body': 'var ${1:module} = require(\'${1:module}\')'
'Class':
'prefix': 'class'
'body': 'class ${1:ClassName} {\n\tconstructor ($2) {\n\t\t$3\n\t}\n}'
@uiur
Copy link
Author

uiur commented May 27, 2015

Just copy and paste to snippets.cson in your atom setting dir

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment