API
@agape/util

properties Function

Creates a new object containing only the non-function properties from the original object.

API

function properties<T extends object>(  object: T): Properties<T>

properties

Properties<T>

Creates a new object containing only the non-function properties from the original object.

@paramobject:  T
The object to extract properties from
@returnsProperties<T>

Description

Creates a new object containing only the non-function properties from the original object.

This function iterates through all enumerable properties of an object and returns a new object containing only those that are not functions.

Usage

const employee = {
  id: 1,
  name: 'John',
  getFullName() { return this.name; },
  calculateSalary() { return 50000; }
};

const dataProps = properties(employee);
// Result: { id: 1, name: 'John' }