-
Notifications
You must be signed in to change notification settings - Fork 5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
100% Coverage web3-utills #7042
Changes from all commits
ebba894
5dc4390
9f9d6df
f0153dc
82a16b3
ad73c89
0d09e92
b0e0bb4
5b9bb46
8677c30
1392b05
f9559f3
d61bd1d
e8ccfff
4ad228a
9154389
3697767
c24c798
72e7095
12b198b
b9617ee
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,3 +47,5 @@ packages/web3/.in3/ | |
benchmark-data.txt | ||
|
||
.eslintcache | ||
|
||
.history |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,10 +57,8 @@ | |
|
||
for (const dataPart of dataPath) { | ||
if (result.oneOf && previousDataPath) { | ||
const path = oneOfPath.find(function (element: [string, number]) { | ||
return (this as unknown as string) === element[0]; | ||
}, previousDataPath ?? ''); | ||
|
||
const currentDataPath = previousDataPath; | ||
const path = oneOfPath.find(([key]) => key === currentDataPath); | ||
if (path && path[0] === previousDataPath) { | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access | ||
result = result.oneOf[path[1]]; | ||
|
@@ -75,10 +73,6 @@ | |
} else if (result.items && (result.items as JsonSchema).properties) { | ||
const node = (result.items as JsonSchema).properties as Record<string, JsonSchema>; | ||
|
||
if (!node) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we remove this |
||
return undefined; | ||
} | ||
|
||
result = node[dataPart]; | ||
} else if (result.items && isObject(result.items)) { | ||
result = result.items; | ||
|
@@ -307,7 +301,7 @@ | |
|
||
// If value is an object, recurse into it | ||
if (isObject(value)) { | ||
convert(value, schema, dataPath, format); | ||
convert(value, schema, dataPath, format, oneOfPath); | ||
dataPath.pop(); | ||
continue; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,6 @@ import { isNullish } from 'web3-validator'; | |
export type Timer = ReturnType<typeof setInterval>; | ||
export type Timeout = ReturnType<typeof setTimeout>; | ||
|
||
|
||
/** | ||
* An alternative to the node function `isPromise` that exists in `util/types` because it is not available on the browser. | ||
* @param object - to check if it is a `Promise` | ||
|
@@ -74,7 +73,6 @@ export async function waitWithTimeout<T>( | |
return result; | ||
} | ||
|
||
|
||
/** | ||
* Repeatedly calls an async function with a given interval until the result of the function is defined (not undefined or null), | ||
* or until a timeout is reached. It returns promise and intervalId. | ||
|
@@ -85,25 +83,27 @@ export function pollTillDefinedAndReturnIntervalId<T>( | |
func: AsyncFunction<T>, | ||
interval: number, | ||
): [Promise<Exclude<T, undefined>>, Timer] { | ||
|
||
let intervalId: Timer | undefined; | ||
const polledRes = new Promise<Exclude<T, undefined>>((resolve, reject) => { | ||
intervalId = setInterval(function intervalCallbackFunc(){ | ||
(async () => { | ||
try { | ||
const res = await waitWithTimeout(func, interval); | ||
|
||
if (!isNullish(res)) { | ||
intervalId = setInterval( | ||
(function intervalCallbackFunc() { | ||
(async () => { | ||
try { | ||
const res = await waitWithTimeout(func, interval); | ||
|
||
if (!isNullish(res)) { | ||
clearInterval(intervalId); | ||
resolve(res as unknown as Exclude<T, undefined>); | ||
} | ||
} catch (error) { | ||
clearInterval(intervalId); | ||
resolve(res as unknown as Exclude<T, undefined>); | ||
reject(error); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this file was changed from prettier |
||
} | ||
} catch (error) { | ||
clearInterval(intervalId); | ||
reject(error); | ||
} | ||
})() as unknown; | ||
return intervalCallbackFunc;}() // this will immediate invoke first call | ||
, interval); | ||
})() as unknown; | ||
return intervalCallbackFunc; | ||
})(), // this will immediate invoke first call | ||
interval, | ||
); | ||
}); | ||
|
||
return [polledRes as unknown as Promise<Exclude<T, undefined>>, intervalId!]; | ||
|
@@ -113,7 +113,7 @@ export function pollTillDefinedAndReturnIntervalId<T>( | |
* Repeatedly calls an async function with a given interval until the result of the function is defined (not undefined or null), | ||
* or until a timeout is reached. | ||
* pollTillDefinedAndReturnIntervalId() function should be used instead of pollTillDefined if you need IntervalId in result. | ||
* This function will be deprecated in next major release so use pollTillDefinedAndReturnIntervalId(). | ||
* This function will be deprecated in next major release so use pollTillDefinedAndReturnIntervalId(). | ||
* @param func - The function to call. | ||
* @param interval - The interval in milliseconds. | ||
*/ | ||
|
@@ -146,7 +146,7 @@ export function rejectIfTimeout(timeout: number, error: Error): [Timer, Promise< | |
/** | ||
* Sets an interval that repeatedly executes the given cond function with the specified interval between each call. | ||
* If the condition is met, the interval is cleared and a Promise that rejects with the returned value is returned. | ||
* @param cond - The function/confition to call. | ||
* @param cond - The function/condition to call. | ||
* @param interval - The interval in milliseconds. | ||
* @returns - an array with the interval ID and the Promise. | ||
*/ | ||
|
@@ -168,4 +168,3 @@ export function rejectIfConditionAtInterval<T>( | |
}); | ||
return [intervalId!, rejectIfCondition]; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed this for readability