r37r0m0d3l/vicis

View on GitHub
src/core/transform/transform.ts

Summary

Maintainability
A
1 hr
Test Coverage
import { IObject } from "../../interface/common/IObject";
import { ITransform } from "../../interface/config/ITransform";

import { objectIsEmpty } from "../../util/object/is/empty";

import { transformConfig } from "./transformConfig";
import { transformData } from "./transformData";

/**
 * @name transform
 * @param {Object} data
 * @param {Object.<string, function>=} propertyValueTransformWith
 * @returns {Object}
 */
export function transform(
  data: IObject,
  propertyValueTransformWith: ITransform = {},
): IObject {
  const config = transformConfig(propertyValueTransformWith);
  if (objectIsEmpty(config)) {
    return data;
  }
  return transformData(config, data);
}