This repository has been archived by the owner on May 19, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #138 from aidenybai/staging
Staging
- Loading branch information
Showing
13 changed files
with
129 additions
and
105 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
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
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
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
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
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
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import fiber from '../fiber'; | ||
|
||
describe('.fiber', () => { | ||
it('should be a function', () => { | ||
expect(typeof fiber).toEqual('function'); | ||
}); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,23 @@ | ||
/* istanbul ignore file */ | ||
|
||
// Concurrent allows us to delay render calls if the main thread is blocked | ||
// Fiber allows us to delay render calls if the main thread is blocked | ||
// This is kind of like time slicing in React but less advanced | ||
|
||
export const concurrent = ( | ||
threshold: number, | ||
export const fiber = ( | ||
generatorFunction: () => Generator<undefined, void, unknown> | ||
// eslint-disable-next-line @typescript-eslint/ban-types | ||
): Function => { | ||
): IdleRequestCallback => { | ||
const generator = generatorFunction(); | ||
return function next() { | ||
const start = performance.now(); | ||
return function next(deadline: IdleDeadline) { | ||
let task = null; | ||
do { | ||
task = generator.next(); | ||
} while (performance.now() - start < threshold && !task.done); | ||
} while (!task.done && deadline.timeRemaining() > 0); | ||
|
||
if (task.done) return; | ||
/* istanbul ignore next */ | ||
setTimeout(next); | ||
requestIdleCallback(next); | ||
}; | ||
}; | ||
|
||
export default concurrent; | ||
export default fiber; |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1399,6 +1399,11 @@ | |
resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-2.2.3.tgz#ef65165aea2924c9359205bf748865b8881753c0" | ||
integrity sha512-PijRCG/K3s3w1We6ynUKdxEc5AcuuH3NBmMDP8uvKVp6X43UY7NQlTzczakXP3DJR0F4dfNQIGjU2cUeRYs2AA== | ||
|
||
"@types/requestidlecallback@^0.3.1": | ||
version "0.3.1" | ||
resolved "https://registry.yarnpkg.com/@types/requestidlecallback/-/requestidlecallback-0.3.1.tgz#34bb89753b1cdc72d0547522527b1cb0f02b5ec4" | ||
integrity sha512-BnnRkgWYijCIndUn+LgoqKHX/hNpJC5G03B9y7mZya/C2gUQTSn75fEj3ZP1/Rl2E6EYeXh2/7/8UNEZ4X7HuQ== | ||
|
||
"@types/[email protected]": | ||
version "1.17.1" | ||
resolved "https://registry.yarnpkg.com/@types/resolve/-/resolve-1.17.1.tgz#3afd6ad8967c77e4376c598a82ddd58f46ec45d6" | ||
|