Coder Social home page Coder Social logo

madskristensen / atom-javascript-snippets Goto Github PK

View Code? Open in Web Editor NEW

This project forked from zenorocha/atom-javascript-snippets

0.0 3.0 1.0 63 KB

JavaScript & NodeJS Snippets for Atom Editor

Home Page: https://atom.io/packages/javascript-snippets

JavaScript 3.97% CoffeeScript 96.03%

atom-javascript-snippets's Introduction

JavaScript Snippets for Atom Build Status

Demo

Install

Go to Atom > Preferences... then search for JavaScript Snippets in Packages tab. Restart atom.

Development

$ cd ~/.atom/packages
$ git clone https://github.com/zenorocha/atom-javascript-snippets.git
$ cd atom-javascript-snippets
$ apm install
$ apm link

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) {
	${0:// body...}
});

[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(${2:elem});

[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}) {
	${0:// body...}
});

[fi] for in

for (${1:prop} in ${2:obj}) {
	if (${2:obj}.hasOwnProperty(${1:prop})) {
		${0:// body...}
	}
}

Function

[fn] function

function ${1:methodName} (${2:arguments}) {
	${0:// body...}
}

[afn] anonymous function

function(${1:arguments}) {
	${0:// body...}
}

[pr] prototype

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

[iife] immediately-invoked function expression

(function(window, document, undefined) {
	${0:// body...}
})(window, 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:// body...}
}

JSON

[jp] JSON.parse

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

[js] JSON.stringify

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

Timer

[si] setInterval

setInterval(function() {
	${0:// body...}
}, ${1:delay});

[st] setTimeout

setTimeout(function() {
	${0:// body...}
}, ${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() {
	${0:// body...}
});

[ita] it asynchronous

it('${1:description}', function(done) {
	${0:// body...}
});

[its] it synchronous

it('${1:description}', function() {
	${0:// body...}
});

[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 Release list.

License

MIT License © Zeno Rocha

atom-javascript-snippets's People

Contributors

brunocoelho avatar carlosliu avatar grvcoelho avatar morenoh149 avatar sergiopvilar avatar zenorocha avatar

Watchers

 avatar  avatar  avatar

Forkers

modulexcite

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.