I hereby claim:
- I am shanewholloway on github.
- I am shanewholloway (https://keybase.io/shanewholloway) on keybase.
- I have a public key ASALlQzEk_Vxarp8quh4XDhlOBCO9NXZrifkY9BwvJ8v7wo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
const tiny_load = src => | |
new Promise((onload, onerror) => | |
document.head.appendChild( | |
Object.assign( | |
document.createElement('script'), | |
{src, onload, onerror}, | |
src.startsWith('http') | |
? {crossorigin: true} | |
: null ) )) |
export default asWorkerFunction | |
export asWorkerFunction | |
export asBlobURLFunction | |
function asWorkerFunction(func) { | |
return new Worker(asBlobURLFunction(func)) | |
} | |
function asBlobURLFunction(func) { | |
const rx_src = /(^.*=>|{)\s*([^]*?)(}\s*)?$/ |
const _fromCharCode = String.fromCharCode | |
export function pack_base64(arr) { | |
let res='' | |
const u8 = new Uint8Array(arr.buffer || arr) | |
const len = u8.byteLength | |
for (let i=0; i<len; i++) | |
res += _fromCharCode(u8[i]) | |
return window.btoa(res) | |
} |
Using rollup 0.57.1 with "lodash-es" package does not treeshake properly.
// to depth-first inspect all attributes of an object | |
inspect(obj) | |
// or, to see all attributes on the entire prototype chain | |
inspect.chain(obj) |
const _fromCharCode = String.fromCharCode | |
export function pack_base64(arr) { | |
let res='' | |
const u8 = new Uint8Array(arr.buffer || arr) | |
const len = u8.byteLength | |
for (let i=0; i<len; i++) | |
res += _fromCharCode(u8[i]) | |
return window.btoa(res) | |
} |
const base64_encode_std = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' | |
const base64_encode_url = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_' | |
const base64_decode = [{}, {}, {}, {}] | |
{ | |
const add = (k, i) => { | |
base64_decode[0][k] = i << 0 | |
base64_decode[1][k] = i << 6 | |
base64_decode[2][k] = i << 12 | |
base64_decode[3][k] = i << 18 | |
} |
function show_memory(interval=1000) { | |
setTimeout(show_memory, interval).unref() | |
let out = [] | |
const mem = process.memoryUsage() | |
out.push('MEM') | |
for (const [k,v] of Object.entries(mem)) { | |
out.push(`${k}: ${(v / 1.0e6).toFixed(1)} MB`) | |
} |