Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7534391

Browse files
author
Travis CI
committed
Deploy 081db43 to NPM branch
1 parent afda567 commit 7534391

15 files changed

+539
-51
lines changed

index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,6 +1011,12 @@ Object.defineProperty(exports, "separateOperations", {
10111011
return _utilities.separateOperations;
10121012
}
10131013
});
1014+
Object.defineProperty(exports, "stripIgnoredCharacters", {
1015+
enumerable: true,
1016+
get: function get() {
1017+
return _utilities.stripIgnoredCharacters;
1018+
}
1019+
});
10141020
Object.defineProperty(exports, "isEqualType", {
10151021
enumerable: true,
10161022
get: function get() {

index.js.flow

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,9 @@ export {
386386
concatAST,
387387
// Separates an AST into an AST per Operation.
388388
separateOperations,
389+
// Strips characters that are not significant to the validity or execution
390+
// of a GraphQL document.
391+
stripIgnoredCharacters,
389392
// Comparators for types
390393
isEqualType,
391394
isTypeSubTypeOf,

index.mjs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,9 @@ coerceValue, // @deprecated use coerceValue - will be removed in v15
9090
isValidJSValue, // @deprecated use validation - will be removed in v15
9191
isValidLiteralValue, // Concatenates multiple AST together.
9292
concatAST, // Separates an AST into an AST per Operation.
93-
separateOperations, // Comparators for types
93+
separateOperations, // Strips characters that are not significant to the validity or execution
94+
// of a GraphQL document.
95+
stripIgnoredCharacters, // Comparators for types
9496
isEqualType, isTypeSubTypeOf, doTypesOverlap, // Asserts a string is a valid GraphQL name.
9597
assertValidName, // Determine if a string is a valid GraphQL name.
9698
isValidNameError, // Compares two GraphQLSchemas and detects breaking changes.

language/blockString.js

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
44
value: true
55
});
66
exports.dedentBlockStringValue = dedentBlockStringValue;
7+
exports.getBlockStringIndentation = getBlockStringIndentation;
78
exports.printBlockString = printBlockString;
89

910
/**
@@ -25,24 +26,11 @@ function dedentBlockStringValue(rawString) {
2526
// Expand a block string's raw value into independent lines.
2627
var lines = rawString.split(/\r\n|[\n\r]/g); // Remove common indentation from all lines but first.
2728

28-
var commonIndent = null;
29-
30-
for (var i = 1; i < lines.length; i++) {
31-
var line = lines[i];
32-
var indent = leadingWhitespace(line);
33-
34-
if (indent < line.length && (commonIndent === null || indent < commonIndent)) {
35-
commonIndent = indent;
36-
37-
if (commonIndent === 0) {
38-
break;
39-
}
40-
}
41-
}
29+
var commonIndent = getBlockStringIndentation(lines);
4230

43-
if (commonIndent) {
44-
for (var _i = 1; _i < lines.length; _i++) {
45-
lines[_i] = lines[_i].slice(commonIndent);
31+
if (commonIndent !== 0) {
32+
for (var i = 1; i < lines.length; i++) {
33+
lines[i] = lines[i].slice(commonIndent);
4634
}
4735
} // Remove leading and trailing blank lines.
4836

@@ -57,6 +45,30 @@ function dedentBlockStringValue(rawString) {
5745

5846

5947
return lines.join('\n');
48+
} // @internal
49+
50+
51+
function getBlockStringIndentation(lines) {
52+
var commonIndent = null;
53+
54+
for (var i = 1; i < lines.length; i++) {
55+
var line = lines[i];
56+
var indent = leadingWhitespace(line);
57+
58+
if (indent === line.length) {
59+
continue; // skip empty lines
60+
}
61+
62+
if (commonIndent === null || indent < commonIndent) {
63+
commonIndent = indent;
64+
65+
if (commonIndent === 0) {
66+
break;
67+
}
68+
}
69+
}
70+
71+
return commonIndent === null ? 0 : commonIndent;
6072
}
6173

6274
function leadingWhitespace(str) {

language/blockString.js.flow

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,9 @@ export function dedentBlockStringValue(rawString: string): string {
1818
const lines = rawString.split(/\r\n|[\n\r]/g);
1919

2020
// Remove common indentation from all lines but first.
21-
let commonIndent = null;
22-
for (let i = 1; i < lines.length; i++) {
23-
const line = lines[i];
24-
const indent = leadingWhitespace(line);
25-
if (
26-
indent < line.length &&
27-
(commonIndent === null || indent < commonIndent)
28-
) {
29-
commonIndent = indent;
30-
if (commonIndent === 0) {
31-
break;
32-
}
33-
}
34-
}
21+
const commonIndent = getBlockStringIndentation(lines);
3522

36-
if (commonIndent) {
23+
if (commonIndent !== 0) {
3724
for (let i = 1; i < lines.length; i++) {
3825
lines[i] = lines[i].slice(commonIndent);
3926
}
@@ -51,6 +38,28 @@ export function dedentBlockStringValue(rawString: string): string {
5138
return lines.join('\n');
5239
}
5340

41+
// @internal
42+
export function getBlockStringIndentation(lines: Array<string>): number {
43+
let commonIndent = null;
44+
45+
for (let i = 1; i < lines.length; i++) {
46+
const line = lines[i];
47+
const indent = leadingWhitespace(line);
48+
if (indent === line.length) {
49+
continue; // skip empty lines
50+
}
51+
52+
if (commonIndent === null || indent < commonIndent) {
53+
commonIndent = indent;
54+
if (commonIndent === 0) {
55+
break;
56+
}
57+
}
58+
}
59+
60+
return commonIndent === null ? 0 : commonIndent;
61+
}
62+
5463
function leadingWhitespace(str) {
5564
let i = 0;
5665
while (i < str.length && (str[i] === ' ' || str[i] === '\t')) {

language/blockString.mjs

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,11 @@ export function dedentBlockStringValue(rawString) {
1717
// Expand a block string's raw value into independent lines.
1818
var lines = rawString.split(/\r\n|[\n\r]/g); // Remove common indentation from all lines but first.
1919

20-
var commonIndent = null;
21-
22-
for (var i = 1; i < lines.length; i++) {
23-
var line = lines[i];
24-
var indent = leadingWhitespace(line);
25-
26-
if (indent < line.length && (commonIndent === null || indent < commonIndent)) {
27-
commonIndent = indent;
20+
var commonIndent = getBlockStringIndentation(lines);
2821

29-
if (commonIndent === 0) {
30-
break;
31-
}
32-
}
33-
}
34-
35-
if (commonIndent) {
36-
for (var _i = 1; _i < lines.length; _i++) {
37-
lines[_i] = lines[_i].slice(commonIndent);
22+
if (commonIndent !== 0) {
23+
for (var i = 1; i < lines.length; i++) {
24+
lines[i] = lines[i].slice(commonIndent);
3825
}
3926
} // Remove leading and trailing blank lines.
4027

@@ -49,6 +36,29 @@ export function dedentBlockStringValue(rawString) {
4936

5037

5138
return lines.join('\n');
39+
} // @internal
40+
41+
export function getBlockStringIndentation(lines) {
42+
var commonIndent = null;
43+
44+
for (var i = 1; i < lines.length; i++) {
45+
var line = lines[i];
46+
var indent = leadingWhitespace(line);
47+
48+
if (indent === line.length) {
49+
continue; // skip empty lines
50+
}
51+
52+
if (commonIndent === null || indent < commonIndent) {
53+
commonIndent = indent;
54+
55+
if (commonIndent === 0) {
56+
break;
57+
}
58+
}
59+
}
60+
61+
return commonIndent === null ? 0 : commonIndent;
5262
}
5363

5464
function leadingWhitespace(str) {

language/lexer.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
44
value: true
55
});
66
exports.createLexer = createLexer;
7+
exports.isPunctuatorToken = isPunctuatorToken;
78
exports.getTokenDesc = getTokenDesc;
89
exports.TokenKind = void 0;
910

@@ -104,9 +105,16 @@ var TokenKind = Object.freeze({
104105

105106
exports.TokenKind = TokenKind;
106107

108+
// @internal
109+
function isPunctuatorToken(token) {
110+
var kind = token.kind;
111+
return kind === TokenKind.BANG || kind === TokenKind.DOLLAR || kind === TokenKind.AMP || kind === TokenKind.PAREN_L || kind === TokenKind.PAREN_R || kind === TokenKind.SPREAD || kind === TokenKind.COLON || kind === TokenKind.EQUALS || kind === TokenKind.AT || kind === TokenKind.BRACKET_L || kind === TokenKind.BRACKET_R || kind === TokenKind.BRACE_L || kind === TokenKind.PIPE || kind === TokenKind.BRACE_R;
112+
}
107113
/**
108114
* A helper function to describe a token as a string for debugging
109115
*/
116+
117+
110118
function getTokenDesc(token) {
111119
var value = token.value;
112120
return value ? "".concat(token.kind, " \"").concat(value, "\"") : token.kind;

language/lexer.js.flow

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,27 @@ export const TokenKind = Object.freeze({
129129
*/
130130
export type TokenKindEnum = $Values<typeof TokenKind>;
131131

132+
// @internal
133+
export function isPunctuatorToken(token: Token) {
134+
const kind = token.kind;
135+
return (
136+
kind === TokenKind.BANG ||
137+
kind === TokenKind.DOLLAR ||
138+
kind === TokenKind.AMP ||
139+
kind === TokenKind.PAREN_L ||
140+
kind === TokenKind.PAREN_R ||
141+
kind === TokenKind.SPREAD ||
142+
kind === TokenKind.COLON ||
143+
kind === TokenKind.EQUALS ||
144+
kind === TokenKind.AT ||
145+
kind === TokenKind.BRACKET_L ||
146+
kind === TokenKind.BRACKET_R ||
147+
kind === TokenKind.BRACE_L ||
148+
kind === TokenKind.PIPE ||
149+
kind === TokenKind.BRACE_R
150+
);
151+
}
152+
132153
/**
133154
* A helper function to describe a token as a string for debugging
134155
*/

language/lexer.mjs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,15 @@ export var TokenKind = Object.freeze({
8888
* The enum type representing the token kinds values.
8989
*/
9090

91+
// @internal
92+
export function isPunctuatorToken(token) {
93+
var kind = token.kind;
94+
return kind === TokenKind.BANG || kind === TokenKind.DOLLAR || kind === TokenKind.AMP || kind === TokenKind.PAREN_L || kind === TokenKind.PAREN_R || kind === TokenKind.SPREAD || kind === TokenKind.COLON || kind === TokenKind.EQUALS || kind === TokenKind.AT || kind === TokenKind.BRACKET_L || kind === TokenKind.BRACKET_R || kind === TokenKind.BRACE_L || kind === TokenKind.PIPE || kind === TokenKind.BRACE_R;
95+
}
9196
/**
9297
* A helper function to describe a token as a string for debugging
9398
*/
99+
94100
export function getTokenDesc(token) {
95101
var value = token.value;
96102
return value ? "".concat(token.kind, " \"").concat(value, "\"") : token.kind;

utilities/index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,12 @@ Object.defineProperty(exports, "separateOperations", {
147147
return _separateOperations.separateOperations;
148148
}
149149
});
150+
Object.defineProperty(exports, "stripIgnoredCharacters", {
151+
enumerable: true,
152+
get: function get() {
153+
return _stripIgnoredCharacters.stripIgnoredCharacters;
154+
}
155+
});
150156
Object.defineProperty(exports, "isEqualType", {
151157
enumerable: true,
152158
get: function get() {
@@ -246,6 +252,8 @@ var _concatAST = require("./concatAST");
246252

247253
var _separateOperations = require("./separateOperations");
248254

255+
var _stripIgnoredCharacters = require("./stripIgnoredCharacters");
256+
249257
var _typeComparators = require("./typeComparators");
250258

251259
var _assertValidName = require("./assertValidName");

0 commit comments

Comments
 (0)