• Stars
    star
    465
  • Rank 94,287 (Top 2 %)
  • Language
    JavaScript
  • Created over 11 years ago
  • Updated about 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

JavaScript & NodeJS Snippets for Sublime Text 2/3

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

More Repositories

1

clipboard.js

✂️ Modern copy to clipboard. No Flash. Just 3kb gzipped 📋
JavaScript
34,022
star
2

alfred-workflows

🤘 A collection of Alfred 3 and 4 workflows that will rock your world
12,272
star
3

browser-diet

🍟 The definitive front-end performance guide
CSS
2,202
star
4

voice-elements

🔈 Web Component wrapper to the Web Speech API, that allows you to do voice recognition and speech synthesis using Polymer
HTML
1,355
star
5

codecopy

A browser extension that adds copy to clipboard buttons on every code block
JavaScript
1,029
star
6

zenorocha.com

My personal website ❤️
JavaScript
404
star
7

jquery-github

A jQuery plugin to display your Github Repositories
JavaScript
276
star
8

diveintohtml5

A portuguese translation of Dive Into HTML5 online book
HTML
200
star
9

delegate

Lightweight event delegation
JavaScript
183
star
10

atom-javascript-snippets

JavaScript & NodeJS Snippets for Atom Editor
168
star
11

select

Programmatically select the text of a HTML element
JavaScript
165
star
12

generator-firefox-os

Yeoman generator for Firefox OS apps
JavaScript
147
star
13

good-listener

A more versatile way of adding & removing event listeners
JavaScript
142
star
14

browser-calories

🍰 The easiest way to measure your performance budget
JavaScript
131
star
15

wormz

HTML5 Canvas Experiment featured in Chrome Experiments
JavaScript
113
star
16

my-coding-style

My own coding conventions for JavaScript development ⚡
77
star
17

ama

💬 Ask me anything!
71
star
18

sublime-preferences

The whole list of plugins, snippets and settings that I use on Sublime Text
60
star
19

14habits.com

The source code of 14habits.com
JavaScript
48
star
20

avatar-elements

Under construction 🚧 Avatars made easy with Web Components
JavaScript
35
star
21

document.queryCommandSupported

Polyfill for document.queryCommandSupported that fixes known bugs on Gecko and Blink
JavaScript
30
star
22

HTML5-Canvas

HTML5 tutorial about Canvas + Three.js
JavaScript
28
star
23

dracula-theme

HTML
24
star
24

talks

Slides (and more) from my presentations
JavaScript
22
star
25

old-dotfiles

My OS X dotfiles.
Shell
17
star
26

Estudos-Java

Resolução de exercícios por Zeno Rocha da matéria de Projeto e Construções de Sistemas, lecionada pelo professor Alexandre Correa na Universidade Federal do Estado de Rio de Janeiro.
Java
16
star
27

browser-calories-api

🍦 Microservice that fetches Web Performance metrics
JavaScript
15
star
28

HTML5-Local-Storage

HTML5 tutorial about the Web Storage API - http://goo.gl/ZDsdz
JavaScript
12
star
29

zenorocha

10
star
30

mintlify-emails

💌 Mintlify Emails
TypeScript
10
star
31

wedeploy-ui

🎨 The new set of UI components behind WeDeploy.com, Console, and Admin
CSS
8
star
32

infisical-emails

💌 Infisical Emails
JavaScript
8
star
33

bytetalk

JavaScript
7
star
34

booth-emails

💌 Booth.ai Emails
TypeScript
6
star
35

HTML5-Script

HTML5 demo testing async atributte on script tag
5
star
36

outerbase-emails

💌 Outerbase emails
TypeScript
4
star
37

web-log

My online trail
3
star
38

sante-emails

TypeScript
3
star
39

infinia-emails

💌 Infinia Emails
TypeScript
3
star
40

spawn-local-bin

A child_process.spawn wrapper that inherits stdio and adds local bin's to the process.env path
JavaScript
3
star
41

vercel-resend-integration

TypeScript
2
star
42

zenorocha.github.io

CSS
2
star
43

react-email-docs

2
star
44

wedocs

Documentation for WeDeploy
2
star
45

railway-emails

TypeScript
2
star
46

raycast-emails

TypeScript
2
star
47

resend-ruby-example

This example shows how to use Resend with Ruby
Ruby
1
star
48

liferay-learn-old

HTML
1
star
49

compound-emails

TypeScript
1
star
50

liveblocks-emails

TypeScript
1
star
51

max-emails

TypeScript
1
star