https://github.com/kchapelier/gist-load
Load the content of a Gist file in the browser
https://github.com/kchapelier/gist-load
Last synced: 7 months ago
JSON representation
Load the content of a Gist file in the browser
- Host: GitHub
- URL: https://github.com/kchapelier/gist-load
- Owner: kchapelier
- License: mit
- Created: 2019-06-02T10:30:56.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-06-02T11:27:36.000Z (over 6 years ago)
- Last Synced: 2025-02-14T02:52:07.964Z (8 months ago)
- Language: JavaScript
- Size: 4.88 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# gist-load
Load the content of a Gist file in the browser.
**Features**
* Does not use the Github API, does not require an API token.
* No dependency.
* Written in conservative ES5.
* Small bundle size.**Warning**
Github may break this at any time so it isn't recommended to use this in any critical project.
It is perfect to maintain an external list of presets for creative coding projects and the likes though.## Installing
With [npm](http://npmjs.org) do:
```
npm install gist-load --production
```## Examples
### Load json from a Gist with a single file
```js
const gistLoad = require('gist-load');gistLoad(
{
url: 'https://gist.github.com/kchapelier/8f0d755cc77e7e5a53d1cf9a38cbee6d',
contentType: 'json'
},
function (error, data) {
console.log('ERR:', error);
console.log('DAT:', data);
}
);
```### Load text from a Gist with multiple files
```js
const gistLoad = require('gist-load');gistLoad(
{
url: 'https://gist.github.com/kchapelier/8e41a80f88a4aec685a343151c38efcf',
file: 'file2.txt',
},
function (error, data) {
console.log('ERR:', error);
console.log('DAT:', data);
}
);
```## API
### gistLoad(options, callback)
Load the content of a gist file.
**Arguments**
* **options :**
* *url :* String. Url of the Gist (mandatory)
* *file :* String. Name of the file (mandatory for Gist with multiple files)
* *contentType :* String. `string` or `json`, default to `string`
* *cache :* Boolean. Whether to cache the result of the query, default to `false`
* **callback :** A node-style / error-first callback.## History
### [1.0.0](https://github.com/kchapelier/gist-load/tree/1.0.0) (2019-06-02) :
* First release
## License
MIT