JavaScript & NodeJS Snippets for Sublime Text 2/3
JavaScript
Clone or download
Latest commit 22d4852 Nov 19, 2017
Permalink
Failed to load latest commit information.
.editorconfig Source formatting Jan 9, 2014
.gitignore Fix mixed tabs and spaces and automate the process to discover it Nov 9, 2013
.travis.yml Add Travis CI Nov 9, 2013
Gruntfile.js Fetch lint options via .editorconfig file Jan 9, 2014
README.md Adds docs for #26 Feb 10, 2016
bdd-describe.sublime-snippet Adds support for JSX and TypeScript Jan 11, 2016
bdd-ita.sublime-snippet Adds support for JSX and TypeScript Jan 11, 2016
bdd-itp.sublime-snippet Adds support for JSX and TypeScript Jan 11, 2016
bdd-its.sublime-snippet Adds support for JSX and TypeScript Jan 11, 2016
console-dir.sublime-snippet Adds support for JSX and TypeScript Jan 11, 2016
console-error.sublime-snippet Adds support for JSX and TypeScript Jan 11, 2016
console-info.sublime-snippet Adds support for JSX and TypeScript Jan 11, 2016
console-log.sublime-snippet Adds support for JSX and TypeScript Jan 11, 2016
console-warn.sublime-snippet Adds support for JSX and TypeScript Jan 11, 2016
dom-addEvent.sublime-snippet Adds support for JSX and TypeScript Jan 11, 2016
dom-attrGet.sublime-snippet Adds support for JSX and TypeScript Jan 11, 2016
dom-attrRemove.sublime-snippet Adds support for JSX and TypeScript Jan 11, 2016
dom-attrSet.sublime-snippet Adds support for JSX and TypeScript Jan 11, 2016
dom-childAppend.sublime-snippet Update dom-childAppend.sublime-snippet Sep 26, 2017
dom-childRemove.sublime-snippet Adds support for JSX and TypeScript Jan 11, 2016
dom-classAdd.sublime-snippet Adds support for JSX and TypeScript Jan 11, 2016
dom-classRemove.sublime-snippet Adds support for JSX and TypeScript Jan 11, 2016
dom-classToggle.sublime-snippet Adds support for JSX and TypeScript Jan 11, 2016
dom-createDocumentFragment.sublime-snippet Fixes createDocumentFragment() argument Feb 10, 2016
dom-createElement.sublime-snippet Adds support for JSX and TypeScript Jan 11, 2016
dom-getByClass.sublime-snippet Adds support for JSX and TypeScript Jan 11, 2016
dom-getById.sublime-snippet Adds support for JSX and TypeScript Jan 11, 2016
dom-getByTag.sublime-snippet Adds support for JSX and TypeScript Jan 11, 2016
dom-innerHTML.sublime-snippet Adds support for JSX and TypeScript Jan 11, 2016
dom-query.sublime-snippet Adds support for JSX and TypeScript Jan 11, 2016
dom-queryAll.sublime-snippet Adds support for JSX and TypeScript Jan 11, 2016
dom-textContent.sublime-snippet Adds support for JSX and TypeScript Jan 11, 2016
for-each.sublime-snippet Adds support for JSX and TypeScript Jan 11, 2016
for-in.sublime-snippet Adds support for JSX and TypeScript Jan 11, 2016
function-anonymous.sublime-snippet Adds support for JSX and TypeScript Jan 11, 2016
function-apply.sublime-snippet Adds support for JSX and TypeScript Jan 11, 2016
function-call.sublime-snippet Adds support for JSX and TypeScript Jan 11, 2016
function-iife.sublime-snippet iife tab to select the parameters easy to delete or change Jan 18, 2016
function-objectProperty.sublime-snippet Adds support for JSX and TypeScript Jan 11, 2016
function-prototype.sublime-snippet Adds support for JSX and TypeScript Jan 11, 2016
function.sublime-snippet Adds support for JSX and TypeScript Jan 11, 2016
json-parse.sublime-snippet Adds support for JSX and TypeScript Jan 11, 2016
json-stringify.sublime-snippet Adds support for JSX and TypeScript Jan 11, 2016
misc-alert.sublime-snippet Adds support for JSX and TypeScript Jan 11, 2016
misc-confirm.sublime-snippet Adds support for JSX and TypeScript Jan 11, 2016
misc-debugger.sublime-snippet Adds support for JSX and TypeScript Jan 11, 2016
misc-prompt.sublime-snippet Adds support for JSX and TypeScript Jan 11, 2016
misc-useStrict.sublime-snippet Adds support for JSX and TypeScript Jan 11, 2016
node-assertDeepEqual.sublime-snippet Adds support for JSX and TypeScript Jan 11, 2016
node-assertEqual.sublime-snippet Adds support for JSX and TypeScript Jan 11, 2016
node-assertNotEqual.sublime-snippet Adds support for JSX and TypeScript Jan 11, 2016
node-moduleExports.sublime-snippet Adds support for JSX and TypeScript Jan 11, 2016
node-processExit.sublime-snippet Adds support for JSX and TypeScript Jan 11, 2016
node-require.sublime-snippet Adds support for JSX and TypeScript Jan 11, 2016
package.json Update dependencies Jun 28, 2016
timer-setInterval.sublime-snippet Adds support for JSX and TypeScript Jan 11, 2016
timer-setTimeout.sublime-snippet Adds support for JSX and TypeScript Jan 11, 2016

