RSSAmplifier

Blog

Mohsen Azimi

Mohsen Azimi's personal weblog

azimi.meRSS feed ↗10 posts

Latest posts

"Use the platform" is not always the best advice

Swizec Teller wrote about how different DOM diffing libraries perform under pressure in his interesting blog post . It’s interesting to see how Preact and Vue perform better than React in that demo. In my opinion the biggest performance bottleneck is “the platform” not the libraries. I rewrote the demo to render everything in a canvas element. It resulted in a much smoother user interactions and…

Setting up test coverage using Mocha, Istanbul, NYC with TypeScript

It’s a pleasure to work with a project that uses TypeScript for your source code and tests, although setting up test coverage can be a bit tricky. I recently started a project that uses TypeScript for source as well as the tests. I used Mocha to run the test and nyc for generating test coverage. You will also need to npm install --save-dev source-map-support . It tooks many hours to figure out a…

Understanding JavaScript Backward Compatibility And The Strict Mode

When I started reading about the new version of JavaScript (ES6 or ES2015) I was conflicted about how adding new keywords to the language will not break JavaScript backward compatibility. As the only runtime language of the Web, JavaScript has to be backward compatible. Any code that is valid and running today should be working in feature JavaScript engines. Here is the list of all JavaScript…

YAML manipulation library that keeps comments and styling

The usual way for manipulating a YAML file in JavaScript is to convert it to JSON, modify the JSON and then convert JSON back to YAML. Unfortunately this process will remove any comment and can mess up the styling of the document. const yamlString = ` # my value value: 100 ` ; const json = YAML . load ( yamlString ); // updating the value json . value = 200 ; // getting back the YAML. Comments are…

Custom Errors in ES6 (ES2015)

A very quick note. With the new class and extend keywords it’s now much easier to subclass Error constructor: class MyError extends Error { constructor ( message ) { super ( message ); this . message = message ; this . name = ' MyError ' ; } } There is no need for this.stack = (new Error()).stack; trick thanks to super() call.

High Performance Recursive HTML/JavaScript Components

I developed json-formatter directive to use it in Swagger Editor . It’s a simple component for rendering JSON in HTML nicely. Inspired by how WebKit renders JSON in developer tools. <json-formatter> <!-- This will result in an infinite loop --> <json-formatter ng-repeat= "key in keys" ></json-formatter> </json-formatter> It’s an AngularJS directives, so you can’t use simple recursion by just…

Non-blocking Asynchronous JSON.parse Using The Fetch API

Update (June 2016) Right after I published this blog post I received this response from amazing Node.js developer Vladimir Kurchatkin that JSON parsing is not happening in a different thread and in fact it is blocking the main thread. In this tweet I admited I was wrong and I need to update my post. @j5bot I need to update that post. It's not really in a background thread. It's doing the process…

How to split a Swagger spec into smaller files

If you’re writing a Swagger API spec and it’s becoming too large, you can split it into multiple files. Swagger supports JSON Reference (draft) for using remote and local pieces of JSON to build up a Swagger document. JSON Reference Overview JSON Reference uses the special key $ref to define a “reference” to a piece of JSON. For example following JSON has a reference to http://example.com/foo.json…

Slides from my talk: An Overview of Map and Set in JavaScript

Here are my slides my talk that I gave in SF Node.js Club Meetup about Set and Map objects in JavaScript Go to slides

Slides from my talk: My Experience in Building Swagger Editor

Here are my slides my talk that I gave in SouthBay JavaScript Meetup about my experience building Swagger Editor If you’re not familiar with Swagger check it out. It’s very useful for starting microservices quickly or generate documentations for you API automatically. Go to slides