mirror of
https://github.com/swc-project/swc.git
synced 2024-12-25 14:43:33 +03:00
bbaf619f63
swc_bundler: - [x] Fix wrapped esms. (denoland/deno#9307) - [x] Make test secure.
18 lines
498 B
TypeScript
18 lines
498 B
TypeScript
// Loaded from https://deno.land/x/dndb@0.2.4/src/methods/insert.js
|
|
|
|
|
|
import { writeFile } from '../storage.ts';
|
|
import { v1 } from "https://deno.land/std/uuid/mod.ts";
|
|
|
|
export default async (filename ,data) => {
|
|
if(Array.isArray(data)) {
|
|
data.forEach(async o => {
|
|
o._id = o._id || v1.generate();
|
|
await writeFile(filename, o);
|
|
});
|
|
} else {
|
|
data._id = data._id || v1.generate();
|
|
await writeFile(filename, data)
|
|
}
|
|
return data;
|
|
} |