Skip to content

Instantly share code, notes, and snippets.

@nChauhan91
nChauhan91 / node-env-hack.js
Last active October 8, 2022 11:13 — forked from pinkhominid/node-env-hack.js
Browser workaround for missing process.env.NODE_ENV
// Hack for immer esm (see https://github.com/immerjs/immer/issues/557)
// and others that suffer the same
window.process = { ...window.process, env: { ...window?.process?.env, NODE_ENV: 'production' } };
@nChauhan91
nChauhan91 / SingletonDefaultExportInstance.js
Created January 31, 2020 10:30 — forked from dmnsgn/SingletonDefaultExportInstance.js
ES6 singleton pattern: module default exports an instance
class SingletonDefaultExportInstance {
constructor() {
this._type = 'SingletonDefaultExportInstance';
}
singletonMethod() {
return 'singletonMethod';
}
static staticMethod() {
@nChauhan91
nChauhan91 / oneliners.js
Created April 2, 2019 07:50 — forked from mikowl/oneliners.js
👑 Awesome one-liners you might find useful while coding.
// By @coderitual
// https://twitter.com/coderitual/status/1112297299307384833
// Remove any duplicates from an array of primitives.
const unique = [...new Set(arr)]
// Sleep in async functions. Use: await sleep(2000).
const sleep = (ms) => (new Promise(resolve => setTimeout(resolve, ms)));
// Type this in your code to break chrome debugger in that line.