graphql 14.0.2 → 14.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (361) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +5 -5
  3. package/codecov.yml +14 -0
  4. package/error/GraphQLError.js +2 -2
  5. package/error/GraphQLError.js.flow +4 -4
  6. package/error/GraphQLError.mjs +2 -2
  7. package/error/formatError.js +2 -2
  8. package/error/formatError.js.flow +1 -1
  9. package/error/formatError.mjs +2 -2
  10. package/error/index.js.flow +1 -1
  11. package/error/index.mjs +2 -2
  12. package/error/locatedError.js +2 -2
  13. package/error/locatedError.js.flow +1 -1
  14. package/error/locatedError.mjs +2 -2
  15. package/error/printError.js +2 -2
  16. package/error/printError.js.flow +1 -1
  17. package/error/printError.mjs +2 -2
  18. package/error/syntaxError.js +2 -2
  19. package/error/syntaxError.js.flow +1 -1
  20. package/error/syntaxError.mjs +2 -2
  21. package/execution/execute.js +20 -11
  22. package/execution/execute.js.flow +41 -27
  23. package/execution/execute.mjs +19 -13
  24. package/execution/index.js +6 -0
  25. package/execution/index.js.flow +7 -2
  26. package/execution/index.mjs +3 -3
  27. package/execution/values.js +10 -10
  28. package/execution/values.js.flow +8 -8
  29. package/execution/values.mjs +9 -9
  30. package/graphql.js +8 -8
  31. package/graphql.js.flow +18 -4
  32. package/graphql.mjs +8 -8
  33. package/index.js +18 -0
  34. package/index.js.flow +4 -1
  35. package/index.mjs +4 -4
  36. package/jsutils/ObjMap.js.flow +1 -1
  37. package/jsutils/{MaybePromise.js → PromiseOrValue.js} +0 -0
  38. package/jsutils/{MaybePromise.js.flow → PromiseOrValue.js.flow} +2 -2
  39. package/jsutils/{MaybePromise.mjs → PromiseOrValue.mjs} +0 -0
  40. package/jsutils/dedent.js +2 -2
  41. package/jsutils/dedent.js.flow +1 -1
  42. package/jsutils/dedent.mjs +2 -2
  43. package/jsutils/defineToJSON.js +18 -7
  44. package/jsutils/defineToJSON.js.flow +15 -6
  45. package/jsutils/defineToJSON.mjs +15 -7
  46. package/jsutils/defineToStringTag.js +6 -6
  47. package/jsutils/defineToStringTag.js.flow +4 -4
  48. package/jsutils/defineToStringTag.mjs +5 -5
  49. package/jsutils/inspect.js +109 -23
  50. package/jsutils/inspect.js.flow +112 -14
  51. package/jsutils/inspect.mjs +108 -17
  52. package/jsutils/instanceOf.js +2 -2
  53. package/jsutils/instanceOf.js.flow +1 -1
  54. package/jsutils/instanceOf.mjs +2 -2
  55. package/jsutils/invariant.js +2 -2
  56. package/jsutils/invariant.js.flow +1 -1
  57. package/jsutils/invariant.mjs +2 -2
  58. package/jsutils/isInvalid.js +2 -2
  59. package/jsutils/isInvalid.js.flow +1 -1
  60. package/jsutils/isInvalid.mjs +2 -2
  61. package/jsutils/isNullish.js +2 -2
  62. package/jsutils/isNullish.js.flow +1 -1
  63. package/jsutils/isNullish.mjs +2 -2
  64. package/jsutils/isPromise.js +2 -2
  65. package/jsutils/isPromise.js.flow +1 -1
  66. package/jsutils/isPromise.mjs +2 -2
  67. package/jsutils/keyMap.js +2 -2
  68. package/jsutils/keyMap.js.flow +1 -1
  69. package/jsutils/keyMap.mjs +2 -2
  70. package/jsutils/keyValMap.js +2 -2
  71. package/jsutils/keyValMap.js.flow +1 -1
  72. package/jsutils/keyValMap.mjs +2 -2
  73. package/jsutils/mapValue.js +54 -0
  74. package/jsutils/mapValue.js.flow +27 -0
  75. package/jsutils/mapValue.mjs +44 -0
  76. package/jsutils/memoize3.js +2 -2
  77. package/jsutils/memoize3.js.flow +1 -1
  78. package/jsutils/memoize3.mjs +2 -2
  79. package/jsutils/nodejsCustomInspectSymbol.js +18 -0
  80. package/jsutils/nodejsCustomInspectSymbol.js.flow +15 -0
  81. package/jsutils/nodejsCustomInspectSymbol.mjs +10 -0
  82. package/jsutils/orList.js +18 -5
  83. package/jsutils/orList.js.flow +14 -8
  84. package/jsutils/orList.mjs +15 -5
  85. package/jsutils/promiseForObject.js +2 -2
  86. package/jsutils/promiseForObject.js.flow +1 -1
  87. package/jsutils/promiseForObject.mjs +2 -2
  88. package/jsutils/promiseReduce.js +2 -2
  89. package/jsutils/promiseReduce.js.flow +5 -5
  90. package/jsutils/promiseReduce.mjs +2 -2
  91. package/jsutils/quotedOrList.js +2 -2
  92. package/jsutils/quotedOrList.js.flow +1 -1
  93. package/jsutils/quotedOrList.mjs +2 -2
  94. package/jsutils/suggestionList.js +2 -2
  95. package/jsutils/suggestionList.js.flow +1 -1
  96. package/jsutils/suggestionList.mjs +2 -2
  97. package/language/ast.js.flow +1 -1
  98. package/language/{blockStringValue.mjs → blockString.js} +39 -3
  99. package/language/{blockStringValue.js.flow → blockString.js.flow} +31 -2
  100. package/language/{blockStringValue.js → blockString.mjs} +31 -10
  101. package/language/directiveLocation.js +2 -2
  102. package/language/directiveLocation.js.flow +1 -1
  103. package/language/directiveLocation.mjs +2 -2
  104. package/language/index.js.flow +1 -1
  105. package/language/index.mjs +2 -2
  106. package/language/kinds.js +2 -2
  107. package/language/kinds.js.flow +1 -1
  108. package/language/kinds.mjs +2 -2
  109. package/language/lexer.js +60 -46
  110. package/language/lexer.js.flow +71 -69
  111. package/language/lexer.mjs +58 -45
  112. package/language/location.js +2 -2
  113. package/language/location.js.flow +1 -1
  114. package/language/location.mjs +2 -2
  115. package/language/parser.js +84 -83
  116. package/language/parser.js.flow +85 -94
  117. package/language/parser.mjs +83 -83
  118. package/language/predicates.js +2 -2
  119. package/language/predicates.js.flow +1 -1
  120. package/language/predicates.mjs +2 -2
  121. package/language/printer.js +15 -17
  122. package/language/printer.js.flow +21 -20
  123. package/language/printer.mjs +14 -17
  124. package/language/source.js +8 -7
  125. package/language/source.js.flow +1 -1
  126. package/language/source.mjs +2 -10
  127. package/language/visitor.js +7 -6
  128. package/language/visitor.js.flow +3 -5
  129. package/language/visitor.mjs +7 -6
  130. package/package.json +5 -2
  131. package/polyfills/find.js +31 -0
  132. package/polyfills/find.js.flow +29 -0
  133. package/polyfills/find.mjs +23 -0
  134. package/polyfills/flatMap.js +38 -0
  135. package/polyfills/flatMap.js.flow +34 -0
  136. package/polyfills/flatMap.mjs +30 -0
  137. package/{jsutils → polyfills}/isFinite.js +2 -2
  138. package/{jsutils → polyfills}/isFinite.js.flow +1 -1
  139. package/{jsutils → polyfills}/isFinite.mjs +2 -2
  140. package/{jsutils → polyfills}/isInteger.js +2 -2
  141. package/{jsutils → polyfills}/isInteger.js.flow +1 -1
  142. package/{jsutils → polyfills}/isInteger.mjs +2 -2
  143. package/polyfills/objectEntries.js +26 -0
  144. package/polyfills/objectEntries.js.flow +19 -0
  145. package/polyfills/objectEntries.mjs +18 -0
  146. package/{jsutils → polyfills}/objectValues.js +2 -2
  147. package/{jsutils → polyfills}/objectValues.js.flow +2 -2
  148. package/{jsutils → polyfills}/objectValues.mjs +2 -2
  149. package/subscription/asyncIteratorReject.js.flow +1 -1
  150. package/subscription/asyncIteratorReject.mjs +2 -2
  151. package/subscription/index.js.flow +1 -1
  152. package/subscription/index.mjs +2 -2
  153. package/subscription/mapAsyncIterator.js.flow +5 -5
  154. package/subscription/mapAsyncIterator.mjs +2 -2
  155. package/subscription/subscribe.js +2 -2
  156. package/subscription/subscribe.js.flow +1 -1
  157. package/subscription/subscribe.mjs +2 -2
  158. package/type/definition.js +161 -138
  159. package/type/definition.js.flow +193 -57
  160. package/type/definition.mjs +158 -140
  161. package/type/directives.js +35 -29
  162. package/type/directives.js.flow +39 -21
  163. package/type/directives.mjs +34 -31
  164. package/type/index.js +12 -0
  165. package/type/index.js.flow +5 -1
  166. package/type/index.mjs +6 -4
  167. package/type/introspection.js +11 -7
  168. package/type/introspection.js.flow +11 -8
  169. package/type/introspection.mjs +11 -7
  170. package/type/scalars.js +45 -34
  171. package/type/scalars.js.flow +41 -27
  172. package/type/scalars.mjs +45 -27
  173. package/type/schema.js +134 -88
  174. package/type/schema.js.flow +77 -11
  175. package/type/schema.mjs +132 -88
  176. package/type/validate.js +152 -187
  177. package/type/validate.js.flow +12 -61
  178. package/type/validate.mjs +143 -188
  179. package/utilities/TypeInfo.js +10 -23
  180. package/utilities/TypeInfo.js.flow +2 -2
  181. package/utilities/TypeInfo.mjs +3 -25
  182. package/utilities/assertValidName.js +2 -2
  183. package/utilities/assertValidName.js.flow +1 -1
  184. package/utilities/assertValidName.mjs +2 -2
  185. package/utilities/astFromValue.js +7 -6
  186. package/utilities/astFromValue.js.flow +7 -6
  187. package/utilities/astFromValue.mjs +9 -8
  188. package/utilities/buildASTSchema.js +213 -197
  189. package/utilities/buildASTSchema.js.flow +163 -173
  190. package/utilities/buildASTSchema.mjs +203 -198
  191. package/utilities/buildClientSchema.js +39 -47
  192. package/utilities/buildClientSchema.js.flow +49 -58
  193. package/utilities/buildClientSchema.mjs +38 -46
  194. package/utilities/coerceValue.js +41 -21
  195. package/utilities/coerceValue.js.flow +44 -49
  196. package/utilities/coerceValue.mjs +42 -23
  197. package/utilities/concatAST.js +9 -13
  198. package/utilities/concatAST.js.flow +3 -9
  199. package/utilities/concatAST.mjs +6 -13
  200. package/utilities/extendSchema.js +256 -630
  201. package/utilities/extendSchema.js.flow +190 -426
  202. package/utilities/extendSchema.mjs +256 -631
  203. package/utilities/findBreakingChanges.js +8 -6
  204. package/utilities/findBreakingChanges.js.flow +4 -3
  205. package/utilities/findBreakingChanges.mjs +7 -6
  206. package/utilities/findDeprecatedUsages.js +4 -4
  207. package/utilities/findDeprecatedUsages.js.flow +3 -3
  208. package/utilities/findDeprecatedUsages.mjs +4 -4
  209. package/utilities/getOperationAST.js +2 -2
  210. package/utilities/getOperationAST.js.flow +1 -1
  211. package/utilities/getOperationAST.mjs +2 -2
  212. package/utilities/getOperationRootType.js +6 -6
  213. package/utilities/getOperationRootType.js.flow +9 -7
  214. package/utilities/getOperationRootType.mjs +6 -6
  215. package/utilities/index.js.flow +1 -1
  216. package/utilities/index.mjs +2 -2
  217. package/utilities/introspectionFromSchema.js +2 -2
  218. package/utilities/introspectionFromSchema.js.flow +1 -1
  219. package/utilities/introspectionFromSchema.mjs +2 -2
  220. package/utilities/introspectionQuery.js +2 -2
  221. package/utilities/introspectionQuery.js.flow +1 -1
  222. package/utilities/introspectionQuery.mjs +2 -2
  223. package/utilities/isValidJSValue.js +4 -2
  224. package/utilities/isValidJSValue.js.flow +2 -1
  225. package/utilities/isValidJSValue.mjs +4 -2
  226. package/utilities/isValidLiteralValue.js +2 -2
  227. package/utilities/isValidLiteralValue.js.flow +1 -1
  228. package/utilities/isValidLiteralValue.mjs +2 -2
  229. package/utilities/lexicographicSortSchema.js +86 -124
  230. package/utilities/lexicographicSortSchema.js.flow +68 -96
  231. package/utilities/lexicographicSortSchema.mjs +86 -124
  232. package/utilities/schemaPrinter.js +47 -73
  233. package/utilities/schemaPrinter.js.flow +62 -111
  234. package/utilities/schemaPrinter.mjs +46 -73
  235. package/utilities/separateOperations.js +11 -10
  236. package/utilities/separateOperations.js.flow +1 -1
  237. package/utilities/separateOperations.mjs +11 -10
  238. package/utilities/typeComparators.js +2 -2
  239. package/utilities/typeComparators.js.flow +1 -1
  240. package/utilities/typeComparators.mjs +2 -2
  241. package/utilities/typeFromAST.js +9 -4
  242. package/utilities/typeFromAST.js.flow +5 -2
  243. package/utilities/typeFromAST.mjs +6 -4
  244. package/utilities/valueFromAST.js +9 -6
  245. package/utilities/valueFromAST.js.flow +5 -3
  246. package/utilities/valueFromAST.mjs +7 -5
  247. package/utilities/valueFromASTUntyped.js +7 -4
  248. package/utilities/valueFromASTUntyped.js.flow +5 -2
  249. package/utilities/valueFromASTUntyped.mjs +6 -4
  250. package/validation/ValidationContext.js +57 -82
  251. package/validation/ValidationContext.js.flow +53 -50
  252. package/validation/ValidationContext.mjs +53 -78
  253. package/validation/index.js.flow +1 -1
  254. package/validation/index.mjs +2 -2
  255. package/validation/rules/ExecutableDefinitions.js +3 -3
  256. package/validation/rules/ExecutableDefinitions.js.flow +3 -3
  257. package/validation/rules/ExecutableDefinitions.mjs +3 -3
  258. package/validation/rules/FieldsOnCorrectType.js +3 -3
  259. package/validation/rules/FieldsOnCorrectType.js.flow +2 -2
  260. package/validation/rules/FieldsOnCorrectType.mjs +3 -3
  261. package/validation/rules/FragmentsOnCompositeTypes.js +4 -4
  262. package/validation/rules/FragmentsOnCompositeTypes.js.flow +3 -3
  263. package/validation/rules/FragmentsOnCompositeTypes.mjs +4 -4
  264. package/validation/rules/KnownArgumentNames.js.flow +1 -1
  265. package/validation/rules/KnownArgumentNames.mjs +2 -2
  266. package/validation/rules/KnownDirectives.js +4 -4
  267. package/validation/rules/KnownDirectives.js.flow +5 -4
  268. package/validation/rules/KnownDirectives.mjs +4 -4
  269. package/validation/rules/KnownFragmentNames.js +3 -3
  270. package/validation/rules/KnownFragmentNames.js.flow +2 -2
  271. package/validation/rules/KnownFragmentNames.mjs +3 -3
  272. package/validation/rules/KnownTypeNames.js +60 -22
  273. package/validation/rules/KnownTypeNames.js.flow +55 -21
  274. package/validation/rules/KnownTypeNames.mjs +57 -22
  275. package/validation/rules/LoneAnonymousOperation.js +3 -3
  276. package/validation/rules/LoneAnonymousOperation.js.flow +2 -2
  277. package/validation/rules/LoneAnonymousOperation.mjs +3 -3
  278. package/validation/rules/LoneSchemaDefinition.js +2 -2
  279. package/validation/rules/LoneSchemaDefinition.js.flow +1 -1
  280. package/validation/rules/LoneSchemaDefinition.mjs +2 -2
  281. package/validation/rules/NoFragmentCycles.js +2 -2
  282. package/validation/rules/NoFragmentCycles.js.flow +3 -3
  283. package/validation/rules/NoFragmentCycles.mjs +2 -2
  284. package/validation/rules/NoUndefinedVariables.js +2 -2
  285. package/validation/rules/NoUndefinedVariables.js.flow +1 -1
  286. package/validation/rules/NoUndefinedVariables.mjs +2 -2
  287. package/validation/rules/NoUnusedFragments.js +10 -7
  288. package/validation/rules/NoUnusedFragments.js.flow +4 -4
  289. package/validation/rules/NoUnusedFragments.mjs +10 -7
  290. package/validation/rules/NoUnusedVariables.js +7 -5
  291. package/validation/rules/NoUnusedVariables.js.flow +4 -3
  292. package/validation/rules/NoUnusedVariables.mjs +7 -5
  293. package/validation/rules/OverlappingFieldsCanBeMerged.js +58 -33
  294. package/validation/rules/OverlappingFieldsCanBeMerged.js.flow +4 -4
  295. package/validation/rules/OverlappingFieldsCanBeMerged.mjs +50 -34
  296. package/validation/rules/PossibleFragmentSpreads.js +4 -4
  297. package/validation/rules/PossibleFragmentSpreads.js.flow +3 -3
  298. package/validation/rules/PossibleFragmentSpreads.mjs +4 -4
  299. package/validation/rules/PossibleTypeExtensions.js +158 -0
  300. package/validation/rules/PossibleTypeExtensions.js.flow +160 -0
  301. package/validation/rules/PossibleTypeExtensions.mjs +146 -0
  302. package/validation/rules/ProvidedRequiredArguments.js +3 -3
  303. package/validation/rules/ProvidedRequiredArguments.js.flow +4 -4
  304. package/validation/rules/ProvidedRequiredArguments.mjs +5 -5
  305. package/validation/rules/ScalarLeafs.js +4 -4
  306. package/validation/rules/ScalarLeafs.js.flow +3 -3
  307. package/validation/rules/ScalarLeafs.mjs +4 -4
  308. package/validation/rules/SingleFieldSubscriptions.js +2 -2
  309. package/validation/rules/SingleFieldSubscriptions.js.flow +1 -1
  310. package/validation/rules/SingleFieldSubscriptions.mjs +2 -2
  311. package/validation/rules/UniqueArgumentNames.js +2 -2
  312. package/validation/rules/UniqueArgumentNames.js.flow +1 -1
  313. package/validation/rules/UniqueArgumentNames.mjs +2 -2
  314. package/validation/rules/UniqueDirectiveNames.js +55 -0
  315. package/validation/rules/UniqueDirectiveNames.js.flow +64 -0
  316. package/validation/rules/UniqueDirectiveNames.mjs +43 -0
  317. package/validation/rules/UniqueDirectivesPerLocation.js +2 -2
  318. package/validation/rules/UniqueDirectivesPerLocation.js.flow +1 -1
  319. package/validation/rules/UniqueDirectivesPerLocation.mjs +2 -2
  320. package/validation/rules/UniqueEnumValueNames.js +90 -0
  321. package/validation/rules/UniqueEnumValueNames.js.flow +85 -0
  322. package/validation/rules/UniqueEnumValueNames.mjs +77 -0
  323. package/validation/rules/UniqueFieldDefinitionNames.js +101 -0
  324. package/validation/rules/UniqueFieldDefinitionNames.js.flow +99 -0
  325. package/validation/rules/UniqueFieldDefinitionNames.mjs +88 -0
  326. package/validation/rules/UniqueFragmentNames.js +2 -2
  327. package/validation/rules/UniqueFragmentNames.js.flow +1 -1
  328. package/validation/rules/UniqueFragmentNames.mjs +2 -2
  329. package/validation/rules/UniqueInputFieldNames.js +2 -4
  330. package/validation/rules/UniqueInputFieldNames.js.flow +1 -2
  331. package/validation/rules/UniqueInputFieldNames.mjs +2 -4
  332. package/validation/rules/UniqueOperationNames.js +2 -2
  333. package/validation/rules/UniqueOperationNames.js.flow +1 -1
  334. package/validation/rules/UniqueOperationNames.mjs +2 -2
  335. package/validation/rules/UniqueOperationTypes.js +85 -0
  336. package/validation/rules/UniqueOperationTypes.js.flow +76 -0
  337. package/validation/rules/UniqueOperationTypes.mjs +73 -0
  338. package/validation/rules/UniqueTypeNames.js +62 -0
  339. package/validation/rules/UniqueTypeNames.js.flow +67 -0
  340. package/validation/rules/UniqueTypeNames.mjs +50 -0
  341. package/validation/rules/UniqueVariableNames.js +2 -2
  342. package/validation/rules/UniqueVariableNames.js.flow +1 -1
  343. package/validation/rules/UniqueVariableNames.mjs +2 -2
  344. package/validation/rules/ValuesOfCorrectType.js +30 -14
  345. package/validation/rules/ValuesOfCorrectType.js.flow +5 -6
  346. package/validation/rules/ValuesOfCorrectType.mjs +29 -14
  347. package/validation/rules/VariablesAreInputTypes.js +3 -3
  348. package/validation/rules/VariablesAreInputTypes.js.flow +2 -2
  349. package/validation/rules/VariablesAreInputTypes.mjs +3 -3
  350. package/validation/rules/VariablesInAllowedPosition.js +5 -5
  351. package/validation/rules/VariablesInAllowedPosition.js.flow +1 -1
  352. package/validation/rules/VariablesInAllowedPosition.mjs +5 -5
  353. package/validation/specifiedRules.js +15 -3
  354. package/validation/specifiedRules.js.flow +14 -1
  355. package/validation/specifiedRules.mjs +9 -3
  356. package/validation/validate.js +2 -2
  357. package/validation/validate.js.flow +1 -1
  358. package/validation/validate.mjs +2 -2
  359. package/jsutils/find.js +0 -22
  360. package/jsutils/find.js.flow +0 -19
  361. package/jsutils/find.mjs +0 -15
