mirror of
https://github.com/swc-project/swc.git
synced 2024-12-24 22:22:34 +03:00
bbaf619f63
swc_bundler: - [x] Fix wrapped esms. (denoland/deno#9307) - [x] Make test secure.
21 lines
508 B
TypeScript
21 lines
508 B
TypeScript
// Loaded from https://deno.land/x/denodb@v1.0.18/lib/helpers/results.ts
|
|
|
|
|
|
import type { ModelSchema } from "../model.ts";
|
|
import type { Values } from "../data-types.ts";
|
|
|
|
/** Transform a plain record object to a given model schema. */
|
|
export function formatResultToModelInstance(
|
|
Schema: ModelSchema,
|
|
fields: Values,
|
|
) {
|
|
const instance = new Schema();
|
|
|
|
for (const field in fields) {
|
|
(instance as any)[Schema.formatFieldToClient(field) as string] =
|
|
fields[field];
|
|
}
|
|
|
|
return instance;
|
|
}
|