MCPcopy
hub / github.com/rollup/rollup / replaceStringifyValues

Function replaceStringifyValues

test/testHelpers.js:498–534  ·  view source on GitHub ↗
(key, value)

Source from the content-addressed store, hash-verified

496};
497
498const replaceStringifyValues = (key, value) => {
499 switch (value?.type) {
500 case 'ImportDeclaration':
501 case 'ExportNamedDeclaration':
502 case 'ExportAllDeclaration': {
503 const { attributes, ...nonAttributesProperties } = value;
504 return {
505 ...nonAttributesProperties,
506 ...(attributes?.length > 0 ? { assertions: attributes } : {})
507 };
508 }
509 case 'ImportExpression': {
510 const { options, ...nonOptionsProperties } = value;
511 return { ...nonOptionsProperties, ...(options ? { arguments: [options] } : {}) };
512 }
513 case 'ClassDeclaration':
514 case 'ClassExpression':
515 case 'PropertyDefinition':
516 case 'MethodDefinition': {
517 const { decorators, ...rest } = value;
518 return rest;
519 }
520 case 'JSXText': {
521 // raw text is encoded differently in acorn
522 const { raw, ...nonRawProperties } = value;
523 return nonRawProperties;
524 }
525 }
526
527 return key[0] === '_'
528 ? undefined
529 : typeof value == 'bigint'
530 ? `~BigInt${value.toString()}`
531 : value instanceof RegExp
532 ? `~RegExp${JSON.stringify({ flags: value.flags, source: value.source })}`
533 : value;
534};
535
536const reviveStringifyValues = (_, value) =>
537 typeof value === 'string'

Callers

nothing calls this directly

Calls 1

toStringMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…