graphql
Version:
A Query Language and Runtime which can target any service.
1 lines • 1.15 kB
Source Map (JSON)
{"version":3,"file":"isIterableObject.js","sourceRoot":"","sources":["../../src/jsutils/isIterableObject.ts"],"names":[],"mappings":"AAkBA,MAAM,UAAU,gBAAgB,CAC9B,aAAkB;IAElB,OAAO,CACL,OAAO,aAAa,KAAK,QAAQ;QACjC,OAAO,aAAa,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,UAAU,CACvD,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Returns true if the provided object is an Object (i.e. not a string literal)\n * and implements the Iterator protocol.\n *\n * This may be used in place of [Array.isArray()][isArray] to determine if\n * an object should be iterated-over e.g. Array, Map, Set, Int8Array,\n * TypedArray, etc. but excludes string literals.\n *\n * @internal\n * @example\n * ```ts\n * isIterableObject([1, 2, 3]); // => true\n * isIterableObject(new Map()); // => true\n * isIterableObject('ABC'); // => false\n * isIterableObject({ key: 'value' }); // => false\n * isIterableObject({ length: 1, 0: 'Alpha' }); // => false\n * ```\n */\nexport function isIterableObject(\n maybeIterable: any,\n): maybeIterable is Iterable<unknown> {\n return (\n typeof maybeIterable === 'object' &&\n typeof maybeIterable?.[Symbol.iterator] === 'function'\n );\n}\n"]}