Skip to content

Instantly share code, notes, and snippets.

View ScriptedAlchemy's full-sized avatar
🎯
Focusing

Zack Jackson ScriptedAlchemy

🎯
Focusing
View GitHub Profile
@ScriptedAlchemy
ScriptedAlchemy / Chunksplitting.js
Last active November 25, 2019 00:49
Split Chunks cache groups via module api
function hasExternalizedModule(module) {
const moduleSource = module?.originalSource?.()?.source?.() || '';
// dead simple way to check if the magic export comment is in a file
if (moduleSource?.indexOf('externalize') > -1 || false) {
return moduleSource;
}
return false;
}
const interleaveConfig = test => ({
@ScriptedAlchemy
ScriptedAlchemy / deepmerge.js
Created September 2, 2019 20:39
Immutable Deep merge
function mergeDeep(...objects) {
const isObject = obj => obj && typeof obj === 'object';
return objects.reduce((prev, obj) => {
Object.keys(obj).forEach(key => {
const pVal = prev[key];
const oVal = obj[key];
if (Array.isArray(pVal) && Array.isArray(oVal)) {
prev[key] = pVal.concat(...oVal);
@ScriptedAlchemy
ScriptedAlchemy / index.js
Created September 2, 2019 19:43
Render Manifest Webpack Plugin
compilation.mainTemplate.hooks.renderManifest.tap(
'URLImportPlugin',
(result, { chunk }) => {
console.log(chunk);
const renderedModules = Array.from(chunk.modulesIterable).filter(
(module) => module.type === MODULE_TYPE
);
if (renderedModules.length > 0) {
result.push({
@ScriptedAlchemy
ScriptedAlchemy / setTimeout-mem-leak.js
Created August 10, 2019 23:05 — forked from irazasyed/setTimeout-mem-leak.js
JavaScript: setTimeout Memory Leak Prevention.
// https://developer.mozilla.org/en-US/docs/Web/API/window.setTimeout
var timeoutID;
delayedAlert();
function delayedAlert() {
timeoutID = window.setTimeout(slowAlert, 2000);
}
function slowAlert() {
import $$observable from 'symbol-observable'
import ActionTypes from './utils/actionTypes'
import isPlainObject from './utils/isPlainObject'
import combineReducers from './combineReducers'
/**
* Creates a Redux store that holds the state tree.
* The only way to change the data in the store is to call `dispatch()` on it.
*
@ScriptedAlchemy
ScriptedAlchemy / md5.js
Last active October 5, 2024 13:53
Super fast MD5 Hashing function, useful for arbitrary hashing needs.
/* eslint-disable */
function md5cycle(x, k) {
let a = x[0];
let b = x[1];
let c = x[2];
let d = x[3];
a = ff(a, b, c, d, k[0], 7, -680876936);
d = ff(d, a, b, c, k[1], 12, -389564586);
@ScriptedAlchemy
ScriptedAlchemy / Worker.js
Created May 6, 2018 09:04
IPFS gateway worker interceptor
'use strict'
const IPFS = require('ipfs')
function App() {
let node
create()