MCPcopy Create free account
hub / github.com/json5/json5 / escape

Function escape

lib/parse.js:729–802  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

727}
728
729function escape () {
730 const c = peek()
731 switch (c) {
732 case 'b':
733 read()
734 return '\b'
735
736 case 'f':
737 read()
738 return '\f'
739
740 case 'n':
741 read()
742 return '\n'
743
744 case 'r':
745 read()
746 return '\r'
747
748 case 't':
749 read()
750 return '\t'
751
752 case 'v':
753 read()
754 return '\v'
755
756 case '0':
757 read()
758 if (util.isDigit(peek())) {
759 throw invalidChar(read())
760 }
761
762 return '\0'
763
764 case 'x':
765 read()
766 return hexEscape()
767
768 case 'u':
769 read()
770 return unicodeEscape()
771
772 case '\n':
773 case '\u2028':
774 case '\u2029':
775 read()
776 return ''
777
778 case '\r':
779 read()
780 if (peek() === '\n') {
781 read()
782 }
783
784 return ''
785
786 case '1':

Callers 1

stringFunction · 0.85

Calls 5

peekFunction · 0.85
readFunction · 0.85
invalidCharFunction · 0.85
hexEscapeFunction · 0.85
unicodeEscapeFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…