Skip to content
View koyanloshe's full-sized avatar
👁️
Focusing
👁️
Focusing

Block or report koyanloshe

Block user

Prevent this user from interacting with your repositories and sending you notifications. Learn more about blocking users.

You must be logged in to block users.

Please don't include any personal information such as legal names or email addresses. Maximum 100 characters, markdown supported. This note will be visible to only you.
Report abuse

Contact GitHub support about this user’s behavior. Learn more about reporting abuse.

Report abuse

Pinned Loading

  1. Basic server for most filetypes #Jav... Basic server for most filetypes #Javascript
    1
    var http = require('http');
    2
    var fs = require('fs');
    3
    var path = require('path');
    4
    
                  
    5
    http.createServer(function (request, response) {
  2. Generate multiple requests #Javascript Generate multiple requests #Javascript
    1
    const {promisify} = require('util')
    2
    const sleep = promisify(setTimeout)
    3
    const request = async(data) => {
    4
      let time = Math.random() * 1000
    5
      await sleep(time)
  3. Cloning objects without effects #Jav... Cloning objects without effects #Javascript
    1
    // Object.assign has an issue with nested Objects. This prevents that leakage
    2
    
                  
    3
    const cloneObj = (existingObj) => {
    4
      return JSON.parse(JSON.stringify(existingObj))
    5
    }
  4. Chat Server #Javascript Chat Server #Javascript
    1
    var net = require('net')
    2
    var chatServer = net.createServer(), clientList = []
    3
    chatServer.on('connection', function(client) {
    4
    client.name = client.remoteAddress + ':' + client.remotePort client.write('Hi ' + client.name + '!\n');
    5
    clientList.push(client)
  5. process.env setter #Javascript process.env setter #Javascript
    1
    const fs = require('fs')
    2
    
                  
    3
    const rootDir = require('../utils/rootDir')
    4
    
                  
    5
    const env = {
  6. Pipe & Compose in Javascript #Javasc... Pipe & Compose in Javascript #Javascript #fp
    1
    // Async compose
    2
    const compose = (…functions) => input => functions.reduceRight((chain, func) => chain.then(func), Promise.resolve(input));
    3
    
                  
    4
    // Functions fn1, fn2, fn3 can be standard synchronous functions or return a Promise
    5
    compose(fn3, fn2, fn1)(input).then(result => console.log(`Do with the ${result} as you please`))