Back to Functions

stubObject

util

This method returns a new empty object.

Installation

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

Source Code

Implementation
/**
 * This method returns a new empty object.
 *
 * @returns Returns the new empty object.
 *
 * @example
 * ```ts
 * const objects = times(2, stubObject);
 * console.log(objects); // [{}, {}]
 * console.log(objects[0] === objects[1]); // false
 * ```
 */
export function stubObject(): Record<string, never> {
  return {};
}

Example

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

const objects = times(2, stubObject);
console.log(objects); // [{}, {}]
console.log(objects[0] === objects[1]); // false

Related Functions