MCPcopy Create free account
hub / github.com/nodejs/node / add

Method add

deps/undici/undici.js:15772–15806  ·  view source on GitHub ↗
(item, cb, hint)

Source from the content-addressed store, hash-verified

15770 this.#socket = socket;
15771 }
15772 add(item, cb, hint) {
15773 if (hint !== sendHints.blob) {
15774 if (!this.#running) {
15775 if (hint === sendHints.text) {
15776 const { 0: head, 1: body } = WebsocketFrameSend.createFastTextFrame(item);
15777 this.#socket.cork();
15778 this.#socket.write(head);
15779 this.#socket.write(body, cb);
15780 this.#socket.uncork();
15781 } else {
15782 this.#socket.write(createFrame(item, hint), cb);
15783 }
15784 } else {
15785 const node2 = {
15786 promise: null,
15787 callback: cb,
15788 frame: createFrame(item, hint)
15789 };
15790 this.#queue.push(node2);
15791 }
15792 return;
15793 }
15794 const node = {
15795 promise: item.arrayBuffer().then((ab) => {
15796 node.promise = null;
15797 node.frame = createFrame(ab, hint);
15798 }),
15799 callback: cb,
15800 frame: null
15801 };
15802 this.#queue.push(node);
15803 if (!this.#running) {
15804 this.#run();
15805 }
15806 }
15807 async #run() {
15808 this.#running = true;
15809 const queue = this.#queue;

Callers

nothing calls this directly

Calls 9

corkMethod · 0.80
uncorkMethod · 0.80
createFrameFunction · 0.70
arrayBufferMethod · 0.65
createFastTextFrameMethod · 0.45
writeMethod · 0.45
pushMethod · 0.45
thenMethod · 0.45
#runMethod · 0.45

Tested by

no test coverage detected