This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const GRPCConnection = gRPC => url => { | |
| let connected = false | |
| const _connection = gRPC(url) | |
| _connection.on('connect', () => (connected = true)) | |
| _connection.on('disconnect', () => (connected = false)) | |
| return { | |
| getIsConnected(): connected, | |
| connect: () => connected || _connection.connect() | |
| send: command => _connection.send(command) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const GRPCConnection = url => { | |
| let connected = false | |
| const _connection = gRPC(url) | |
| _connection.on('connect', () => (connected = true)) | |
| _connection.on('disconnect', () => (connected = false)) | |
| return { | |
| getIsConnected(): connected, | |
| connect: () => connected || _connection.connect() | |
| send: command => _connection.send(command) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function outerScope() { | |
| let a = "Hello" | |
| console.log(a) // "Hello" | |
| function innerScope() { | |
| a = 3 | |
| return | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var a = { | |
| loop: (() => setInterval(() => console.log('It lives!'), 1000))() | |
| } | |
| console.log(a) | |
| a = undefined | |
| console.log(a) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //global variable | |
| const GlobalMembersArray =[]; | |
| /** | |
| * This creates a new Member. | |
| * @class | |
| * @classdesc A Member object. | |
| * @param {Object} memberData - The data for the member to create. | |
| * @param {string} memberData.id - The unique id of the member. | |
| * @param {string} memberData.password - The member's password. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //global variable | |
| const GlobalMembersArray =[]; | |
| /** | |
| * Member type definition | |
| * @typedef {Object} Member | |
| * @property {string} id - The unique id of the member. | |
| * @property {string} password - The member's password. | |
| */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //global variable | |
| const GlobalMembersArray =[]; | |
| /** | |
| * Create a new member. | |
| * @param {Object} memberData - The data for the member to create. | |
| * @param {string} memberData.id - The unique id of the member. | |
| * @param {string} memberData.password - The member's password. | |
| */ | |
| function Member({id, password}){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //global variable | |
| const GlobalMembersArray =[]; | |
| // TypeScript types on function parameters | |
| function Member({id, password}: {id: string, password: string}){ | |
| this.id = id; | |
| this.password = password | |
| } | |
| const member1 = new Member({id: "m001", password: "123"}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //global variable | |
| const GlobalMembersArray =[]; | |
| //object | |
| function Member({id, password}){ | |
| this.id = id; | |
| this.password = password | |
| } | |
| const member1 = new Member({id: "m001", password: "123"}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //global variable | |
| const GlobalMembersArray = []; | |
| //object | |
| function Member(id, password) { | |
| this.id = id; | |
| this.password = password | |
| } | |
| const member1 = new Member("m001","123"); |