Skip to content

Instantly share code, notes, and snippets.

View Cadienvan's full-sized avatar

Michael Di Prisco Cadienvan

View GitHub Profile
@Cadienvan
Cadienvan / index.js
Last active February 11, 2023 10:32
Tests about inverted index performances on JS arrays
const linearArray = [];
const testArray = {
// The array that will hold the values
array: [],
// The inverted index
index: {},
// The push function
push: function (value) {
// Push the value to the array
@Cadienvan
Cadienvan / cluster-reverse-proxy.js
Last active February 20, 2023 06:28
How to create a reverse proxy using clusters in Node.js
const cluster = require('cluster');
const http = require('http');
if (cluster.isMaster) {
for (let i = 0; i < 10; i++) {
cluster.fork();
}
let workers = Object.values(cluster.workers)
cluster.on('exit', (worker, code, signal) => {
@Cadienvan
Cadienvan / index.js
Created April 3, 2023 15:14
Cache Candidate Example Internals
const { cacheCandidate } = require("@jointly/cache-candidate");
const myFn = () => {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve('Hello World');
}, 1000);
});
}