NPM Everywhere

Azer Koçulu / @azerbike









November 2013 

Title

What is NPM?

It hosts JavaScript libraries, with versions.

 

 

It was built for NodeJS, which implements CommonJS modules


It grew  really fast...






Prolific library authors
 followed and recommended Unix Philosopy





"Do one thing well." 

"Compose larger units out of smaller, independent units of functionality."

From @SubStack's JingJS 2013 slides  





NPM works for front-end development, too. You can Browserify any NodeJS library.

Try: requirebin.com






The question: why would npm matter for front-end?














I'll answer this with a story from long time ago.

once upon a time ago


english-time was written to be used by a cron-job alternative:


 shell-jobs

Example .jobs file

A similar tool, run-after was written, based on same library:






Since english-time is just a JS library,
why not to use it in front-end, too?



Here is an example: play radio paradise, and define schedules with english-time:



Link: http://requirebin.com/?gist=7541940


How about implementing this?



...in 30 lines of JavaScript



NPM contains tons of projects written for only front-end:

npm.im/center
npm.im/spinning
npm.im/play-url
npm.im/load-script





The NPM ecosystem itself is an alternative for all frameworks and big libraries such as jQuery and Underscore.




and there are still handy modules to for DOM programming:






Besides of  reusing libraries by others, NPM gives a productive and safe way to split the internal code into small pieces






require('./path/to/module')

will be calling another another module



All modules document their internal and external dependencies.







It's viable for keeping the code modularized enough.




small things are easy to design and share




...and easy to document & test






Most projects in NPM has its own README with well formatted description, manual, examples, and list of caveats if there is.






and of course, tests...






Tons of testing tools exist in NPM, some of those help us test cross-platform JavaScript





Prova is one of them. It simplifies running tests, a lot.



...in both NodeJS and browsers








Questions?






This is a lot of small projects







...waiting for a developer to compose them, into a big software.






NPM is like flying around the planet like a bird, when using a framework is like driving a big truck in restricted roads






Questions?





You can find this slides at 
slid.es/azer/npm

NPM Everywhere

By Azer Koçulu