👁️
Focusing
Conceptualise | Create | Convey | Convert
-
Designer & Developer
- Mumbai
- alokshenoy.com
- @koyanloshe
- koyanloshe
Highlights
Pinned Loading
-
Basic server for most filetypes #Jav...
Basic server for most filetypes #Javascript 1var http = require('http');
2var fs = require('fs');
3var path = require('path');
45http.createServer(function (request, response) {
-
Generate multiple requests #Javascript
Generate multiple requests #Javascript 1const {promisify} = require('util')
2const sleep = promisify(setTimeout)
3const request = async(data) => {
4let time = Math.random() * 1000
5await sleep(time)
-
Cloning objects without effects #Jav...
Cloning objects without effects #Javascript 1// Object.assign has an issue with nested Objects. This prevents that leakage
23const cloneObj = (existingObj) => {
4return JSON.parse(JSON.stringify(existingObj))
5}
-
Chat Server #Javascript
Chat Server #Javascript 1var net = require('net')
2var chatServer = net.createServer(), clientList = []
3chatServer.on('connection', function(client) {
4client.name = client.remoteAddress + ':' + client.remotePort client.write('Hi ' + client.name + '!\n');
5clientList.push(client)
-
process.env setter #Javascript
process.env setter #Javascript 1const fs = require('fs')
23const rootDir = require('../utils/rootDir')
45const env = {
-
Pipe & Compose in Javascript #Javasc...
Pipe & Compose in Javascript #Javascript #fp 1// Async compose
2const compose = (…functions) => input => functions.reduceRight((chain, func) => chain.then(func), Promise.resolve(input));
34// Functions fn1, fn2, fn3 can be standard synchronous functions or return a Promise
5compose(fn3, fn2, fn1)(input).then(result => console.log(`Do with the ${result} as you please`))
Something went wrong, please refresh the page to try again.
If the problem persists, check the GitHub status page or contact support.
If the problem persists, check the GitHub status page or contact support.