Skip to content

Instantly share code, notes, and snippets.

View doasync's full-sized avatar
🎯
Focusing

Ruslan @doasync doasync

🎯
Focusing
View GitHub Profile
@doasync
doasync / The Inevitable Architecture.md
Last active January 18, 2026 20:45
Foundational architectural thesis ❗This paper represents months of deep research by the Effector Core Team. We discovered that by applying principles from Harvard Architecture, Linear Logic, and Thermodynamics, we can mathematically prove the efficiency of a reactive system.

A Unified Theory of Reactive Business Logic and State Management

Authors: The Effector Core Team Date: January 15, 2026 Subject: Theoretical Foundations of @effector/model

Abstract

The contemporary landscape of frontend engineering has reached an inflection point where traditional state management paradigms—focused primarily on data synchronization and propagation—are no longer sufficient for modeling complex, high-entropy business domains. As application scale increases, the primary challenge shifts from the storage of values to the orchestration of capabilities, the enforcement of topological constraints, and the management of polymorphic behavior.

@doasync
doasync / human-format.ts
Created February 4, 2021 17:27
Human format
type ReadableConfig = {
separator?: string;
unit?: string;
formatFn?: (value: number) => string;
fractional?: boolean;
};
// Sorted from big to small
// See: https://www.bipm.org/en/measurement-units
const si = [
@doasync
doasync / cached.js
Last active January 7, 2022 16:35
Create cached function (memoize)
export const cached = (fn) => {
const cache = new Map();
return function cachedFn(...args) {
const input = JSON.stringify(args);
if (cache.has(input)) {
return cache.get(input);
}
@doasync
doasync / round.ts
Created October 19, 2020 12:23
Round number with precision (TypeScrypt)
export const round = (number: number, fractionDigits = 0): number => {
const digits = 10 ** fractionDigits;
const value = number * digits * (1 + Number.EPSILON);
return Math.round(value) / digits;
};
@doasync
doasync / fry.js
Last active September 3, 2020 12:13
fry with interceptors
'use strict';
const queryString = (params) => {
const qs = String(new URLSearchParams(params));
return qs ? `?${qs}` : "";
};
const joinBase = (url, baseUrl) =>
`${baseUrl.replace(/\/$/, "")}/${url.replace(/^\/|\/$/, "")}/`;
@doasync
doasync / error-map.js
Last active May 26, 2020 11:14
Final form validators
import {
notEmpty,
booleanType,
numberType,
numberMin,
numberMax,
numberGt,
numberLt,
numberBetween,
integerType,
@doasync
doasync / NameModal.jsx
Created April 28, 2020 17:46
Effector modal model
// Сам компонент модалки при этом будет выглядеть примерно так:
// ...
const onSubmit = () => {
closeModal();
saveNameAction();
};
// Component
@doasync
doasync / request.js
Last active May 29, 2020 10:39
Axios-like fetch
const queryString = (params) => {
const qs = String(new URLSearchParams(params));
return qs ? `?${qs}` : "";
};
const joinBase = (url, baseUrl) =>
`${baseUrl.replace(/\/$/, "")}/${url.replace(/^\/|\/$/, "")}/`;
const contentTypeJson = { "Content-Type": "application/json" };
@doasync
doasync / perf.js
Last active April 8, 2019 17:51
Browser or Node.js JavaScript performance test (jsperf): for..in vs for + Object.keys vs for..of + Object.keys vs for..of + Object.entries
// Run each test in the new tab
const { performance, PerformanceObserver } = typeof window !== 'undefined' ? window : require('perf_hooks');
function test() {
let objectSize = 30;
let iterations = 7000;
const values = {
'ENTRIES': 0,
'FOR-OF-KEYS': 0,
@doasync
doasync / __example.js
Last active March 15, 2019 02:08
Flow 0.92.1: CustomEvent type with addEventListener (put dom.js to flow-typed folder)
// @flow
const myEvent = new CustomEvent<{ body: string }>('eventType', {
detail: { body: 'Specific Text' },
});
const myEventHandler = (event: typeof myEvent) => {
if (event.detail.body === 'Specific Text') {
// perform a certain action
}