Imagine we have a reducer to control a list of items:
function listOfItems(state: Array<Object> = [], action: Object = {}): Array<Object> {
switch(action.type) {
case 'SHOW_ALL_ITEMS':
return action.data.items
default:| /* | |
| Instructions for MacOS: | |
| - Install the fonts 'Operator Mono' & 'Fira Code' | |
| - Install theme 'Dark Candy' | |
| - Add the following config to the VS Code settings.json: | |
| { | |
| "editor.renderWhitespace": "all", | |
| "editor.fontSize": 14, |
My current editor of choice for all things related to Javascript and Node is VS Code, which I highly recommend. The other day I needed to hunt down a bug in one of my tests written in ES6, which at time of writing is not fully supported in Node. Shortly after, I found myself down the rabbit hole of debugging in VS Code and realized this isn't as straightforward as I thought initially. This short post summarizes the steps I took to make debugging ES6 in VS Code frictionless.
My first approach was a launch configuration in launch.json mimicking tape -r babel-register ./path/to/testfile.js with babel configured to create inline sourcemaps in my package.json. The debugging started but breakpoints and stepping through the code in VS Code were a complete mess. Apparently, ad-hoc transpilation via babel-require-hook and inline sourcemaps do not work in VS Code. The same result for
attaching (instead of launch) to `babel-node
fluid-aspect is a Sass mixin for creating intrinsic ratios in CSS. Intrinsic ratios allow elements to fill the width of their containing block and resize on the fly while maintaining their aspect ratio.
@include fluid-aspect($ratio, [$target]);| // articles per page | |
| var limit = 10; | |
| // pagination middleware function sets some | |
| // local view variables that any view can use | |
| function pagination(req, res, next) { | |
| var page = parseInt(req.params.page) || 1, | |
| num = page * limit; | |
| db.articles.count(function(err, total) { | |
| res.local("total", total); |