MCPcopy
hub / github.com/axios/axios / convertValue

Function convertValue

lib/helpers/toFormData.js:130–156  ·  view source on GitHub ↗
(value)

Source from the content-addressed store, hash-verified

128 }
129
130 function convertValue(value) {
131 if (value === null) return '';
132
133 if (utils.isDate(value)) {
134 return value.toISOString();
135 }
136
137 if (utils.isBoolean(value)) {
138 return value.toString();
139 }
140
141 if (!useBlob && utils.isBlob(value)) {
142 throw new AxiosError('Blob is not supported. Use a Buffer instead.');
143 }
144
145 if (utils.isArrayBuffer(value) || utils.isTypedArray(value)) {
146 if (useBlob && typeof _Blob === 'function') {
147 return new _Blob([value]);
148 }
149 if (typeof Buffer !== 'undefined') {
150 return Buffer.from(value);
151 }
152 throw new AxiosError('Blob is not supported. Use a Buffer instead.', AxiosError.ERR_NOT_SUPPORT);
153 }
154
155 return value;
156 }
157
158 function throwIfMaxDepthExceeded(depth) {
159 if (depth > maxDepth) {

Callers 1

defaultVisitorFunction · 0.85

Calls 2

toStringMethod · 0.80
fromMethod · 0.45

Tested by

no test coverage detected