How to use the bodec.encodeUtf8 function in bodec

To help you get started, we’ve selected a few bodec 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 es-git / es-git / lib / encoders.js View on Github external
function encodeCommit(body) {
  var str = "tree " + body.tree;
  for (var i = 0, l = body.parents.length; i < l; ++i) {
    str += "\nparent " + body.parents[i];
  }
  str += "\nauthor " + formatPerson(body.author) +
         "\ncommitter " + formatPerson(body.committer) +
         "\n\n" + body.message;
  return binary.encodeUtf8(str);
}
github digidem / react-mapfilter / app / js / lib / backbone-github.js View on Github external
function encodeBlob(blob) {
  if (typeof blob === "string") return {
    content: bodec.encodeUtf8(blob),
    encoding: "utf-8"
  };
  if (bodec.isBinary(blob)) return {
    content: bodec.toBase64(blob),
    encoding: "base64"
  };
  throw new TypeError("Invalid blob type, must be binary or string");
}
github es-git / es-git / lib / encoders.js View on Github external
function encodeTag(body) {
  var str = "object " + body.object +
    "\ntype " + body.type +
    "\ntag " + body.tag +
    "\ntagger " + formatPerson(body.tagger) +
    "\n\n" + body.message;
  return binary.encodeUtf8(str);
}
github creationix / js-github / mixins / github-db.js View on Github external
function encodeBlob(blob) {
  if (typeof blob === "string") return {
    content: bodec.encodeUtf8(blob),
    encoding: "utf-8"
  };
  if (bodec.isBinary(blob)) return {
    content: bodec.toBase64(blob),
    encoding: "base64"
  };
  throw new TypeError("Invalid blob type, must be binary or string");
}
github es-git / es-git / mixins / github-db.js View on Github external
function encodeBlob(blob) {
  if (typeof blob === "string") return {
    content: binary.encodeUtf8(blob),
    encoding: "utf-8"
  };
  if (binary.isBinary(blob)) return {
    content: binary.toBase64(blob),
    encoding: "base64"
  };
  throw new TypeError("Invalid blob type, must be binary of string");
}
github digidem / react-mapfilter / app / js / lib / backbone-github.js View on Github external
function encodeTree(body) {
  var tree = "";
  if (Array.isArray(body)) throw new TypeError("Tree must be in object form");
  var list = Object.keys(body).map(treeMap, body).sort(treeSort);
  for (var i = 0, l = list.length; i < l; i++) {
    var entry = list[i];
    tree += entry.mode.toString(8) + " " + bodec.encodeUtf8(entry.name) +
            "\0" + bodec.decodeHex(entry.hash);
  }
  return bodec.fromRaw(tree);
}
github es-git / es-git / ts / lib / object-codec.ts View on Github external
function encodeTree(body : TreeBody) {
  let tree = "";
  if (Array.isArray(body)) throw new TypeError("Tree must be in object form");
  const list = Object.keys(body).map(treeMap, body).sort(treeSort);
  for (let i = 0, l = list.length; i < l; i++) {
    const entry = list[i];
    tree += entry.mode.toString(8) + " " + bodec.encodeUtf8(entry.name) +
            "\0" + bodec.decodeHex(entry.hash);
  }
  return bodec.fromRaw(tree);
}