How to use the js-git/lib/object-codec.frame function in js-git

To help you get started, we’ve selected a few js-git examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github creationix / js-github / mixins / github-db.js View on Github external
tree: encodeTree,
  blob: encodeBlob
};

var decoders = {
  commit: decodeCommit,
  tag: decodeTag,
  tree: decodeTree,
  blob: decodeBlob,
};

var typeCache = {};

// Precompute hashes for empty blob and empty tree since github won't
var empty = bodec.create(0);
var emptyBlob = sha1(frame({ type: "blob", body: empty }));
var emptyTree = sha1(frame({ type: "tree", body: empty }));

// Implement the js-git object interface using github APIs
module.exports = function (repo, root, accessToken, githubHostname) {

  var apiRequest = xhr(root, accessToken, githubHostname);

  repo.loadAs = loadAs;         // (type, hash) -> value, hash
  repo.saveAs = saveAs;         // (type, value) -> hash, value
  repo.listRefs = listRefs;     // (filter='') -> [ refs ]
  repo.readRef = readRef;       // (ref) -> hash
  repo.updateRef = updateRef;   // (ref, hash) -> hash
  repo.deleteRef = deleteRef    // (ref) -> null
  repo.createTree = createTree; // (entries) -> hash, tree
  repo.hasHash = hasHash;
github digidem / react-mapfilter / app / js / lib / backbone-github.js View on Github external
blob: encodeBlob
};

var decoders = {
  commit: decodeCommit,
  tag: decodeTag,
  tree: decodeTree,
  blob: decodeBlob,
};

var typeCache = {};

// Precompute hashes for empty blob and empty tree since github won't
var empty = bodec.create(0);
var emptyBlob = sha1(frame({ type: "blob", body: empty }));
var emptyTree = sha1(frame({ type: "tree", body: empty }));

// Implement the js-git object interface using github APIs
module.exports = function (repo, root, accessToken) {

  var apiRequest = xhr(root, accessToken);

  repo.loadAs = loadAs;         // (type, hash) -> value, hash
  repo.saveAs = saveAs;         // (type, value) -> hash, value
  repo.readRef = readRef;       // (ref) -> hash
  repo.updateRef = updateRef;   // (ref, hash) -> hash
  repo.createTree = createTree; // (entries) -> hash, tree
  repo.hasHash = hasHash;

  function loadAs(type, hash, callback) {
    if (!callback) return loadAs.bind(repo, type, hash);
    // Github doesn't like empty trees, but we know them already.
github creationix / js-github / mixins / github-db.js View on Github external
function hashAs(type, body) {
  var buffer = frame({type: type, body: body});
  return sha1(buffer);
}
github digidem / react-mapfilter / app / js / lib / backbone-github.js View on Github external
function hashAs(type, body) {
  var buffer = frame({type: type, body: body});
  return sha1(buffer);
}