@deek80/gh-reader

3.0.0 • Public • Published

gh-reader

Get files from Github in Javascript

This is a simple wrapper around fetch which gets file or directory listings from GitHub via anonymous API calls. There's reasonable HTTP caching in GitHub already (60s on any directory or file listing) and the ratelimit is 60 calls (i.e. fresh / cache miss) per hour.

The returned File objects can have their text/json/etc content downloaded from the corresponding raw.githubusercontent site.

Example:

const repo = new Repo("deek80/gh-reader");
const srcFiles = await repo.ls("src");
// and `srcFiles` looks like:
[
  File({name: "api.js", type: "file", path: "src/api.js", ...}),
  File({name: "index.js", type: "file", path: "src/index.js", ...}),
  ...
]

const content = await srcFiles[0].download();
// `download` gets text by default

Readme

Keywords

Package Sidebar

Install

npm i @deek80/gh-reader

Weekly Downloads

1

Version

3.0.0

License

MIT

Unpacked Size

6.93 kB

Total Files

7

Last publish

Collaborators

  • deek80