react-ready-state-effect
Version:
React Effect Hook based on document.readyState
12 lines (10 loc) • 352 B
text/typescript
import { ExpectedReadyState } from "./ExpectedReadyState";
export const isReadyStateMatch = (expected?: ExpectedReadyState): boolean => {
if (!expected) {
return true;
}
if (("string" === typeof expected) && document.readyState === expected) {
return true;
}
return expected.indexOf(document.readyState) !== -1;
};