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.
With npm do:
npm install gist-load --production
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);
}
);
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);
}
);
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
orjson
, default tostring
-
cache : Boolean. Whether to cache the result of the query, default to
false
- callback : A node-style / error-first callback.
1.0.0 (2019-06-02) :
- First release
MIT