What does var io = require ('../ ..') (server) do?

I created a project https://github.com/Automattic/socket.io/tree/master/examples/chat locally and it works great. However, it would be nice to understand how the socket application works.

In the main script run, one of the modules that are pulled in with the request,

var io = require('../..')(server)

what is needed ('../..')?

thank!

+4
source share
2 answers

When a directory path is assigned require, it will implicitly search index.jsin that directory.

In this case, this is the equivalent

var socket = require("../../index.js");
var io     = socket(server);

, require.

module.require docs .

+7

,

("../..');

File form , SOCKET.IO, , Socket.io.

, - , index.js index.node. , .

0

Source: https://habr.com/ru/post/1547856/


All Articles