This file contains 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
<script setup lang="ts"> | |
const props = defineProps<{ | |
startAt?: Date | number | |
endAt?: Date | number | |
now?: Date | number | |
}>() | |
const isBetween = computed(() => { | |
const now = props.now ?? Date.now() | |
const startAt = props.startAt ?? now |
This file contains 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 { useStorage } from '@vueuse/core' | |
export const useStoredState = <T>(key: string, initValue: T) => { | |
const shared = useState<T>(key, () => initValue) | |
const stored = useStorage<T>(key, initValue) | |
const state = computed({ | |
get: () => shared.value, | |
set: (value: T) => { | |
shared.value = value |
This file contains 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
{ | |
"firestore": { | |
"rules": "firestore.rules", | |
"indexes": "firestore.indexes.json" | |
}, | |
"functions": [ | |
{ | |
"codebase": "backend", | |
"source": "packages/firebase-functions", | |
"ignore": [ |
This file contains 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 { describe, expect, it, test, vi } from 'vitest' | |
import { | |
unwrapRefs, | |
wrapRefs, | |
} from './unwrapRef' | |
describe('unwrapRefs', () => { | |
it('should be enabled to use Ref', () => { | |
const source = { |
This file contains 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
export type Prettify<T> = { | |
[K in keyof T]: T[K] | |
} & {} |
This file contains 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 { ref } from 'vue-demi' | |
import type { Ref, UnwrapRef } from 'vue-demi' | |
import { createGlobalState, useSessionStorage } from '@vueuse/core' | |
export type StorableRef<T> = Ref<T> & { | |
commit: () => void | |
restore: () => void | |
} | |
const createState = <T>(storageKey: string, initialValue: T) => createGlobalState(() => useSessionStorage(storageKey, initialValue)) |
This file contains 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 { Ref } from 'vue' | |
import { createGlobalState, createSharedComposable } from '@vueuse/core' | |
const createBaseStore = <T>() => createGlobalState<Record<string, Ref<T>>>(() => reactive({})) | |
const useBaseStore = createSharedComposable(createBaseStore) | |
export const useState = <T>(key: string, init?: () => T): Ref<T> => { | |
const store = useBaseStore<T>() | |
const state = store[key] |
This file contains 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 pickAndFilter = <T extends { id: string }>(id: string, items: Array<T>): [T | undefined, T[]] => { | |
const picked: T[] = [] | |
const remained = items.reduce((accumulator: T[], item) => { | |
if (item.id === id) { | |
picked.push(item) | |
} else { | |
accumulator.push(item) | |
} | |
return accumulator | |
}, []) |
This file contains 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
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing! | |
VAGRANTFILE_API_VERSION = "2" | |
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| | |
config.vm.box = "centos64_ja" | |
config.vm.box_url = "https://dl.dropboxusercontent.com/u/3657281/centos64_ja.box" | |
config.vm.hostname = "vagrant-test.local" |
NewerOlder