ixfx
    Preparing search index...

    Function resolveFields

    • Returns a copy of object, with the same properties. For each property that has a basic value (string, number, boolean, object), the value is set for the return object. If the property is a function or generator, its value is used instead. Async functions and generators are also usable.

      Use resolveFieldsSync for a synchronous version.

      Not recursive.

      In the below example, the function for the property random is invoked.

      const state = {
      length: 10,
      random: () => Math.random();
      }
      const x = resolveFields(state);
      // { length: 10, random: 0.1235 }

      It also works with generators

      import { count } from './numbers.js';

      const state = {
      length: 10,
      index: count(2) // Generator that yields: 0, 1 and then ends
      }
      resolveFields(state); // { length: 10, index: 0 }
      resolveFields(state); // { length: 10, index: 1 }
      // Generator finishes after counting twice:
      resolveFields(state); // { length: 10, index: undefined }

      Type Parameters

      Parameters

      • object: T

      Returns Promise<ResolvedObject<T>>