package/language/lexer.js CHANGED
@@ -7,19 +7,21 @@ exports.createLexer = createLexer;
7
7
  exports.getTokenDesc = getTokenDesc;
8
8
  exports.TokenKind = void 0;
9
9
 
10
+ var _defineToJSON = _interopRequireDefault(require("../jsutils/defineToJSON"));
11
+
10
12
  var _error = require("../error");
11
13
 
12
- var _blockStringValue = _interopRequireDefault(require("./blockStringValue"));
14
+ var _blockString = require("./blockString");
13
15
 
14
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
17
 
16
18
  /**
17
- * Copyright (c) 2015-present, Facebook, Inc.
19
+ * Copyright (c) Facebook, Inc. and its affiliates.
18
20
  *
19
21
  * This source code is licensed under the MIT license found in the
20
22
  * LICENSE file in the root directory of this source tree.
21
23
  *
22
- * strict
24
+ *
23
25
  */
24
26
 
25
27
  /**
@@ -109,13 +111,11 @@ function getTokenDesc(token) {
109
111
  var value = token.value;
110
112
  return value ? "".concat(token.kind, " \"").concat(value, "\"") : token.kind;
111
113
  }
112
-
113
- var charCodeAt = String.prototype.charCodeAt;
114
- var slice = String.prototype.slice;
115
114
  /**
116
115
  * Helper function for constructing the Token object.
117
116
  */
