What's Backus-Naur Form (BNF)?

Quoted definition from wikipedia:

In computer science, BNF (Backus Normal Form or Backus–Naur Form) is one of the two main notation techniques for context-free grammars, often used to describe the syntax of languages used in computing, such as computer programming languages, document formats, instruction sets and communication protocols.

A BNF specification is a set of derivation rules, written as:

1
<symbol> ::= __expression__

Read More

Comments

What's the date time string format in JavaScript?

Date time string can be used as the argument of Date.parse method or the Date constructor in JavaScript.

According to the specification of Date Time String Format:

ECMAScript defines a string interchange format for date-times based upon a simplification of the ISO 8601 Extended Format. The format is as follows: YYYY-MM-DDTHH:mm:ss.sssZ.

Read More

Comments

What does error like EPERM, ENOENT means in Node.js?

Things like EPERM, EONENT are the error names(codes) which represent different system call error. For example:

  • EPERM: Operation not permitted.
  • ENOENT: No such file or directory.

Of course, there are not only two of them. I searched Node.js’s API and find an exhausitive list which shows all those error codes and their meanings. What’s more, there is a link which refers to the <errno.h> header file in Linux, which says:

All the error names specified by POSIX.1 must have distinct values, with the exception of EAGAIN and EWOULDBLOCK, which may be the same.

I found the corresponding POSIX.1 specification here, and this is the latest version of <errno.h>. As it says, it’s an extension of ISO C standard, and Node.js is mainly based on C, so there is no wonder that Node.js will use those strange names.

Log Errors Easier

When we use those APIs in Node.js which handle the system call and error happens, those methods will return an error as the first parameter of the callback. It’s not easy for us to remember each error and corresponding description, so our error message would be hard to read. Fortunately, there is a library node-errno that can help us with that. You can pass the errno to it and it will return a description about it. So now we have more friendly error message~

Comments