- Encryption algorithm: aes-256-gcm
- Hashing algorithm: sha512
- Key derivation algorithm: pbkdf2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// src/batch.ts | |
var Batch = class { | |
constructor() { | |
this.level = 0; | |
this.registerUpdate = (observable2, value) => { | |
if (!this.queue) | |
return; | |
this.queue.set(observable2, value); | |
}; | |
this.wrap = (fn) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* IMPORT */ | |
import {SYMBOL} from './constants'; | |
import Observable from './observable'; | |
import {ObservableCallable} from './types'; | |
/* MAIN */ | |
// The most optimized way to make an Observable class callable |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* IMPORT */ | |
import _ from 'lodash'; | |
import {Text} from '~/components'; | |
import {Utils} from '~/lib'; | |
import {useRef, useClass} from '~/hooks'; | |
import {observable, computed, Component} from '~/view'; | |
import {Class, Styles} from './styles'; | |
import {Props} from './types'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// It's the fastest pure-JS base64 encoder (that doesn't account for padding though) that I've found. | |
// It's cursed because it takes ~2s to startup and 16MB of memory 😂 | |
const encoder = new TextEncoder (); | |
const lookup = (() => { | |
const alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.split ( '' ); | |
const lookup = new Array ( 2 ** 24 ); | |
const mask1 = 0b11111100_00000000_00000000; | |
const mask2 = 0b00000011_11110000_00000000; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Can you make this faster? Ping me. | |
const escapeHtml = (function () { | |
const serializer = new XMLSerializer (); | |
const attr = document.createAttribute ( 'attr' ); | |
const re = /[&<>"]/; | |
return function escapeHtml ( str ) { | |
if ( !re.test ( str ) ) return str; | |
attr.value = str; | |
return serializer.serializeToString ( attr ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require ( 'fs' ); | |
const content = fs.readFileSync ( 'War and Peace.md', 'utf-8' ); | |
const charCodesAt = new Array ( content.length ); | |
console.time('charCodeAt'); | |
for ( let i = 0, l = content.length; i < l; i++ ) { | |
charCodesAt[i] = content.charCodeAt ( i ); | |
} | |
console.timeEnd('charCodeAt'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* IMPORT */ | |
const esbuild = require ( 'esbuild' ); | |
const {nodeExternalsPlugin} = require ( 'esbuild-node-externals' ); | |
const monex = require ( 'monex' ); | |
const path = require ( 'path' ); | |
const {color, parseArgv} = require ( 'specialist' ); | |
const Watcher = require ( 'watcher' ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function bundle-bytes () { | |
#FIXME: code-only bundles, for some reaon the "--external" flags aren't respected | |
local full=`esbuild $@ --bundle --minify`; | |
local full_min=`echo $full | wc -c`; | |
local full_gzip=`echo $full | gzip | wc -c`; | |
local dependencies=`jq '.dependencies|keys[]' package.json`; | |
local dependencies_external=`echo $dependencies | sed -e 's/^/--external:/' | tr '\n' ' '`; | |
local code=`esbuild $@ --bundle --minify $dependencies_external`; | |
local code_min=`echo $code | wc -c`; | |
local code_gzip=`echo $code | gzip | wc -c`; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type _ = { | |
partial: Partial | |
}; | |
type Partial = { | |
/* WITH PLACEHOLDERS */ | |
<T1, R> ( fn: FN<[T1], R>, a1: _ ): FN<[T1], R>, | |
<T1, T2, R> ( fn: FN<[T1, T2], R>, a1: _ ): FN<[T1, T2], R>, | |
<T1, T2, R> ( fn: FN<[T1, T2], R>, a1: _, a2: T2 ): FN<[T1], R>, | |
<T1, T2, R> ( fn: FN<[T1, T2], R>, a1: T1, a2: _ ): FN<[T2], R>, |