MCPcopy Index your code
hub / github.com/nodejs/node / request

Method request

lib/internal/locks.js:167–308  ·  view source on GitHub ↗
(name, options, callback = undefined)

Source from the content-addressed store, hash-verified

165 */
166 // https://w3c.github.io/web-locks/#api-lock-manager-request
167 async request(name, options, callback = undefined) {
168 if (callback === undefined) {
169 callback = options;
170 options = undefined;
171 }
172
173 name = converters.DOMString(name);
174 validateFunction(callback, 'callback');
175
176 if (options === undefined || typeof options === 'function') {
177 options = kEmptyObject;
178 }
179
180 // Convert LockOptions dictionary
181 options = convertLockOptions(options);
182
183 const { mode, ifAvailable, steal, signal } = options;
184
185 validateAbortSignal(signal, 'options.signal');
186
187 if (signal) {
188 signal.throwIfAborted();
189 }
190
191 if (name[0] === '-') {
192 // If name starts with U+002D HYPHEN-MINUS (-), then reject promise with a
193 // "NotSupportedError" DOMException.
194 throw lazyDOMException('Lock name may not start with hyphen',
195 'NotSupportedError');
196 }
197
198 if (ifAvailable === true && steal === true) {
199 // If both options' steal dictionary member and option's
200 // ifAvailable dictionary member are true, then reject promise with a
201 // "NotSupportedError" DOMException.
202 throw lazyDOMException('ifAvailable and steal are mutually exclusive',
203 'NotSupportedError');
204 }
205
206 if (mode !== locks.LOCK_MODE_EXCLUSIVE && steal === true) {
207 // If options' steal dictionary member is true and options' mode
208 // dictionary member is not "exclusive", then return a promise rejected
209 // with a "NotSupportedError" DOMException.
210 throw lazyDOMException(`mode: "${locks.LOCK_MODE_SHARED}" and steal are mutually exclusive`,
211 'NotSupportedError');
212 }
213
214 if (signal && (steal === true || ifAvailable === true)) {
215 // If options' signal dictionary member is present, and either of
216 // options' steal dictionary member or options' ifAvailable dictionary
217 // member is true, then return a promise rejected with a
218 // "NotSupportedError" DOMException.
219 throw lazyDOMException('signal cannot be used with steal or ifAvailable',
220 'NotSupportedError');
221 }
222
223 const clientId = `node-${process.pid}-${threadId}`;
224 publishLockRequestStart(name, mode);

Callers

nothing calls this directly

Calls 12

validateAbortSignalFunction · 0.85
lazyDOMExceptionFunction · 0.85
publishLockRequestStartFunction · 0.85
publishLockRequestEndFunction · 0.85
convertLockErrorFunction · 0.85
DOMStringMethod · 0.80
throwIfAbortedMethod · 0.80
addEventListenerMethod · 0.65
requestMethod · 0.65
removeEventListenerMethod · 0.65
resolveFunction · 0.50
rejectFunction · 0.50

Tested by

no test coverage detected