118
117
 
118
+
119
119
  function Tok(kind, start, end, line, column, prev, value) {
120
120
  this.kind = kind;
121
121
  this.start = start;
@@ -128,14 +128,14 @@ function Tok(kind, start, end, line, column, prev, value) {
128
128
  } // Print a simplified form when appearing in JSON/util.inspect.
129
129
 
130
130
 
131
- Tok.prototype.toJSON = Tok.prototype.inspect = function toJSON() {
131
+ (0, _defineToJSON.default)(Tok, function () {
132
132
  return {
133
133
  kind: this.kind,
134
134
  value: this.value,
135
135
  line: this.line,
136
136
  column: this.column
137
137
  };
138
- };
138
+ });
139
139
 
140
140
  function printCharCode(code) {
141
141
  return (// NaN/undefined represents access beyond the end of the file.
@@ -147,9 +147,9 @@ function printCharCode(code) {
147
147
  /**
148
148
  * Gets the next token from the source starting at the given position.
149
149
  *
150
- * This skips over whitespace and comments until it finds the next lexable
151
- * token, then lexes punctuators immediately or calls the appropriate helper
152
- * function for more complicated tokens.
150
+ * This skips over whitespace until it finds the next lexable token, then lexes
151
+ * punctuators immediately or calls the appropriate helper function for more
152
+ * complicated tokens.
153
153
  */
154
154
 
155
155
 
@@ -165,7 +165,7 @@ function readToken(lexer, prev) {
165
165
  return new Tok(TokenKind.EOF, bodyLength, bodyLength, line, col, prev);
166
166
  }
167
167
 
168
- var code = charCodeAt.call(body, pos); // SourceCharacter
168
+ var code = body.charCodeAt(pos); // SourceCharacter
169
169
 
170
170
  switch (code) {
171
171
  // !
@@ -194,7 +194,7 @@ function readToken(lexer, prev) {
194
194
  // .
195
195
 
196
196
  case 46:
197
- if (charCodeAt.call(body, pos + 1) === 46 && charCodeAt.call(body, pos + 2) === 46) {
197
+ if (body.charCodeAt(pos + 1) === 46 && body.charCodeAt(pos + 2) === 46) {
198
198
  return new Tok(TokenKind.SPREAD, pos, pos + 3, line, col, prev);
199
199
  }
200
200
 
@@ -304,8 +304,8 @@ function readToken(lexer, prev) {
304
304
  // "
305
305
 
306
306
  case 34:
307
- if (charCodeAt.call(body, pos + 1) === 34 && charCodeAt.call(body, pos + 2) === 34) {
308
- return readBlockString(source, pos, line, col, prev);
307
+ if (body.charCodeAt(pos + 1) === 34 && body.charCodeAt(pos + 2) === 34) {
308
+ return readBlockString(source, pos, line, col, prev, lexer);
309
309
  }
310
310
 
311
311
  return readString(source, pos, line, col, prev);
@@ -332,8 +332,7 @@ function unexpectedCharacterMessage(code) {
332
332
  }
333
333
  /**
334
334
  * Reads from body starting at startPosition until it finds a non-whitespace
335
- * or commented character, then returns the position of that character for
336
- * lexing.
335
+ * character, then returns the position of that character for lexing.
337
336
  */
338
337
 
339
338
 
@@ -342,7 +341,7 @@ function positionAfterWhitespace(body, startPosition, lexer) {
342
341
  var position = startPosition;
343
342
 
344
343
  while (position < bodyLength) {
345
- var code = charCodeAt.call(body, position); // tab | space | comma | BOM
344
+ var code = body.charCodeAt(position); // tab | space | comma | BOM
346
345
 
347
346
  if (code === 9 || code === 32 || code === 44 || code === 0xfeff) {
348
347
  ++position;
@@ -353,7 +352,7 @@ function positionAfterWhitespace(body, startPosition, lexer) {
353
352
  lexer.lineStart = position;
354
353
  } else if (code === 13) {
355
354
  // carriage return
356
- if (charCodeAt.call(body, position + 1) === 10) {
355
+ if (body.charCodeAt(position + 1) === 10) {
357
356
  position += 2;
358
357
  } else {
359
358
  ++position;
@@ -381,11 +380,11 @@ function readComment(source, start, line, col, prev) {
381
380
  var position = start;
382
381
 
383
382
  do {
384
- code = charCodeAt.call(body, ++position);
385
- } while (code !== null && ( // SourceCharacter but not LineTerminator
383
+ code = body.charCodeAt(++position);
384
+ } while (!isNaN(code) && ( // SourceCharacter but not LineTerminator
386
385
  code > 0x001f || code === 0x0009));
387
386
 
388
- return new Tok(TokenKind.COMMENT, start, position, line, col, prev, slice.call(body, start + 1, position));
387
+ return new Tok(TokenKind.COMMENT, start, position, line, col, prev, body.slice(start + 1, position));
389
388
  }
390
389
  /**
391
390
  * Reads a number token from the source file, either a float
@@ -404,43 +403,43 @@ function readNumber(source, start, firstCode, line, col, prev) {
404
403
 
405
404
  if (code === 45) {
406
405
  // -
407
- code = charCodeAt.call(body, ++position);
406
+ code = body.charCodeAt(++position);
408
407
  }
409
408
 
410
409
  if (code === 48) {
411
410
  // 0
412
- code = charCodeAt.call(body, ++position);
411
+ code = body.charCodeAt(++position);
413
412
 
414
413
  if (code >= 48 && code <= 57) {
415
414
  throw (0, _error.syntaxError)(source, position, "Invalid number, unexpected digit after 0: ".concat(printCharCode(code), "."));
416
415
  }
417
416
  } else {
418
417
  position = readDigits(source, position, code);
419
- code = charCodeAt.call(body, position);
418
+ code = body.charCodeAt(position);
420
419
  }
421
420
 
422
421
  if (code === 46) {
423
422
  // .
424
423
  isFloat = true;
425
- code = charCodeAt.call(body, ++position);
424
+ code = body.charCodeAt(++position);
426
425
  position = readDigits(source, position, code);
427
- code = charCodeAt.call(body, position);
426
+ code = body.charCodeAt(position);
428
427
  }
429
428
 
430
429
  if (code === 69 || code === 101) {
431
430
  // E e
432
431
  isFloat = true;
433
- code = charCodeAt.call(body, ++position);
432
+ code = body.charCodeAt(++position);
434
433
 
435
434
  if (code === 43 || code === 45) {
436
435
  // + -
437
- code = charCodeAt.call(body, ++position);
436
+ code = body.charCodeAt(++position);
438
437
  }
439
438
 
440
439
  position = readDigits(source, position, code);
441
440
  }
442
441
 
443
- return new Tok(isFloat ? TokenKind.FLOAT : TokenKind.INT, start, position, line, col, prev, slice.call(body, start, position));
442
+ return new Tok(isFloat ? TokenKind.FLOAT : TokenKind.INT, start, position, line, col, prev, body.slice(start, position));
444
443
  }
445
444
  /**
446
445
  * Returns the new position in the source after reading digits.
@@ -455,7 +454,7 @@ function readDigits(source, start, firstCode) {
455
454
  if (code >= 48 && code <= 57) {
456
455
  // 0 - 9
457
456
  do {
458
- code = charCodeAt.call(body, ++position);
457
+ code = body.charCodeAt(++position);
459
458
  } while (code >= 48 && code <= 57); // 0 - 9
460
459
 
461
460
 
@@ -478,11 +477,11 @@ function readString(source, start, line, col, prev) {
478
477
  var code = 0;
479
478
  var value = '';
480
479
 
481
- while (position < body.length && (code = charCodeAt.call(body, position)) !== null && // not LineTerminator
480
+ while (position < body.length && !isNaN(code = body.charCodeAt(position)) && // not LineTerminator
482
481
  code !== 0x000a && code !== 0x000d) {
483
482
  // Closing Quote (")
484
483
  if (code === 34) {
485
- value += slice.call(body, chunkStart, position);
484
+ value += body.slice(chunkStart, position);
486
485
  return new Tok(TokenKind.STRING, start, position + 1, line, col, prev, value);
487
486
  } // SourceCharacter
488
487
 
@@ -495,8 +494,8 @@ function readString(source, start, line, col, prev) {
495
494
 
496
495
  if (code === 92) {
497
496
  // \
498
- value += slice.call(body, chunkStart, position - 1);
499
- code = charCodeAt.call(body, position);
497
+ value += body.slice(chunkStart, position - 1);
498
+ code = body.charCodeAt(position);
500
499
 
501
500
  switch (code) {
502
501
  case 34:
@@ -533,7 +532,7 @@ function readString(source, start, line, col, prev) {
533
532
 
534
533
  case 117:
535
534
  // u
536
- var charCode = uniCharCode(charCodeAt.call(body, position + 1), charCodeAt.call(body, position + 2), charCodeAt.call(body, position + 3), charCodeAt.call(body, position + 4));
535
+ var charCode = uniCharCode(body.charCodeAt(position + 1), body.charCodeAt(position + 2), body.charCodeAt(position + 3), body.charCodeAt(position + 4));
537
536
 
538
537
  if (charCode < 0) {
539
538
  throw (0, _error.syntaxError)(source, position, 'Invalid character escape sequence: ' + "\\u".concat(body.slice(position + 1, position + 5), "."));
@@ -561,28 +560,43 @@ function readString(source, start, line, col, prev) {
561
560
  */
562
561
 
563
562
 
564
- function readBlockString(source, start, line, col, prev) {
563
+ function readBlockString(source, start, line, col, prev, lexer) {
565
564
  var body = source.body;
566
565
  var position = start + 3;
567
566
  var chunkStart = position;
568
567
  var code = 0;
569
568
  var rawValue = '';
570
569
 
571
- while (position < body.length && (code = charCodeAt.call(body, position)) !== null) {
570
+ while (position < body.length && !isNaN(code = body.charCodeAt(position))) {
572
571
  // Closing Triple-Quote (""")
573
- if (code === 34 && charCodeAt.call(body, position + 1) === 34 && charCodeAt.call(body, position + 2) === 34) {
574
- rawValue += slice.call(body, chunkStart, position);
575
- return new Tok(TokenKind.BLOCK_STRING, start, position + 3, line, col, prev, (0, _blockStringValue.default)(rawValue));
572
+ if (code === 34 && body.charCodeAt(position + 1) === 34 && body.charCodeAt(position + 2) === 34) {
573
+ rawValue += body.slice(chunkStart, position);
574
+ return new Tok(TokenKind.BLOCK_STRING, start, position + 3, line, col, prev, (0, _blockString.dedentBlockStringValue)(rawValue));
576
575
  } // SourceCharacter
577
576
 
578
577
 
579
578
  if (code < 0x0020 && code !== 0x0009 && code !== 0x000a && code !== 0x000d) {
580
579
  throw (0, _error.syntaxError)(source, position, "Invalid character within String: ".concat(printCharCode(code), "."));
581
- } // Escape Triple-Quote (\""")
580
+ }
582
581
 
582
+ if (code === 10) {
583
+ // new line
584
+ ++position;
585
+ ++lexer.line;
586
+ lexer.lineStart = position;
587
+ } else if (code === 13) {
588
+ // carriage return
589
+ if (body.charCodeAt(position + 1) === 10) {
590
+ position += 2;
591
+ } else {
592
+ ++position;
593
+ }
583
594
 
584
- if (code === 92 && charCodeAt.call(body, position + 1) === 34 && charCodeAt.call(body, position + 2) === 34 && charCodeAt.call(body, position + 3) === 34) {
585
- rawValue += slice.call(body, chunkStart, position) + '"""';
595
+ ++lexer.line;
596
+ lexer.lineStart = position;
597
+ } else if ( // Escape Triple-Quote (\""")
598
+ code === 92 && body.charCodeAt(position + 1) === 34 && body.charCodeAt(position + 2) === 34 && body.charCodeAt(position + 3) === 34) {
599
+ rawValue += body.slice(chunkStart, position) + '"""';
586
600
  position += 4;
587
601
  chunkStart = position;
588
602
  } else {
@@ -636,7 +650,7 @@ function readName(source, start, line, col, prev) {
636
650
  var position = start + 1;
637
651
  var code = 0;
638
652
 
639
- while (position !== bodyLength && (code = charCodeAt.call(body, position)) !== null && (code === 95 || // _
653
+ while (position !== bodyLength && !isNaN(code = body.charCodeAt(position)) && (code === 95 || // _
640
654
  code >= 48 && code <= 57 || // 0-9
641
655
  code >= 65 && code <= 90 || // A-Z
642
656
  code >= 97 && code <= 122) // a-z
@@ -644,5 +658,5 @@ function readName(source, start, line, col, prev) {
644
658
  ++position;
645
659
  }
646
660
 
647
- return new Tok(TokenKind.NAME, start, position, line, col, prev, slice.call(body, start, position));
661
+ return new Tok(TokenKind.NAME, start, position, line, col, prev, body.slice(start, position));
648
662
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) 2015-present, Facebook, Inc.
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -7,10 +7,11 @@
7
7
  * @flow strict
8
8
  */
9
9
 
10
+ import defineToJSON from '../jsutils/defineToJSON';
10
11
  import type { Token } from './ast';
11
12
  import type { Source } from './source';
12
13
  import { syntaxError } from '../error';
13
- import blockStringValue from './blockStringValue';
14
+ import { dedentBlockStringValue } from './blockString';
14
15
 
15
16
  /**
16
17
  * Given a Source object, this returns a Lexer for that source.
@@ -136,9 +137,6 @@ export function getTokenDesc(token: Token): string {
136
137
  return value ? `${token.kind} "${value}"` : token.kind;
137
138
  }
138
139
 
139
- const charCodeAt = String.prototype.charCodeAt;
140
- const slice = String.prototype.slice;
141
-
142
140
  /**
143
141
  * Helper function for constructing the Token object.
144
142
  */
@@ -162,14 +160,14 @@ function Tok(
162
160
  }
163
161
 
164
162
  // Print a simplified form when appearing in JSON/util.inspect.
165
- Tok.prototype.toJSON = Tok.prototype.inspect = function toJSON() {
163
+ defineToJSON(Tok, function() {
166
164
  return {
167
165
  kind: this.kind,
168
166
  value: this.value,
169
167
  line: this.line,
170
168
  column: this.column,
171
169
  };
172
- };
170
+ });
173
171
 
174
172
  function printCharCode(code) {
175
173
  return (
@@ -177,19 +175,19 @@ function printCharCode(code) {
177
175
  isNaN(code)
178
176
  ? TokenKind.EOF
179
177
  : // Trust JSON for ASCII.
180
- code < 0x007f
181
- ? JSON.stringify(String.fromCharCode(code))
182
- : // Otherwise print the escaped form.
183
- `"\\u${('00' + code.toString(16).toUpperCase()).slice(-4)}"`
178
+ code < 0x007f
179
+ ? JSON.stringify(String.fromCharCode(code))
180
+ : // Otherwise print the escaped form.
181
+ `"\\u${('00' + code.toString(16).toUpperCase()).slice(-4)}"`
184
182
  );
185
183
  }
186
184
 
187
185
  /**
188
186
  * Gets the next token from the source starting at the given position.
189
187
  *
190
- * This skips over whitespace and comments until it finds the next lexable
191
- * token, then lexes punctuators immediately or calls the appropriate helper
192
- * function for more complicated tokens.
188
+ * This skips over whitespace until it finds the next lexable token, then lexes
189
+ * punctuators immediately or calls the appropriate helper function for more
190
+ * complicated tokens.
193
191
  */
194
192
  function readToken(lexer: Lexer<*>, prev: Token): Token {
195
193
  const source = lexer.source;
@@ -204,7 +202,7 @@ function readToken(lexer: Lexer<*>, prev: Token): Token {
204
202
  return new Tok(TokenKind.EOF, bodyLength, bodyLength, line, col, prev);
205
203
  }
206
204
 
207
- const code = charCodeAt.call(body, pos);
205
+ const code = body.charCodeAt(pos);
208
206
 
209
207
  // SourceCharacter
210
208
  switch (code) {
@@ -228,10 +226,7 @@ function readToken(lexer: Lexer<*>, prev: Token): Token {
228
226
  return new Tok(TokenKind.PAREN_R, pos, pos + 1, line, col, prev);
229
227
  // .
230
228
  case 46:
231
- if (
232
- charCodeAt.call(body, pos + 1) === 46 &&
233
- charCodeAt.call(body, pos + 2) === 46
234
- ) {
229
+ if (body.charCodeAt(pos + 1) === 46 && body.charCodeAt(pos + 2) === 46) {
235
230
  return new Tok(TokenKind.SPREAD, pos, pos + 3, line, col, prev);
236
231
  }
237
232
  break;
@@ -329,11 +324,8 @@ function readToken(lexer: Lexer<*>, prev: Token): Token {
329
324
  return readNumber(source, pos, code, line, col, prev);
330
325
  // "
331
326
  case 34:
332
- if (
333
- charCodeAt.call(body, pos + 1) === 34 &&
334
- charCodeAt.call(body, pos + 2) === 34
335
- ) {
336
- return readBlockString(source, pos, line, col, prev);
327
+ if (body.charCodeAt(pos + 1) === 34 && body.charCodeAt(pos + 2) === 34) {
328
+ return readBlockString(source, pos, line, col, prev, lexer);
337
329
  }
338
330
  return readString(source, pos, line, col, prev);
339
331
  }
@@ -362,8 +354,7 @@ function unexpectedCharacterMessage(code) {
362
354
 
363
355
  /**
364
356
  * Reads from body starting at startPosition until it finds a non-whitespace
365
- * or commented character, then returns the position of that character for
366
- * lexing.
357
+ * character, then returns the position of that character for lexing.
367
358
  */
368
359
  function positionAfterWhitespace(
369
360
  body: string,
@@ -373,7 +364,7 @@ function positionAfterWhitespace(
373
364
  const bodyLength = body.length;
374
365
  let position = startPosition;
375
366
  while (position < bodyLength) {
376
- const code = charCodeAt.call(body, position);
367
+ const code = body.charCodeAt(position);
377
368
  // tab | space | comma | BOM
378
369
  if (code === 9 || code === 32 || code === 44 || code === 0xfeff) {
379
370
  ++position;
@@ -384,7 +375,7 @@ function positionAfterWhitespace(
384
375
  lexer.lineStart = position;
385
376
  } else if (code === 13) {
386
377
  // carriage return
387
- if (charCodeAt.call(body, position + 1) === 10) {
378
+ if (body.charCodeAt(position + 1) === 10) {
388
379
  position += 2;
389
380
  } else {
390
381
  ++position;
@@ -409,9 +400,9 @@ function readComment(source, start, line, col, prev): Token {
409
400
  let position = start;
410
401
 
411
402
  do {
412
- code = charCodeAt.call(body, ++position);
403
+ code = body.charCodeAt(++position);
413
404
  } while (
414
- code !== null &&
405
+ !isNaN(code) &&
415
406
  // SourceCharacter but not LineTerminator
416
407
  (code > 0x001f || code === 0x0009)
417
408
  );
@@ -423,7 +414,7 @@ function readComment(source, start, line, col, prev): Token {
423
414
  line,
424
415
  col,
425
416
  prev,
426
- slice.call(body, start + 1, position),
417
+ body.slice(start + 1, position),
427
418
  );
428
419
  }
429
420
 
@@ -442,12 +433,12 @@ function readNumber(source, start, firstCode, line, col, prev): Token {
442
433
 
443
434
  if (code === 45) {
444
435
  // -
445
- code = charCodeAt.call(body, ++position);
436
+ code = body.charCodeAt(++position);
446
437
  }
447
438
 
448
439
  if (code === 48) {
449
440
  // 0
450
- code = charCodeAt.call(body, ++position);
441
+ code = body.charCodeAt(++position);
451
442
  if (code >= 48 && code <= 57) {
452
443
  throw syntaxError(
453
444
  source,
@@ -457,26 +448,26 @@ function readNumber(source, start, firstCode, line, col, prev): Token {
457
448
  }
458
449
  } else {
459
450
  position = readDigits(source, position, code);
460
- code = charCodeAt.call(body, position);
451
+ code = body.charCodeAt(position);
461
452
  }
462
453
 
463
454
  if (code === 46) {
464
455
  // .
465
456
  isFloat = true;
466
457
 
467
- code = charCodeAt.call(body, ++position);
458
+ code = body.charCodeAt(++position);
468
459
  position = readDigits(source, position, code);
469
- code = charCodeAt.call(body, position);
460
+ code = body.charCodeAt(position);
470
461
  }
471
462
 
472
463
  if (code === 69 || code === 101) {
473
464
  // E e
474
465
  isFloat = true;
475
466
 
476
- code = charCodeAt.call(body, ++position);
467
+ code = body.charCodeAt(++position);
477
468
  if (code === 43 || code === 45) {
478
469
  // + -
479
- code = charCodeAt.call(body, ++position);
470
+ code = body.charCodeAt(++position);
480
471
  }
481
472
  position = readDigits(source, position, code);
482
473
  }
@@ -488,7 +479,7 @@ function readNumber(source, start, firstCode, line, col, prev): Token {
488
479
  line,
489
480
  col,
490
481
  prev,
491
- slice.call(body, start, position),
482
+ body.slice(start, position),
492
483
  );
493
484
  }
494
485
 
@@ -502,7 +493,7 @@ function readDigits(source, start, firstCode) {
502
493
  if (code >= 48 && code <= 57) {
503
494
  // 0 - 9
504
495
  do {
505
- code = charCodeAt.call(body, ++position);
496
+ code = body.charCodeAt(++position);
506
497
  } while (code >= 48 && code <= 57); // 0 - 9
507
498
  return position;
508
499
  }
@@ -527,14 +518,14 @@ function readString(source, start, line, col, prev): Token {
527
518
 
528
519
  while (
529
520
  position < body.length &&
530
- (code = charCodeAt.call(body, position)) !== null &&
521
+ !isNaN((code = body.charCodeAt(position))) &&
531
522
  // not LineTerminator
532
523
  code !== 0x000a &&
533
524
  code !== 0x000d
534
525
  ) {
535
526
  // Closing Quote (")
536
527
  if (code === 34) {
537
- value += slice.call(body, chunkStart, position);
528
+ value += body.slice(chunkStart, position);
538
529
  return new Tok(
539
530
  TokenKind.STRING,
540
531
  start,
@@ -558,8 +549,8 @@ function readString(source, start, line, col, prev): Token {
558
549
  ++position;
559
550
  if (code === 92) {
560
551
  // \
561
- value += slice.call(body, chunkStart, position - 1);
562
- code = charCodeAt.call(body, position);
552
+ value += body.slice(chunkStart, position - 1);
553
+ code = body.charCodeAt(position);
563
554
  switch (code) {
564
555
  case 34:
565
556
  value += '"';
@@ -587,10 +578,10 @@ function readString(source, start, line, col, prev): Token {
587
578
  break;
588
579
  case 117: // u
589
580
  const charCode = uniCharCode(
590
- charCodeAt.call(body, position + 1),
591
- charCodeAt.call(body, position + 2),
592
- charCodeAt.call(body, position + 3),
593
- charCodeAt.call(body, position + 4),
581
+ body.charCodeAt(position + 1),
582
+ body.charCodeAt(position + 2),
583
+ body.charCodeAt(position + 3),
584
+ body.charCodeAt(position + 4),
594
585
  );
595
586
  if (charCode < 0) {
596
587
  throw syntaxError(
@@ -625,24 +616,21 @@ function readString(source, start, line, col, prev): Token {
625
616
  *
626
617
  * """("?"?(\\"""|\\(?!=""")|[^"\\]))*"""
627
618
  */
628
- function readBlockString(source, start, line, col, prev): Token {
619
+ function readBlockString(source, start, line, col, prev, lexer): Token {
629
620
  const body = source.body;
630
621
  let position = start + 3;
631
622
  let chunkStart = position;
632
623
  let code = 0;
633
624
  let rawValue = '';
634
625
 
635
- while (
636
- position < body.length &&
637
- (code = charCodeAt.call(body, position)) !== null
638
- ) {
626
+ while (position < body.length && !isNaN((code = body.charCodeAt(position)))) {
639
627
  // Closing Triple-Quote (""")
640
628
  if (
641
629
  code === 34 &&
642
- charCodeAt.call(body, position + 1) === 34 &&
643
- charCodeAt.call(body, position + 2) === 34
630
+ body.charCodeAt(position + 1) === 34 &&
631
+ body.charCodeAt(position + 2) === 34
644
632
  ) {
645
- rawValue += slice.call(body, chunkStart, position);
633
+ rawValue += body.slice(chunkStart, position);
646
634
  return new Tok(
647
635
  TokenKind.BLOCK_STRING,
648
636
  start,
@@ -650,7 +638,7 @@ function readBlockString(source, start, line, col, prev): Token {
650
638
  line,
651
639
  col,
652
640
  prev,
653
- blockStringValue(rawValue),
641
+ dedentBlockStringValue(rawValue),
654
642
  );
655
643
  }
656
644
 
@@ -668,14 +656,28 @@ function readBlockString(source, start, line, col, prev): Token {
668
656
  );
669
657
  }
670
658
 
671
- // Escape Triple-Quote (\""")
672
- if (
659
+ if (code === 10) {
660
+ // new line
661
+ ++position;
662
+ ++lexer.line;
663
+ lexer.lineStart = position;
664
+ } else if (code === 13) {
665
+ // carriage return
666
+ if (body.charCodeAt(position + 1) === 10) {
667
+ position += 2;
668
+ } else {
669
+ ++position;
670
+ }
671
+ ++lexer.line;
672
+ lexer.lineStart = position;
673
+ } else if (
674
+ // Escape Triple-Quote (\""")
673
675
  code === 92 &&
674
- charCodeAt.call(body, position + 1) === 34 &&
675
- charCodeAt.call(body, position + 2) === 34 &&
676
- charCodeAt.call(body, position + 3) === 34
676
+ body.charCodeAt(position + 1) === 34 &&
677
+ body.charCodeAt(position + 2) === 34 &&
678
+ body.charCodeAt(position + 3) === 34
677
679
  ) {
678
- rawValue += slice.call(body, chunkStart, position) + '"""';
680
+ rawValue += body.slice(chunkStart, position) + '"""';
679
681
  position += 4;
680
682
  chunkStart = position;
681
683
  } else {
@@ -714,10 +716,10 @@ function char2hex(a) {
714
716
  return a >= 48 && a <= 57
715
717
  ? a - 48 // 0-9
716
718
  : a >= 65 && a <= 70
717
- ? a - 55 // A-F
718
- : a >= 97 && a <= 102
719
- ? a - 87 // a-f
720
- : -1;
719
+ ? a - 55 // A-F
720
+ : a >= 97 && a <= 102
721
+ ? a - 87 // a-f
722
+ : -1;
721
723
  }
722
724
 
723
725
  /**
@@ -732,7 +734,7 @@ function readName(source, start, line, col, prev): Token {
732
734
  let code = 0;
733
735
  while (
734
736
  position !== bodyLength &&
735
- (code = charCodeAt.call(body, position)) !== null &&
737
+ !isNaN((code = body.charCodeAt(position))) &&
736
738
  (code === 95 || // _
737
739
  (code >= 48 && code <= 57) || // 0-9
738
740
  (code >= 65 && code <= 90) || // A-Z
@@ -747,6 +749,6 @@ function readName(source, start, line, col, prev): Token {
747
749
  line,
748
750
  col,
749
751
  prev,
750
- slice.call(body, start, position),
752
+ body.slice(start, position),
751
753
  );
752
754
  }