README.md

JavaScript Snippets for Sublime Build Status

Demo

Install

To install through Package Control, search for JavaScript & NodeJS Snippets. If you still don't have Package Control in Sublime Text, go get it. It's pure awesomeness.

If you prefer to install it manually, you can download the package and put it inside your Packages directory. It should work but will not update automatically.

Console

[cd] console.dir

console.dir(${1:obj});

[ce] console.error

console.error(${1:obj});

[ci] console.info

console.info(${1:obj});

[cl] console.log

console.log(${1:obj});

[cw] console.warn

console.warn(${1:obj});

[de] debugger

debugger;

DOM

[ae] addEventListener

${1:document}.addEventListener('${2:event}', function(e) {
	${3}
});

[ac] appendChild

${1:document}.appendChild(${2:elem});

[rc] removeChild

${1:document}.removeChild(${2:elem});

[cel] createElement

${1:document}.createElement(${2:elem});

[cdf] createDocumentFragment

${1:document}.createDocumentFragment();

[ca] classList.add

${1:document}.classList.add('${2:class}');

[ct] classList.toggle

${1:document}.classList.toggle('${2:class}');

[cr] classList.remove

${1:document}.classList.remove('${2:class}');

[gi] getElementById

${1:document}.getElementById('${2:id}');

[gc] getElementsByClassName

${1:document}.getElementsByClassName('${2:class}');

[gt] getElementsByTagName

${1:document}.getElementsByTagName('${2:tag}');

[ga] getAttribute

${1:document}.getAttribute('${2:attr}');

[sa] setAttribute

${1:document}.setAttribute('${2:attr}', ${3:value});

[ra] removeAttribute

${1:document}.removeAttribute('${2:attr}');

[ih] innerHTML

${1:document}.innerHTML = '${2:elem}';

[tc] textContent

${1:document}.textContent = '${2:content}';

[qs] querySelector

${1:document}.querySelector('${2:selector}');

[qsa] querySelectorAll

${1:document}.querySelectorAll('${2:selector}');

Loop

[fe] forEach

${1:myArray}.forEach(function(${2:elem}) {
	${3}
});

[fi] for in

for (${1:prop} in ${2:obj}) {
	if (${2:obj}.hasOwnProperty(${1:prop})) {
		${3}
	}
}

Function

[fn] function

function ${1:methodName}(${2:arguments}) {
	${3}
}

[afn] anonymous function

function(${1:arguments}) {
	${2}
}

[pr] prototype

${1:ClassName}.prototype.${2:methodName} = function(${3:arguments}) {
	${4}
}

[iife] immediately-invoked function expression

(function(${1:window}, ${2:document}) {
	${1}
})(${1:window}, ${2:document});

[call] function call

${1:methodName}.call(${2:context}, ${3:arguments})

[apply] function apply

${1:methodName}.apply(${2:context}, [${3:arguments}])

[ofn] function as a property of an object

${1:functionName}: function (${2:arguments}) {
	${3}
}

JSON

[jp] JSON.parse

JSON.parse(${1:obj});

[js] JSON.stringify

JSON.stringify(${1:obj});

Timer

[si] setInterval

setInterval(function() {
	${2}
}, ${1:delay});

[st] setTimeout

setTimeout(function() {
	${2}
}, ${1:delay});

NodeJS

[ase] assert.equal

assert.equal(${1:actual}, ${2:expected});

[asd] assert.deepEqual

assert.deepEqual(${1:actual}, ${2:expected});

[asn] assert.notEqual

assert.notEqual(${1:actual}, ${2:expected});

[me] module.exports

module.exports = ${1:name};

[pe] process.exit

process.exit(${1:code});

[re] require

require('${1:module}');

BDD

[desc] describe

describe('${1:description}', function() {
	${2}
});

[ita] it asynchronous

it('${1:description}', function(done) {
	${2}
});

[its] it synchronous

it('${1:description}', function() {
	${2}
});

[itp] it pending

it('${1:description}');

Misc

[us] use strict

'use strict';

[al] alert

alert('${1:msg}');

[co] confirm

confirm('${1:msg}');

[pm] prompt

prompt('${1:msg}');

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -m 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

History

Check Releases for detailed changelog.

License

MIT License © Zeno Rocha