How to use the bodec.js.toUnicode 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 creationix / tedit / src / git-tree.js View on Github external
hash: ruleEntry.hash
            });
          }

          if (!entry) {
            // If you get here, the entry didn't match
            // In raw-mode this is a no-find.
            if (!bake) break;
            // In bake mode, look for rule that may serve this path.
            return searchRules();
          }

          if (bake && (entry.mode === modes.sym)) {
             if (!check("blob", entry.hash)) return;
             var blob = storage.get(entry.hash);
             var link = binary.toUnicode(blob);
             var rest = parts.slice(index + 1).join("/");
             var linkPath = pathJoin(partial, link, rest);
             return resolvePath(linkPath, bake, callback);
          }

          // We're good, move on!
          mode = entry.mode;
          hash = entry.hash;
          partial = newPath;
          if (mode === modes.commit) root = partial;
          index++;
        } else {
          break;
        }
      }
github creationix / tedit / src / data / document.js View on Github external
function setDoc(row, body) {
  if (!row) return editor.setDoc();
  var doc = row.doc || (row.doc = { save: save });
  doc.row = row;

  var ext = row.path.match(/[^.]*$/)[0].toLowerCase();
  var imageType = imageTypes[ext];
  if (imageType) {
    if (doc.session) delete doc.session;
    if (doc.hash !== row.hash) {
      var blob = new Blob([body], { type: imageType });
      doc.url = window.URL.createObjectURL(blob);
    }
  }
  else {
    var code = binary.toUnicode(body);
    if (doc.url) delete doc.url;
    if (!doc.session) {
      doc.session = ace.createEditSession(code);
      doc.code = code;
      doc.session.setTabSize(2);
      whitespace.detectIndentation(doc.session);
      doc.mode = 0;
    }
    else if (doc.code !== code) {
      doc.session.setValue(code, 1);
      doc.code = code;
      whitespace.detectIndentation(doc.session);
    }
    if (doc.mode !== row.mode) {
      var aceMode =
        /\.rule/.test(row.path) ? "ace/mode/jack" :
github creationix / tedit / src / data / publisher.js View on Github external
function onCode(err, blob) {
      if (err) return callback(err);
      var code;
      try { code = binary.toUnicode(blob); }
      catch (err) { return callback(err); }
      console.log("Compiling filter " + req.program);
      var module = loadModule(code);
      if (typeof module !== "function") {
        return callback(new Error(req.program + " exports was not a function"));
      }
      filters[req.program] = module;
      codeHashes[req.program] = codeHash;
      filters[req.program](servePath, req, callback);
    }
  }
github creationix / tedit / src / git-tree.js View on Github external
repo.loadAs("blob", entry.hash, function (err, blob) {
        if (err) return callback(err);
        try { entry.link = binary.toUnicode(blob); }
        catch (err) { return callback(err); }
        callback(null, entry);
      });
    });
github creationix / tedit / src / git-tree.js View on Github external
repo.loadAs("blob", hash, function (err, blob) {
        if (blob === undefined) return callback(err || new Error("Missing blob " + hash));
        if (hash === modules.hash) return callback();
        try {
          var text = binary.toUnicode(blob);
          var meta = codec.decode(text);
          modules.meta = meta;
          modules.hash = hash;
        }
        catch (err) { return callback(err); }
        callback();
      });
    },
github creationix / tedit / src / git-tree.js View on Github external
return storage.loadAs(rule.root, "blob", rule.hash, function (err, blob) {
        if (err) return callback(err);
        if (blob === undefined) return callback(new Error("Missing blob " + rule.hash));
        var data;
        try {
          var jon = binary.toUnicode(blob);
          data = jonParse(jon);
        }
        catch (err) {
          err.message += "\nin " + rule.path + ".rule";
          err.path = rule.path + ".rule";
          return callback(err);
        }
        data.paths = {
          full: path,
          local: rule.path ? path.substring(rule.path.length + 1) : path,
          rule: rule.path,
          root: root
        };
        bake(data, callback);
      });
    }