diff --git a/1-js/11-async/06-promisify/article.md b/1-js/11-async/06-promisify/article.md index e72329ce..7c84912b 100644 --- a/1-js/11-async/06-promisify/article.md +++ b/1-js/11-async/06-promisify/article.md @@ -2,7 +2,7 @@ Promisification -- is a long word for a simple transform. It's conversion of a function that accepts a callback into a function returning a promise. -In other words, we create a wrapper-function that does the same, internally calling the original one, but returns a promise. +To be more precise, we create a wrapper-function that does the same, internally calling the original one, but returns a promise. Such transforms are often needed in real-life, as many functions and libraries are callback-based. But promises are more convenient. So it makes sense to promisify those. @@ -105,7 +105,7 @@ f = promisify(f, true); f(...).then(arrayOfResults => ..., err => ...) ``` -In some cases, `err` may be absent at all: `callback(result)`, or there's something exotic in the callback format, then we can promisify such functions manually. +In some cases, `err` may be absent at all: `callback(result)`, or there's something exotic in the callback format, then we can promisify such functions without using the helper, manually. There are also modules with a bit more flexible promisification functions, e.g. [es6-promisify](https://github.com/digitaldesignlabs/es6-promisify). In Node.js, there's a built-in `util.promisify` function for that. diff --git a/1-js/13-modules/01-modules-intro/article.md b/1-js/13-modules/01-modules-intro/article.md index b19fb284..6bf66abb 100644 --- a/1-js/13-modules/01-modules-intro/article.md +++ b/1-js/13-modules/01-modules-intro/article.md @@ -6,7 +6,7 @@ A module usually contains a class or a library of useful functions. For a long time, JavaScript existed without a language-level module syntax. That wasn't a problem, because initially scripts were small and simple. So there was no need. -But eventually scripts became more and more complex, so the community invented a variety of ways to organize code into modules. +But eventually scripts became more and more complex, so the community invented a variety of ways to organize code into modules, special libraries to load modules on demand. For instance: @@ -20,9 +20,9 @@ Now all these slowly become a part of history, but we still can find them in old A module is just a file, a single script, as simple as that. -Directives `export` and `import` allow to interchange functionality between modules: +There are directives `export` and `import` to interchange functionality between modules, call functions of one module from another one: -- `export` keyword labels variables and functions that should be accessible from outside the file. +- `export` keyword labels variables and functions that should be accessible from outside the current module. - `import` allows to import functionality from other modules. For instance, if we have a file `sayHi.js` exporting a function: @@ -44,13 +44,15 @@ alert(sayHi); // function... sayHi('John'); // Hello, John! ``` -In this tutorial we concentrate on the language itself, but we use browser as the demo environment, so let's see how modules work in the browser. +In this tutorial we concentrate on the language itself, but we use browser as the demo environment, so let's see how to use modules in the browser. -To use modules, we must set the attribute ` ``` -If we really need to make a "global" in-browser variable, we can explicitly assign it to `window` and access as `window.user`. But that's an exception requiring a good reason. +If we really need to make a window-level global variable, we can explicitly assign it to `window` and access as `window.user`. But that's an exception requiring a good reason. ### A module code is evaluated only the first time when imported @@ -229,11 +231,11 @@ You may want skip those for now if you're reading for the first time, or if you Module scripts are *always* deferred, same effect as `defer` attribute (described in the chapter [](info:script-async-defer)), for both external and inline scripts. In other words: -- external module scripts ` +Compare to regular script below: +