Skip to content

Commit 2300df4

Browse files
committed
Drop 'Array.from' polyfill
1 parent d24e4d0 commit 2300df4

File tree

7 files changed

+10
-70
lines changed

7 files changed

+10
-70
lines changed

src/execution/execute.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import arrayFrom from '../polyfills/arrayFrom';
2-
31
import type { Path } from '../jsutils/Path';
42
import type { ObjMap } from '../jsutils/ObjMap';
53
import type { PromiseOrValue } from '../jsutils/PromiseOrValue';
@@ -833,7 +831,7 @@ function completeListValue(
833831
// where the list contains no Promises by avoiding creating another Promise.
834832
const itemType = returnType.ofType;
835833
let containsPromise = false;
836-
const completedResults = arrayFrom(result, (item, index) => {
834+
const completedResults = Array.from(result, (item, index) => {
837835
// No need to modify the info object containing the path,
838836
// since from here on it is not ever accessed by resolver functions.
839837
const itemPath = addPath(path, index, undefined);

src/jsutils/isCollection.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ import { SYMBOL_ITERATOR } from '../polyfills/symbols';
2121
* An Object value which might implement the Iterable or Array-like protocols.
2222
* @return {boolean} true if Iterable or Array-like Object.
2323
*/
24-
export default function isCollection(obj: mixed): boolean {
24+
declare function isCollection(value: mixed): boolean %checks(value instanceof
25+
Iterable);
26+
27+
// eslint-disable-next-line no-redeclare
28+
export default function isCollection(obj) {
2529
if (obj == null || typeof obj !== 'object') {
2630
return false;
2731
}

src/polyfills/arrayFrom.js

Lines changed: 0 additions & 57 deletions
This file was deleted.

src/type/schema.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import arrayFrom from '../polyfills/arrayFrom';
21
import objectValues from '../polyfills/objectValues';
32
import { SYMBOL_TO_STRING_TAG } from '../polyfills/symbols';
43

@@ -207,7 +206,7 @@ export class GraphQLSchema {
207206
// Keep track of all implementations by interface name.
208207
this._implementationsMap = Object.create(null);
209208

210-
for (const namedType of arrayFrom(allReferencedTypes)) {
209+
for (const namedType of Array.from(allReferencedTypes)) {
211210
if (namedType == null) {
212211
continue;
213212
}

src/utilities/astFromValue.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import arrayFrom from '../polyfills/arrayFrom';
21
import objectValues from '../polyfills/objectValues';
32

43
import inspect from '../jsutils/inspect';
@@ -67,7 +66,7 @@ export function astFromValue(value: mixed, type: GraphQLInputType): ?ValueNode {
6766
const valuesNodes = [];
6867
// Since we transpile for-of in loose mode it doesn't support iterators
6968
// and it's required to first convert iteratable into array
70-
for (const item of arrayFrom(value)) {
69+
for (const item of Array.from(value)) {
7170
const itemNode = astFromValue(item, itemType);
7271
if (itemNode != null) {
7372
valuesNodes.push(itemNode);

src/utilities/coerceInputValue.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import arrayFrom from '../polyfills/arrayFrom';
21
import objectValues from '../polyfills/objectValues';
32

43
import type { Path } from '../jsutils/Path';
@@ -79,7 +78,7 @@ function coerceInputValueImpl(
7978
if (isListType(type)) {
8079
const itemType = type.ofType;
8180
if (isCollection(inputValue)) {
82-
return arrayFrom(inputValue, (itemValue, index) => {
81+
return Array.from(inputValue, (itemValue, index) => {
8382
const itemPath = addPath(path, index, undefined);
8483
return coerceInputValueImpl(itemValue, itemType, onError, itemPath);
8584
});

src/validation/rules/FieldsOnCorrectTypeRule.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import arrayFrom from '../../polyfills/arrayFrom';
2-
31
import didYouMean from '../../jsutils/didYouMean';
42
import suggestionList from '../../jsutils/suggestionList';
53

@@ -106,7 +104,7 @@ function getSuggestedTypeNames(
106104
}
107105
}
108106

109-
return arrayFrom(suggestedTypes)
107+
return Array.from(suggestedTypes)
110108
.sort((typeA, typeB) => {
111109
// Suggest both interface and object types based on how common they are.
112110
const usageCountDiff = usageCount[typeB.name] - usageCount[typeA.name];

0 commit comments

Comments
 (0)