Download apps/readest-app/src/utils/polyfill.ts from echodict/readest: direct link, hf CLI and curl.
- Browser
- Download file 615 Bytes
-
https://huggingface.co/datasets/echodict/readest/resolve/main/apps/readest-app/src/utils/polyfill.ts
- Command line
-
hf download hf://datasets/echodict/readest/apps/readest-app/src/utils/polyfill.ts
-
curl -L -o polyfill.ts https://huggingface.co/datasets/echodict/readest/resolve/main/apps/readest-app/src/utils/polyfill.ts
615 Bytes
| // A groupBy polyfill for foliate-js | |
| Object.groupBy ??= (iterable, callbackfn) => { | |
| const obj = Object.create(null); | |
| let i = 0; | |
| for (const value of iterable) { | |
| const key = callbackfn(value, i++); | |
| if (key in obj) { | |
| obj[key].push(value); | |
| } else { | |
| obj[key] = [value]; | |
| } | |
| } | |
| return obj; | |
| }; | |
| Map.groupBy ??= (iterable, callbackfn) => { | |
| const map = new Map(); | |
| let i = 0; | |
| for (const value of iterable) { | |
| const key = callbackfn(value, i++), | |
| list = map.get(key); | |
| if (list) { | |
| list.push(value); | |
| } else { | |
| map.set(key, [value]); | |
| } | |
| } | |
| return map; | |
| }; | |