shlogg · Early preview
Ramu Narasinga @karthik-m22

Assert Usage In Grida Source Code And Node.js

Assert in Grida source code: assert stops execution & throws AssertionError with custom error message. Use to add defensive mechanisms with clear error messages. Read more about assert in Node.js: https://nodejs.org/api/assert.html-message

In this article, we will review the assert usage in Grida source code and I ran some experiments in a codesandbox repo to see this in action. Let’s get started.

  
  
  Assert in Nodejs

assert is an alias of assert.ok(). Use this to test if value is truthy. It is equivalent to assert.equal(!!value, true, message).

If value is not truthy, an AssertionError is thrown with a message property set equal to the value of the message parameter. If the message parameter is undefined, a default error message is assigned. If the message parameter is an instance of an Error then it will be thrown inste...