ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

Async Snippets

by jleonard ALL

Sublime Text 2 package of snippets for node/async

Labels snippets

Details

  • 2014.01.03.22.38.02
  • github.​com
  • github.​com
  • 11 years ago
  • 59 minutes ago
  • 12 years ago

Installs

  • Total 2K
  • Win 1K
  • Mac 657
  • Linux 411
Oct 24 Oct 23 Oct 22 Oct 21 Oct 20 Oct 19 Oct 18 Oct 17 Oct 16 Oct 15 Oct 14 Oct 13 Oct 12 Oct 11 Oct 10 Oct 9 Oct 8 Oct 7 Oct 6 Oct 5 Oct 4 Oct 3 Oct 2 Oct 1 Sep 30 Sep 29 Sep 28 Sep 27 Sep 26 Sep 25 Sep 24 Sep 23 Sep 22 Sep 21 Sep 20 Sep 19 Sep 18 Sep 17 Sep 16 Sep 15 Sep 14 Sep 13 Sep 12 Sep 11 Sep 10
Windows 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0
Mac 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Linux 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Readme

Source
raw.​githubusercontent.​com

Sublime Text 2 Async-Snippets

This package contains Sublime Text 2 snippets to be used with the Async .js utility.

In order to use the snippets, enter the shortcode and press Tab (or whatever you have set as completion key).

Included are all snippets listed below. $1, $2, etc. show the position where the caret will appear whenever you press the tab key inside the snippet.


async_foreach

async.forEach(
  ${1:array}, 
  function(item,callback){
    ${2:callback();}
  }, 
  function(err){
    // if any of the saves produced an error, err would equal that error
    if(err){
      ${3}
    }else{
      ${4}
    }
  }
);

async_parallel

async.parallel({
    ${1:one}: function(callback){
        ${2://body}
    },
    ${3:two}: function(callback){
        ${4://body}
    },
},
function(err, ${5:results}) {
    // results now equals: {one: 1, two: 2}
    $6
});

async_series

async.series({
  ${1:one}: function(callback){
      ${2:callback(null,{})}
  },
  ${3:two}: function(callback){
      ${4:callback(null,{})}
  },
},
function(err, ${5:results}) {
  // results is now equal to: {one: 1, two: 2}
  ${6}
});

async_waterfall

async.waterfall([
  function(callback){
      callback(null, ${1:'one'}, ${2:'two'});
  },
  function(${3:arg1}, ${4:arg2}, callback){
      callback(null, ${5:'three'});
  },
  function(${6:arg1}, callback){
      // arg1 now equals 'three'
      callback(null, ${7:'done'});
  }
], function (err, ${8:result}) {
  // result now equals 'done'    
});