Skip to content

Instantly share code, notes, and snippets.

import { style } from '@vanilla-extract/css';
const NEW_RULE = /(?:([\u0080-\uFFFF\w-%@]+) *:? *([^{;]+?);|([^;}{]*?) *{)|(}\s*)/g;
const RULE_CLEAN = /\/\*[^]*?\*\/| +/g;
const RULE_NEWLINE = /\n+/g;
const EMPTY = ' ';
/**
* @param {string} val
* @returns {object}
import { stableStringify } from '@intrnl/stable-stringify';
const defaultKey = () => {};
const defaultId = (x) => x.id;
export const createBatchedFetch = (options) => {
const {
fetch,
limit = 100,
let effects = [];
let current = null;
let dirty = 0n;
let flushing = false;
export let access = Symbol();
export function state (flag, value) {
import http from 'node:http';
export function createRunner (middlewares) {
/**
* @param {http.IncomingMessage} request
* @param {http.ServerResponse} response
* @param {(error?: any) => void} done
*/
return function runner (request, response, done = createFinalHandler(request, response)) {
let idx = 0;
let map;
function generateUUID () {
const buf = crypto.getRandomValues(new Uint8Array(16));
buf[6] = (buf[6] & 0x0f) | 0x40;
buf[8] = (buf[8] & 0x3f) | 0x80;
if (!map) {
map = [];
@intrnl
intrnl / _readme.md
Last active July 31, 2022 10:56
Create exclusion list for PSO2 NGS Global

Creates an exclusion list to only download the NGS version for PSO2 Global.

You can't use this on a mainline version of Legendary just yet, pull request is still pending

@intrnl
intrnl / bench.mjs
Last active July 24, 2022 06:29
HTML escape function #bench
import { run, bench, group } from 'https://esm.sh/mitata';
function escape (value) {
const str = '' + value;
const res = str.replace(/[&<]/g, (char) => '&#' + char.charCodeAt(0) + ';');
return res;
}
import * as tty from 'node:tty';
const isTTY = tty.isatty(1) && process.env.TERM !== 'dumb' && !('CI' in process.env);
export function createLogger (options = {}) {
let { text = '', interval = 50, stream = process.stdout, hideCursor = false } = options;
let rows = 0;
let timer;
/**
* @param {HTMLElement} node
* @param {string} target
* @returns {?HTMLElement}
*/
export function query (node, target) {
if (node.matches(`[x-target~='this.${target}']`)) {
return node;
}
@intrnl
intrnl / jsx2dom.js
Created June 18, 2022 03:12
JSX to DOM nodes
export function h (type, props, ...children) {
if (typeof type === 'function') {
if (props === null) {
props = {};
}
if (children.length > 0) {
props.children = children;
}