Adapted from https://github.com/marzent/wine-msync to apply to Wine 9.0 without CrossOver.
import ldap from 'ldapjs'; | |
const makeLDAPURL = (server: string) => { | |
const [domain, mainPort, altPort] = server.split(':'); | |
return [mainPort, altPort].map(port => `ldap://${domain}:${port}`); | |
} | |
// Finds a TNS string from the LDAP source | |
// Adapted from https://github.com/oracle/python-oracledb/discussions/71#discussioncomment-3918181 |
// Writing this in JavaScript was a mistake. | |
const B = 10000; | |
const N = 9329629409n * 2315959301n; | |
console.time('exec'); | |
const bigintSqrt = (v, ceil = false) => { | |
if (v < 2n) return v; | |
let iter = v >> 1n; |
# Lifting scheme version of the discrete wavelet transform in JPEG 2000 | |
# The approximation and detail coefficients are interleaved in the output of dwt (even | |
# indices for approx, odd for detail). In practice you may need to separate them afterwards | |
# idwt is esentially reversing the order of the lifting scheme steps in dwt and | |
# flipping the sign of operations(i.e. addition becomes subtraction and vice versa) | |
# approx_len = approximation coefficients length = ceil(total_series_len / 2) | |
# detail_len = detail coefficients length = floor(total_series_len / 2) |
// Cooley-Tukey FFT implementation in JS | |
// My DSP is very shaky so this probably has some bugs... | |
const N_TRIG = 4096; | |
const HALF_N_TRIG = N_TRIG >> 1; | |
const COS = new Float64Array(N_TRIG); | |
const SIN = new Float64Array(N_TRIG); | |
for (let i = 0; i < N_TRIG; ++i) { | |
const rad = 2 * Math.PI * i / N_TRIG; |
// Will be used in fzstd if the default distributions ever update | |
// Not fast because it's meant to be run once for precomputation | |
// accuracy log | |
const al = 5; | |
// distribution | |
const dist = [1, 1, 1, 1, 1, 1, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, | |
1, 1, 1, 1, 1, 1, 1, 1,-1,-1,-1,-1,-1]; | |
const out = new Uint8Array(1000); |
/**! | |
* Fast CRC32 in JavaScript | |
* 101arrowz (https://github.com/101arrowz) | |
* License: MIT | |
*/ | |
// If you use this code, please link this gist or attribute it somehow. | |
// This code uses the Slice-by-16 algorithm to achieve performance | |
// roughly 2x greater than all other JS CRC32 implementations (e.g. |
import { useEffect, useState } from 'react'; | |
type Subscribable<T> = { | |
trigger(newValue: T): void; | |
subscribe(listener: (value: T) => unknown): number; | |
unsubscribe(ind: number): void; | |
}; | |
const createSubscribable = <T = void>(): Subscribable<T> => { | |
const subs: ((value: T) => unknown)[] = []; |
FFlate is the fastest, smallest, and most effective JavaScript compressor/decompressor currently; to create it, I used a variety of modified or optimized algorithms.
The core of most popular compressed file formats is DEFLATE, or RFC1951. GZIP data, Zlib data, .zip
files, PNG images, and more all use some variant of DEFLATE under the hood. At its core, the DEFLATE format is actually not too complex: it's merely a combination of Huffman coding and LZ77 compression.
If you don't understand either of these concepts, feel free to read the following subsections, or skip to Part 2 if you already know what these are and just want to get to implementation details.
Computers think of basically everything as numbers. The smallest unit of information in a computer is a single bit, which can only be either a 0 or a 1. When multiple bits are stringed together, they can be interpreted as a ba
Object.fromEntries = function(entries) { | |
return entries.reduce( | |
function(a, v) { a[v[0]] = v[1]; return a; }, | |
{} | |
); | |
}; | |
// ES6 | |
Object.fromEntries = entries => entries.reduce((a, v) => (a[v[0]] = v[1], a), {}); |