Skip to content

Commit

Permalink
fix(guide): dont-block-the-event-loop.md (#2597)
Browse files Browse the repository at this point in the history
* Update dont-block-the-event-loop.md

incorrect example code

* fix(guide): dont-block-the-event-loop.md of zh-ch translation
  • Loading branch information
objectisundefined authored and Trott committed Sep 24, 2019
1 parent fd9206c commit 2026c6a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions locale/en/docs/guides/dont-block-the-event-loop.md
Original file line number Diff line number Diff line change
Expand Up @@ -255,19 +255,19 @@ Example: JSON blocking. We create an object `obj` of size 2^21 and `JSON.stringi
var obj = { a: 1 };
var niter = 20;

var before, res, took;
var before, str, pos, res, took;

for (var i = 0; i < niter; i++) {
obj = { obj1: obj, obj2: obj }; // Doubles in size each iter
}

before = process.hrtime();
res = JSON.stringify(obj);
str = JSON.stringify(obj);
took = process.hrtime(before);
console.log('JSON.stringify took ' + took);

before = process.hrtime();
res = str.indexOf('nomatch');
pos = str.indexOf('nomatch');
took = process.hrtime(before);
console.log('Pure indexof took ' + took);

Expand Down
6 changes: 3 additions & 3 deletions locale/zh-cn/docs/guides/dont-block-the-event-loop.md
Original file line number Diff line number Diff line change
Expand Up @@ -256,19 +256,19 @@ app.get('/redos-me', (req, res) => {
var obj = { a: 1 };
var niter = 20;

var before, res, took;
var before, str, pos, res, took;

for (var i = 0; i < niter; i++) {
obj = { obj1: obj, obj2: obj }; // 每个循环里面将对象 size 加倍
}

before = process.hrtime();
res = JSON.stringify(obj);
str = JSON.stringify(obj);
took = process.hrtime(before);
console.log('JSON.stringify took ' + took);

before = process.hrtime();
res = str.indexOf('nomatch');
pos = str.indexOf('nomatch');
took = process.hrtime(before);
console.log('Pure indexof took ' + took);

Expand Down

0 comments on commit 2026c6a

Please sign in to comment.