INNER CODE UNIT · TypeScript

bindingsIndex

cloudflare/miniflare · packages/core/src/index.ts:121

  let bindingsIndex = -1;
  for (let i = 0; i < entries.length; i++) {
    const [, plugin] = entries[i];
    // @ts-expect-error plugin has type `typeof Plugin`
    if (plugin === CorePlugin) coreIndex = i;
    // @ts-expect-error plugin has type `typeof Plugin`
    else if (plugin === BindingsPlugin) bindingsIndex = i;
  }
  // If CorePlugin isn't already first, move it to start
  if (coreIndex > 0) {
    entries.unshift(...entries.splice(coreIndex, 1));
  }
  // If BindingsPlugin isn't already last (and it was included), move it to end
  if (bindingsIndex !== -1 && bindingsIndex !== entries.length - 1) {
    entries.push(...entries.splice(bindingsIndex, 1));
  }
  return entries;
}

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…