Skip to content

Instantly share code, notes, and snippets.

View jwulf's full-sized avatar
:octocat:
Coding on Halmak

Josh Wulf jwulf

:octocat:
Coding on Halmak
View GitHub Profile
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)
}
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)
}
function outerScope() {
let a = "Hello"
console.log(a) // "Hello"
function innerScope() {
a = 3
return
}
var a = {
loop: (() => setInterval(() => console.log('It lives!'), 1000))()
}
console.log(a)
a = undefined
console.log(a)
//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.
//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.
*/
//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}){
//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"});
//global variable
const GlobalMembersArray =[];
//object
function Member({id, password}){
this.id = id;
this.password = password
}
const member1 = new Member({id: "m001", password: "123"});
//global variable
const GlobalMembersArray = [];
//object
function Member(id, password) {
this.id = id;
this.password = password
}
const member1 = new Member("m001","123");