MCPcopy Create free account
hub / github.com/di-sukharev/opencommit / calculateContentLength

Method calculateContentLength

out/cli.cjs:69646–69658  ·  view source on GitHub ↗
(body)

Source from the content-addressed store, hash-verified

69644 return this.methodRequest("delete", path5, opts);
69645 }
69646 methodRequest(method, path5, opts) {
69647 return this.request(Promise.resolve(opts).then((opts2) => ({ method, path: path5, ...opts2 })));
69648 }
69649 getAPIList(path5, Page2, opts) {
69650 return this.requestAPIList(Page2, { method: "get", path: path5, ...opts });
69651 }
69652 calculateContentLength(body) {
69653 if (typeof body === "string") {
69654 if (typeof Buffer !== "undefined") {
69655 return Buffer.byteLength(body, "utf8").toString();
69656 }
69657 if (typeof TextEncoder !== "undefined") {
69658 const encoder = new TextEncoder();
69659 const encoded = encoder.encode(body);
69660 return encoded.length.toString();
69661 }

Callers 1

buildRequestMethod · 0.80

Calls 2

encodeMethod · 0.80
toStringMethod · 0.45

Tested by

no test coverage detected