This file contains hidden or 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
| /* | |
| Compress (gzip) JSON-serialisable object and output as base 64; Decompress base 64 data and output as parsed JSON. | |
| Useful for URLs, e.g. | |
| Compress: | |
| const bigObject = { ...lotsOfData }; | |
| const url = "https://www.example.com/?" + await compressToUrl(bigObject); |
This file contains hidden or 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
| import React, { | |
| useRef, | |
| useImperativeHandle | |
| } from "react"; | |
| import useAnimationFrame from "../hooks/animationFrame"; | |
| type UpdateHandler = (dt: number, canvas: HTMLCanvasElement) => void; | |
| export interface CanvasProps extends React.CanvasHTMLAttributes<HTMLCanvasElement> { | |
| onAnimationFrame: UpdateHandler; |
This file contains hidden or 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
| function decimalExpansion(numerator, denominator) { | |
| // Special case for 0 | |
| if (denominator === 0) { | |
| return null; | |
| } else if (numerator === 0) { | |
| return { whole: 0, nonRecurring: "", recurring: null }; | |
| } | |
| const whole = Math.floor(numerator / denominator); | |
| let remainder = numerator % denominator; |
This file contains hidden or 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 has moved to: https://github.com/dcollien/react-decimal-expansion |
OlderNewer