MCPcopy
hub / github.com/nock/nock / convertBodyToStream

Function convertBodyToStream

lib/playback_interceptor.js:78–96  ·  view source on GitHub ↗
(body)

Source from the content-addressed store, hash-verified

76}
77
78function convertBodyToStream(body) {
79 if (common.isStream(body)) {
80 return body
81 }
82
83 if (body === undefined) {
84 return new ReadableBuffers([])
85 }
86
87 if (Buffer.isBuffer(body)) {
88 return new ReadableBuffers([body])
89 }
90
91 if (typeof body !== 'string') {
92 body = JSON.stringify(body)
93 }
94
95 return new ReadableBuffers([Buffer.from(body)])
96}
97
98/**
99 * Play back an interceptor using the given request and mock response.

Callers 1

continueWithResponseBodyFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…