push
github
8 of 9 branches covered (88.89%)
Branch coverage included in aggregate %.
52 of 53 new or added lines in 2 files covered. (98.11%)
52 of 53 relevant lines covered (98.11%)
2.96 hits per line
|
type Options = { |
1✔ |
|
base?: string
|
1✔ |
|
fetch?: Function |
1✔ |
|
} |
1✔ |
|
|
1✔ |
|
const createEnhancedFunction = ({
|
|
|
base = '',
|
2✔ |
|
fetch = () => {}, |
2✔ |
|
}: Options = {}) => new Proxy((o: any) => createEnhancedFunction(o), {
|
|
|
get(obj: any, prop: any) { |
|
|
return obj[prop]
|
1✔ |
|
?? ( |
1✔ |
|
(...args: any) => { |
|
|
// console.log('calling method', prop, 'with args', args)
|
1✔ |
|
// console.log('typeof args[0]', typeof args[0])
|
1✔ |
|
base = base + ( |
1✔ |
|
typeof args[0] == 'string' |
|
NEW
|
? args.shift() |
× |
|
: ''
|
1✔ |
|
) |
1✔ |
|
// console.log({
|
1✔ |
|
// base,
|
1✔ |
|
// fetch,
|
1✔ |
|
// })
|
1✔ |
|
return fetch(base, ...args)
|
1✔ |
|
} |
1✔ |
|
) |
1✔ |
|
} |
1✔ |
|
}) |
2✔ |
|
|
1✔ |
|
export const fetcher = createEnhancedFunction() |
1✔ |