Skip to content

Instantly share code, notes, and snippets.

View TheLucifurry's full-sized avatar

Lucifurry TheLucifurry

View GitHub Profile
import { shallowRef } from 'vue'
import { DiffMap } from '../../utils/structures/DiffMap'
import { useRecords } from './useRecords'
/**
* Придает DiffMap-у реактивное поведение
*/
export function useDiffMap<K extends string | number, V extends Record<string, unknown>>() {
const diffMap = new DiffMap<K, V>()
const records = useRecords<K, V>()
function useInstance<ElementType extends HTMLElement = HTMLDivElement>(component?) {
return shallowRef<
typeof component extends undefined
? ElementType
: InstanceType<typeof component>
>(null)
}
function useDataTable<
K extends string | number | symbol,
V extends Record<string, unknown>
>(options: IOptions<V> = {}) {
const list = shallowReactive({}) as Record<K, V>
const size = ref(0)
const {
merge = mergeSimple,
} = options
function useRefsMap<K extends string | number | symbol, V>() {
const mapRefs = new Map<K, Ref<V | undefined>>()
return {
...mapRefs,
set(key: K, value: V) {
if (mapRefs.has(key)) {
const r = mapRefs.get(key)!
r.value = value
} else {
mapRefs.set(key, ref(value) as Ref<V>)
import { isEqual, isPlainObject as lodashIsPlainObject } from '../lodash'
type If<V extends boolean, Then, Else> = V extends true ? Then : Else
function isPlainObject(value: unknown): value is object {
return lodashIsPlainObject(value)
}
function getDifference<V>(_source: V, changed: Partial<V>): Partial<V> {
return changed // TODO: реализовать
@TheLucifurry
TheLucifurry / tint.ts
Created October 5, 2023 08:09
Tiny console coloring function
const colors = {
black: '\x1B[30m',
red: '\x1B[31m',
green: '\x1B[32m',
yellow: '\x1B[33m',
blue: '\x1B[34m',
magenta: '\x1B[35m',
cyan: '\x1B[36m',
white: '\x1B[37m',
gray: '\x1B[90m',