added prototype

This commit is contained in:
Philippe Torrel
2026-08-03 14:46:13 +02:00
parent 831644667e
commit 44428b0495
310 changed files with 49133 additions and 93 deletions

View File

@@ -0,0 +1,19 @@
import fs from 'node:fs';
import { v4 as id } from 'uuid';
console.log(id()); // 97412ca6-c7a8-4868-a49b-3cf4c2258dd8
try {
const data = JSON.parse(fs.readFileSync('../data/products.json', 'utf-8'));
const products = data.map((product, index) => {
return { _id: product._id || id(), position: index + 1, ...product };
});
console.log(products);
fs.writeFileSync('../data/products.json', JSON.stringify(products, null, 2), 'utf-8');
console.log('File modified');
} catch (error) {
console.log(error);
}

View File

@@ -0,0 +1,28 @@
{
"name": "utils",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "utils",
"version": "1.0.0",
"dependencies": {
"uuid": "^14.0.1"
}
},
"node_modules/uuid": {
"version": "14.0.1",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-14.0.1.tgz",
"integrity": "sha512-6ZxzVpzDXDa3bJWaHilVayA+BH/1zmxCJoVgvmqJnid/gPoKHxUrS/aC/T6LGQtNHT+XHG9fXPJB4d+IrU30Ew==",
"funding": [
"https://github.com/sponsors/broofa",
"https://github.com/sponsors/ctavan"
],
"license": "MIT",
"bin": {
"uuid": "dist-node/bin/uuid"
}
}
}
}

View File

@@ -0,0 +1,14 @@
{
"name": "utils",
"version": "1.0.0",
"description": "",
"main": "json-modifier.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"type": "module",
"dependencies": {
"uuid": "^14.0.1"
}
}