MCPcopy
hub / github.com/webpack/webpack / getSerializerFor

Method getSerializerFor

lib/serialization/ObjectMiddleware.js:317–342  ·  view source on GitHub ↗

* Gets serializer for. * @param {EXPECTED_ANY} object for serialization * @returns {SerializerConfigWithSerializer} Serializer config

(object)

Source from the content-addressed store, hash-verified

315 * @returns {SerializerConfigWithSerializer} Serializer config
316 */
317 static getSerializerFor(object) {
318 const proto = Object.getPrototypeOf(object);
319 /** @type {null | Constructor} */
320 let c;
321 if (proto === null) {
322 // Object created with Object.create(null)
323 c = null;
324 } else {
325 c = proto.constructor;
326 if (!c) {
327 throw new Error(
328 "Serialization of objects with prototype without valid constructor property not possible"
329 );
330 }
331 }
332 const config = serializers.get(c);
333
334 if (!config) {
335 throw new Error(
336 `No serializer registered for ${/** @type {Constructor} */ (c).name}`
337 );
338 }
339 if (config === NOT_SERIALIZABLE) throw NOT_SERIALIZABLE;
340
341 return /** @type {SerializerConfigWithSerializer} */ (config);
342 }
343
344 /**
345 * Gets deserializer for.

Callers 2

stackToStringMethod · 0.80
processMethod · 0.80

Calls 1

getMethod · 0.45

Tested by

no test coverage detected