Nice Pretty Modules
Nice Pretty Modules
npm modules I use and recommend
lodash
- Inspired by underscore.js, but better
- Core data structure helper functions
- functional programming, inheritence, polyfills
- I use it in nearly every project
- ECMAScript 5 Array prototype has .map, .forEach, .filter, which I use
["Monday", "Tuesday", "Wednesday"].forEach(function(day) {
});
const _ = require("lodash");
const user = {
name: "Bob",
email: "bob@example.com",
shoeSize: 11
};
const variant = _.pick(user, "name", "email");
console.log(variant);
lodash functions I use frequently
- _.pick
- _.pluck
- _.last
- _.without
- _.uniq
- _.flatten
- _.debounce, _.throttle
- _.omit
Testing
- mocha.js best testing framework
- expectacle least insane expactation library
- sinon.js spies, mocks, stubs
- rewire dependency injection
Web Apps
- browserify Bundle browser JS without reaching for the FaceAxe
- brfs for loading static files as strings
- browserify-shim for third party stuff (angularjs)
- browserify-middleware almost-perfect dev/prod workflow
- cheerio for server-side HTML parsing and manipulation
- supertest for testing express.js apps end to end
- stylus for CSS preprocessing (better than LESS, SASS, SCSS)
- bunyan for logging
- passport.js for authentication with bcrypt for password hashing
async.js
Still my go-to flow control library. There are lots of good choices here, though.
moment.js
Painfully awesome library for Date parsing and manipulation
moment().add(7, 'days').toDate()
Thu Jul 03 2014 12:27:00 GMT-0600 (MDT)
AVOID: Bad (but popular) modules
- should.js
- mongoose.js
- requirejs: browserify FTW (see also webpack)
- anything based on the Ruby on Rails asset pipeline
Quagmires: Still no clear winners
- Database layers ORM/ODM
- SQL dialect managers, query libraries
- expectation libraries (expectacle is closest)
- JSON validation
Misc tips about searching for modules
- alternative/rewrites usually better
- requirejs -> browserify
- jasmine -> mocha
- jsdom -> cheerio
- q -> bluebird (probably...)
- Get familiar with prolific, high-quality authors
- actively maintained
- sensible documentation
Use caution for highly expensive switching costs
Try out in a small side project first
- logging
- assertions/expectations
- control flow
- any framework
- DB access and abstractions
Nice Pretty Modules npm modules I use and recommend