Back to Functions

runInContext

util

Create a new pristine lodash function using the given context object.

Installation

Import
import { runInContext } from '@tulx/utils';

Source Code

Implementation
/**
 * Create a new pristine lodash function using the given context object.
 *
 * @param context - The context object.
 * @returns Returns a new lodash function.
 *
 * @example
 * ```ts
 * const _ = runInContext();
 * ```
 */
export function runInContext(
  context?: Record<string, unknown>
): typeof globalThis {
  return context ? (context as typeof globalThis) : globalThis;
}

Example

import { runInContext } from '@tulx/utils';

const _ = runInContext();

Related Functions