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

Node Completions

by james2doyle ST2/ST3

A collection of completions/snippets for node.js v8.x

Details

  • 2017.09.28.17.47.38
  • github.​com
  • github.​com
  • 4 weeks ago
  • 57 minutes ago
  • 4 years ago

Installs

  • Total 44K
  • Win 22K
  • OS X 13K
  • Linux 9K
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 Sep 9 Sep 8
Windows 14 13 22 30 19 15 23 29 8 18 16 13 14 11 23 22 18 13 13 14 9 16 17 15 17 16 22 24 39 15 18 23 17 26 19 43 22 16 23 25 24 18 14 12 15 9
OS X 8 3 10 3 11 13 6 8 5 8 12 5 4 8 9 8 4 12 9 11 8 7 4 8 4 7 7 8 8 5 6 4 3 11 7 7 7 7 8 12 6 8 8 1 4 5
Linux 5 3 8 9 9 6 10 9 7 5 8 9 6 6 7 6 6 9 6 7 9 9 2 6 8 5 8 10 2 9 5 6 6 8 10 6 6 6 9 11 7 8 2 1 6 3

Readme

Source
raw.​githubusercontent.​com

sublime-node-snippets

The majority of snippets for node v8.x. There are 1083 total right now.

Installing

Package Control

Just look for Node Completions on Package Control.

Manual

  • Open the Commands Palette (command+shift+p)
  • Package Control: Add Repository
  • Past in this repos URL
  • Press Enter
  • Open the palette again
  • press enter on “sublime-node-snippets”
  • watch it install

Using

Pressing . (period) will end the snippet lookup.

You will have better results if you pretend the period isn't needed. So if you are looking for fs.readdir, you would type fsread and you would see the results coming up.

Snippet Categories

  • Assertion Testing
  • Buffer
  • Child Processes
  • Cluster
  • Console
  • Crypto
  • DNS
  • Domain
  • Errors
  • Events
  • File System
  • Globals
  • HTTP
  • HTTP/2
  • HTTPS
  • Inspector
  • Modules
  • Net
  • OS
  • Path
  • Performance Hooks
  • Process
  • Punycode
  • Query Strings
  • Readline
  • REPL
  • Stream
  • String Decoder
  • Timers
  • TLS/SSL
  • TTY
  • UDP/Datagram
  • URL
  • Utilities
  • V8
  • VM
  • ZLIB

Building

I went to each page of the node docs, and copied the functions. Then I wrote a converter to take each function and convert it to a snippet.

For Example, this line:

setTimeout(fun, delay)

Is going to get converted to:

setTimeout(${1:fun}, ${2:delay})${0}

When the word callback appears, it will convert it to the standard fun snippet.

fs.readdir(path, callback)

will become

fs.readdir(${1:path}, function(${2:args}){
  ${3:// body}
})${0}

sources.txt

This file is cool. It is just a line-by-line output of the node docs functions. This is the file that is raked over to generate the snippets.

Running The Build

Just run node build.js and it will rake the sources.txt file and then write the new snippet in the snippets folder.

Everything before the first ( will be used as the filename.

Adding New Snippets

Here is how I quickly got all these snippets. I will use Express as an example since it isn't in here.

First I went to the docs for the framework, and I looked to see what the code examples were wrapped in.

For the express docs site, the codes are show in section h3 tags. So to quickly get the list, I ran the following code:

Array.prototype.slice.call(document.querySelectorAll("section h3"), 0).map(function(item){
  return item.textContent.trim();
}).join("\n");

Then copied the output and pasted it in the sources.txt file. Done!

The word callback will automagically be converted into a function.

Contributing

Just add (or edit) a line in the source file. Then run node build.js to generate the new snippets.

License

The MIT License

Copyright © 2014 James Doyle james2doyle@gmail.com

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.