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 { 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>() |
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 useInstance<ElementType extends HTMLElement = HTMLDivElement>(component?) { | |
| return shallowRef< | |
| typeof component extends undefined | |
| ? ElementType | |
| : InstanceType<typeof component> | |
| >(null) | |
| } |
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 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 |
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 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>) |
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 { 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: реализовать |
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 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', |
NewerOlder