node.js

webdriver-manager update throwing Error: connect ETIMEDOUT

情到浓时终转凉″ 提交于 2021-02-20 19:30:09
问题 I'm getting ETIMEDOUT error while installing webdriver-manager updated . Find the error details as below: C:\Users\....> webdriver-manager update webdriver-manager: using global installed version 12.0.6 events.js:160 throw er; // Unhandled 'error' event ^ Error: connect ETIMEDOUT XX.XXX.XX.XXX:XXX at Object.exports._errnoException (util.js:1018:11) at exports._exceptionWithHostPort (util.js:1041:20) at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1086:14) Also when I tried to ping the

Run Nodemon with Typescript compiling?

可紊 提交于 2021-02-20 19:27:30
问题 I want my typescript files to be compiled on every file saving with the command tsc . How do I combine the tsc command with the command that nodemon runs in the build:live script "scripts": { "start": "npm run build:live", "build:live": "nodemon --watch '*.ts' --exec 'ts-node' app.ts", } this script causes nodemon to call itself twice or three times: "build:live": "nodemon --watch '*.ts' --exec 'ts-node app.ts & tsc'", 回答1: This looks like it will achieve what you're looking for: "start":

websocket server, storing the data

别说谁变了你拦得住时间么 提交于 2021-02-20 18:46:57
问题 Lets say that i make a websocket server chat (node.js + socket.io). How would i store the chat messages, so that when a "new" user joins the chat, he will be seeing old chat messages, and not just the ones which has been sent while hes in the chat. Should the data be stored in variables in the server? Something like: var io = require('socket.io').listen(80); var saveData = { }; io.sockets.on('connection', function (socket) { socket.emit('news', { hello: 'world' }); socket.on('my other event',

websocket server, storing the data

为君一笑 提交于 2021-02-20 18:44:24
问题 Lets say that i make a websocket server chat (node.js + socket.io). How would i store the chat messages, so that when a "new" user joins the chat, he will be seeing old chat messages, and not just the ones which has been sent while hes in the chat. Should the data be stored in variables in the server? Something like: var io = require('socket.io').listen(80); var saveData = { }; io.sockets.on('connection', function (socket) { socket.emit('news', { hello: 'world' }); socket.on('my other event',

Is Javascript “caching” operations?

假装没事ソ 提交于 2021-02-20 18:03:32
问题 I was implementing the Levenshtein distance function in Javascript, and I was wondering how much time it takes to run it with Wikedia's example ("sunday" & "saturday"). So I used console.time() and console.timeEnd() to determine the time spent for the function execution. for (var i = 0; i < 15; i++) { console.time("benchmark" + i); var result = LevenshteinDistance("sunday", "saturday"); console.timeEnd("benchmark" + i); } Since it was fluctuating between 0.4ms and 0.15ms, I used a loop and I

Is Javascript “caching” operations?

我们两清 提交于 2021-02-20 18:03:07
问题 I was implementing the Levenshtein distance function in Javascript, and I was wondering how much time it takes to run it with Wikedia's example ("sunday" & "saturday"). So I used console.time() and console.timeEnd() to determine the time spent for the function execution. for (var i = 0; i < 15; i++) { console.time("benchmark" + i); var result = LevenshteinDistance("sunday", "saturday"); console.timeEnd("benchmark" + i); } Since it was fluctuating between 0.4ms and 0.15ms, I used a loop and I

Redefinition of variable in node.js

独自空忆成欢 提交于 2021-02-20 17:52:39
问题 The execution of this script: tmp.js, that contains: var parameters = {}; (1,eval)("var parameters = {a:1}"); (1,eval)(console.log(parameters)); node tmp.js produces: {} If we comment out the first statement, and execute again the script, we obtain: { a: 1 } The global scope contains exactly the same variables with the same value, so why console.log displays a different value? 回答1: Because all code you run in Node is running in a Node module,¹ with its own scope, not at global scope. But the

Redefinition of variable in node.js

南楼画角 提交于 2021-02-20 17:52:01
问题 The execution of this script: tmp.js, that contains: var parameters = {}; (1,eval)("var parameters = {a:1}"); (1,eval)(console.log(parameters)); node tmp.js produces: {} If we comment out the first statement, and execute again the script, we obtain: { a: 1 } The global scope contains exactly the same variables with the same value, so why console.log displays a different value? 回答1: Because all code you run in Node is running in a Node module,¹ with its own scope, not at global scope. But the

仅使用CSS就可以提高页面渲染速度的4个技巧

随声附和 提交于 2021-02-20 16:16:19
文末福利资源更新 本文将重点介绍4个可以用来提高页面渲染速度的CSS技巧。 1. Content-visibility 一般来说,大多数Web应用都有复杂的UI元素,它的扩展范围超出了用户在浏览器视图中看到的内容。在这种情况下,我们可以使用内容可见性( content-visibility )来跳过屏幕外内容的渲染。如果你有大量的离屏内容,这将大大减少页面渲染时间。 这个功能是最新增加的功能之一,也是对提高渲染性能影响最大的功能之一。虽然 content-visibility 接受几个值,但我们可以在元素上使用 content-visibility: auto; 来获得直接的性能提升。 让我们考虑一下下面的页面,其中包含许多不同信息的卡片。虽然大约有12张卡适合屏幕,但列表中大约有375张卡。正如你所看到的,浏览器用了1037ms来渲染这个页面 。 下一步,您可以向所有卡添加 content-visibility 。 在这个例子中,在页面中加入 content-visibility 后,渲染时间下降到150ms,这是6倍以上的性能提升。 正如你所看到的,内容可见性是相当强大的,对提高页面渲染时间非常有用。根据我们目前所讨论的东西,你一定是把它当成了页面渲染的银弹。 content-visibility 的限制 然而,有几个领域的内容可视性不佳。我想强调两点,供大家参考。

Appending file to zip in nodejs

萝らか妹 提交于 2021-02-20 14:52:24
问题 I'm making an application in which you edit a file, and it should append the edited file to zip archive and make it downloadable. It should be cross platform (Windows and Linux). My goal is to programmatically generate the edited file and append it to static archive (which is always the same, around 3-4MBs, but around 40-50 files). I've looked at the following post on how to zip archives in node.js, however the answer by Eliseo Soto is OS dependent. I've also found daraosn/node-zip, but as I