MCPcopy Create free account
hub / github.com/microsoft/SandDance / createIterable

Function createIterable

docs/app/js/sanddance-app.js:86234–86257  ·  view source on GitHub ↗
(data)

Source from the content-addressed store, hash-verified

86232var EMPTY_ARRAY = [];
86233var placeholderArray = [];
86234function createIterable(data) {
86235 var startRow = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
86236 var endRow = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : Infinity;
86237 var iterable = EMPTY_ARRAY;
86238 var objectInfo = {
86239 index: -1,
86240 data: data,
86241 target: []
86242 };
86243 if (!data) iterable = EMPTY_ARRAY;
86244 else if (typeof data[Symbol.iterator] === "function") iterable = data;
86245 else if (data.length > 0) {
86246 placeholderArray.length = data.length;
86247 iterable = placeholderArray;
86248 }
86249 if (startRow > 0 || Number.isFinite(endRow)) {
86250 iterable = (Array.isArray(iterable) ? iterable : Array.from(iterable)).slice(startRow, endRow);
86251 objectInfo.index = startRow - 1;
86252 }
86253 return {
86254 iterable: iterable,
86255 objectInfo: objectInfo
86256 };
86257}
86258function isAsyncIterable(data) {
86259 return data && data[Symbol.asyncIterator];
86260}

Callers

nothing calls this directly

Calls 1

fromMethod · 0.45

Tested by

no test coverage detected