better code: removed unused code
Massimo Melina committed
Aug 18, 2023 at 23:33 UTC
a5dc3aab8f465d69f80c5db0082a9523161478b7
2 files changed
+1
-14
shared/api.ts
+1
-1
@@ -2,7 +2,7 @@
2
3
import _ from 'lodash';
4
import { useCallback, useEffect, useRef } from 'react';
5
-import { Dict, Falsy, getCookie, getPrefixUrl, pendingPromise, useStateMounted } from '.'
5
+import { Dict, Falsy, getPrefixUrl, pendingPromise, useStateMounted } from '.'
6
7
export const API_URL = '/~/api/'
8
shared/index.ts
-13
@@ -48,19 +48,6 @@ export function wait<T=undefined>(ms: number, val?: T): Promise<T> {
48
return new Promise(res=> setTimeout(res,ms,val))
49
}
50
51
-export function getCookie(name: string) {
52
- const pre = name + '='
53
- //@ts-ignore necessary to import this file in tests.ts (node doesn't have document)
54
- let decodedCookie = decodeURIComponent(document.cookie)
55
- let ca = decodedCookie.split(';')
56
- for (let c of ca) {
57
- c = c.trim()
58
- if (c.startsWith(pre))
59
- return c.substring(pre.length, c.length)
60
- }
61
- return ''
62
-}
63
-
51
export function objSameKeys<S extends object,VR=any>(src: S, newValue:(value:Truthy<S[keyof S]>, key:keyof S)=>VR) {
52
return Object.fromEntries(Object.entries(src).map(([k,v]) => [k, newValue(v,k as keyof S)])) as { [K in keyof S]:VR }
53
}