How to use the class-transformer.classToPlainFromExist function in class-transformer

To help you get started, we’ve selected a few class-transformer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nestjsx / crud / packages / crud / src / interceptors / crud-response.interceptor.ts View on Github external
protected transform(dto: any, data: any) {
    if (!isObject(data) || isFalse(dto)) {
      return data;
    }

    if (!isFunction(dto)) {
      return data.constructor !== Object ? classToPlain(data) : data;
    }

    return data instanceof dto
      ? classToPlain(data)
      : classToPlain(classToPlainFromExist(data, new dto()));
  }