MCPcopy Index your code
hub / github.com/loopbackio/loopback-next / singleValue

Method singleValue

packages/context/src/context-view.ts:255–264  ·  view source on GitHub ↗

* Get the single value

(
    session?: ResolutionOptionsOrSession,
  )

Source from the content-addressed store, hash-verified

253 * Get the single value
254 */
255 async singleValue(
256 session?: ResolutionOptionsOrSession,
257 ): Promise<T | undefined> {
258 const values = await this.values(session);
259 if (values.length === 0) return undefined;
260 if (values.length === 1) return values[0];
261 throw new Error(
262 'The ContextView has more than one value. Use values() to access them.',
263 );
264 }
265
266 /**
267 * The "bind" event is emitted when a new binding is added to the view.

Callers 4

valueFunction · 0.80
getTTLMethod · 0.80

Calls 1

valuesMethod · 0.95

Tested by

no test coverage detected