1.0.5 • Published 3 years ago
get-flat v1.0.5
get-flat
Turn class instances into plain js objects making use of the instance's getters.
Turn this:
class Hat {
private _hatName: string;
constructor(hatName: string) {
this._hatName = hatName;
}
public get hatName() {
return this._hatName;
}
}
Into this:
{
hatName: 'name';
}
By doing this:
import { ObjectSerializer } from 'get-flat';
const serializer = new ObjectSerializer();
const hat = new Hat('name');
const flatHat = serializer.toPlainObject(hat);