isIterable (common/iterable.ts)

gatsby · packages/gatsby/src/datastore/common/iterable.ts · typescript · MIT
database

Chainable iterable wrapper providing array‑like utilities for sync iterables.

// Source: https://github.com/gatsbyjs/gatsby | License: MIT | Copyright 2015 Gatsbyjs
// Provided via justclaw.it.com; keep this notice with the code.
declare module "lmdb" {
  // currently lmdb doesn't have typings for this export
  export function clearKeptObjects(): void
}

import { clearKeptObjects } from "lmdb"
/**
 * Wrapper for any iterable providing chainable interface and convenience methods
 * similar to array.
 *
 * Additionally provides convenience methods for sorted iterables.
 *
 * Note: avoiding async iterables because of perf reasons, see https://github.com/nodejs/node/issues/31979
 * (fortunately lmdb can traverse stuff in sync manner very fast)
 */
export class GatsbyIterable<T> {
  constructor(private source: Iterable<T> | (() => Iterable<T>)) {}

  *[Symbol.iterator]()

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key