{"id":23814449,"url":"https://github.com/stuartpb/gistachio","last_synced_at":"2026-02-28T23:02:30.368Z","repository":{"id":25412831,"uuid":"28841917","full_name":"stuartpb/gistachio","owner":"stuartpb","description":"Add public, versioned storage to your single-page apps with one function","archived":false,"fork":false,"pushed_at":"2017-02-22T08:26:15.000Z","size":11,"stargazers_count":4,"open_issues_count":5,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-28T01:04:22.223Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stuartpb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-01-06T02:00:40.000Z","updated_at":"2021-04-03T01:34:48.000Z","dependencies_parsed_at":"2022-08-23T07:10:13.850Z","dependency_job_id":null,"html_url":"https://github.com/stuartpb/gistachio","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/stuartpb/gistachio","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stuartpb%2Fgistachio","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stuartpb%2Fgistachio/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stuartpb%2Fgistachio/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stuartpb%2Fgistachio/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stuartpb","download_url":"https://codeload.github.com/stuartpb/gistachio/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stuartpb%2Fgistachio/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29954583,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-28T22:53:01.873Z","status":"ssl_error","status_checked_at":"2026-02-28T22:52:50.699Z","response_time":90,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-01-02T03:47:41.250Z","updated_at":"2026-02-28T23:02:30.350Z","avatar_url":"https://github.com/stuartpb.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gistachio\n\nLightweight Gist JS functions for browsers.\n\nI made this because all the JS libraries I could find for working with Gists\nout there either have heavyweight dependencies like jQuery, or are written for\nNode.JS / browserify. I prefer my libraries to be lightweight and\nself-contained wherever possible.\n\n## Demo / examples\n\nSee gistachio in action at https://stuartpb.github.io/gistachio/demo.html\n\n## Requirements\n\nThis script uses `addEventListener` on XMLHttpRequest to handle its loading and\npotential error scenarios, so you'll need a browser that supports the progress\nevents for XHR. This has been supported in the evergreen browsers (Firefox and\nChrome) for several years - as usual, the only place you'll encounter problems\nwill be with Internet Explorer, which didn't implement XHR events until IE10\n(if [MDN's support matrix][MDNXHR] is to be believed).\n\nTo use this in earlier versions of IE (or some similarly ancient version of any\nother browser), you'll need to implement a\n[polyfill for these events on XMLHttpRequest][polyfill]. This seems like a\nsensible thing to want, making it altogether more surprising that none seems to\nexist at time of writing (January 6 2015).\n\n[MDNXHR]: https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest#compat-desktop\n[polyfill]: https://github.com/inexorabletash/polyfill/issues/49\n\n## Usage\n\nUse this file by including it as a `\u003cscript\u003e`. It will add `window.gistachio`.\n\n### Callback error handling\n\ngistachio's callback signatures use the traditional Node.JS convention of\ntaking an `err` argument first, which will be `null` if the operation succeeds\nwith no errors, or some truthy value if there is an error.\n\nThe potential values for `err` are:\n\n- A parsed JSON error from the GitHub API, eg. if your request doesn't match\n  the expected format. gistachio does only a little coercion (for postFiles)\n  and does no validation of its own, so this is the most likely error you're\n  going to encounter.\n- A JSON parse error if the request succeeds (at the network level), but\n  something goes wrong interpreting the response from the API as JSON. The\n  original body that failed to parse will probably be in some property on that\n  error, although I'm not sure what. I think this is one of those non-standard\n  things that varies from browser to browser.\n- A ProgressEvent passed to the event handler for one of XMLHttpRequest's\n  non-successful load events: `error`, `abort`, or `timeout`. I couldn't find\n  any documentation signifying how errors are signaled: again, the salient data\n  will likely be somewhere beentween a spec-compliant standard property and a\n  non-standard and browser-dependent feature of the error.\n\n### Common options\n\nThese options are supported on all methods:\n\n- `accessToken`: an [OAuth 2 access token][oauth] to authenticate requests to\n  the GitHub API. You need this to post user-owned, non-anonymous gists, or to\n  make changes to a user's already-posted gists. The accessToken can also be\n  used for many other GitHub API tasks that aren't covered by gistachio.\n- `username` and `password`: The less-savory alternative to using `accessToken`\n  to authenticate requests as a user. You really shouldn't use this kind of\n  authentication. Even if it's just your own account, you should generate a\n  personal access token at https://github.com/settings/applications instead of\n  passing your password around through anything other than a GitHub login page.\n\n[oauth]: https://developer.github.com/v3/oauth/\n\n### gistachio.getFiles(gistId, [opts,] callback)\n\nGets the files for the gist with the given ID.\n\nThe callback signature is `(err, files)`, where `files` is an object with the\nfilenames of the gist as the keys, and the contents of each file as string\nvalues.\n\nBehind the scenes, this will entail multiple requests if any of the Gist's\nfiles are over the [truncation limit][truncation] (one megabyte) for the Gist\nAPI. If any files are over *ten* megabytes (the limit of the raw content CDN),\nthey are beyond the reach of ordinary API requests, and you will need a\nheavyweight solution, involving full-on Git checkouts, to retrieve them (see\nthe previous link).\n\n[truncation]: https://developer.github.com/v3/gists/#truncation\n\n### gistachio.postFiles(files, [opts,] callback)\n\nCreate a new gist with the given files.\n\nThe `files` object can mirror the structure of the `getFiles` response, where\neach value is the string content of the filenamed by the key. The values can\nalso be objects, with the file's content as the string value of the `content`\nproperty. This is the format expected by the API (the former will be converted\nto the latter by gistachio), and this leaves room for the structure of the\n`files` argument used for editing Gists, where the object can also have a\n`filename` property to rename the file (see the documentation for patchFiles\nbelow).\n\nIf authentication for a user (as described above, either via token or\nusername+password) is provided, the created gist will be owned by the\nauthenticated user. Otherwise it will be posted anonymously, with no owner, and\nno way to edit the gist after posting (other than to create a fork).\n\nIn addition to the authentication options, a `description` option can be\nprovided as part of `opts`, specifying a default description for the gist. A\n`public` option can also be specified, with a value of `true` posting the gist\nas a public, discoverable, and (if authentication is provided and the gist is\ncreated with an owner) listed on the owner's Gist profile.\n\nThe callback signature is `(err, gistId)`, where `gistId` is the ID of the\nnewly-created gist (accessible by going to `https://gist.github.com/` + the ID,\nwhich will redirect you to the username (or `anonymous`) prefixed URL for the\ngist.\n\n### gistachio.patchFiles(gistId, files, [opts,] callback)\n\nEdit an existing gist.\n\nThe `files` argument is an object describing the *changes* that will be made\nto any files in the gist. Any files not present in the `files` object will be\n*unchanged* from their existing contents. As with postFiles, the values of the\n`files` object's filename keys may be either string contents (containing the\nnew content for the named file), or an object with a `content` property\ncontaining the file's new content, and/or a `filename` property containing the\nfile's new name. (To delete a file, use `{filename: null}` as the file's\nvalue.) [See the API documentation.][edit-a-gist] Any keys in `files` that\ndon't match an existing file's name will create a new file in the gist.\n\n[edit-a-gist]: https://developer.github.com/v3/gists/#edit-a-gist\n\npatchFiles can take a `description` option to edit the gist's description,\nproviding the new description as the value. (Due to\n[an oversight in the API][isaacs/github#329], it is *not* currently possible\nto change the gist's publication status via the `public` option, the way it is\nwhen initially creating the gist.)\n\n[isaacs/github#329]: https://github.com/isaacs/github/issues/329\n\nAs anonymous gists do not allow editing, this will need authentication in the\nform of `accessToken` or `username` and `password` options, for the user who\nowns the gist. (Failure to do so will result in an error from the GitHub API,\nobviously.)\n\nThe callback signature for patchFiles is the same as getFiles, returning the\ngist's new contents after the modification is applied. The same caveats around\ntruncation limits and multiple requests apply.\n\n## FAQ\n\n### I want to work with more than just file contents and gist IDs!\n\nIf you want access to everything provided by the GitHub API, use a proper\nGitHub API JS module. This module is just for handling files (and posting the\ndescriptions / public status because there's plenty of room for it in the\ndesign).\n\n## [License in Three Lines ![(LITL)](https://litl-license.org/logo.svg)][LITL]\n\n[LITL]: https://litl-license.org\n\nCopyright 2015 Stuart P. Bentley.\u003cbr\u003e\nThis work may be used freely as long as this notice is included.\u003cbr\u003e\nThe work is provided \"as is\" without warranty, express or implied.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstuartpb%2Fgistachio","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstuartpb%2Fgistachio","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstuartpb%2Fgistachio/lists"}