1.0.2 • Published 1 year ago

generate-product v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

generateProduct Documentation

Overview

The generateProduct function is used to generate random product data and save it to a JSON file. It takes a single parameter total, which specifies the number of products to generate.

Syntax

generateProduct(total)

Parameters

  • total: The number of products to generate. Must be a positive integer.

Return Value

An array of objects representing the generated products. Each object contains the following properties:

  • id: The unique identifier of the product.
  • name: The name of the product.
  • price: The price of the product in Indonesian Rupiah (IDR).
  • category: The category of the product.
  • priceFormatted: The formatted price of the product in Indonesian Rupiah (IDR).

Usage

import { generateProduct } from './path/to/generateProduct.js';

// Generate 10 products
const products = generateProduct(10);

Example

import { generateProduct } from './path/to/generateProduct.js';

// Generate 5 products
const products = generateProduct(5);

console.log(products);
// Output:
// [
//   {
//     id: 1,
//     name: 'Product 1',
//     price: 87,
//     category: 'Electronics',
//     priceFormatted: 'Rp 87'
//   },
//   {
//     id: 2,
//     name: 'Product 2',
//     price: 55,
//     category: 'Clothing',
//     priceFormatted: 'Rp 55'
//   },
//   ...
// ]

File Output

The generated product data will be saved to a JSON file named products.json.

Error Handling

If an error occurs while writing the file, an error message will be logged to the console.

Lisensi

MIT

tasteless-blue-cariboutasteless-fuchsia-bobolinksystematic-aquamarine-constrictorsystematic-chocolate-peafowlsystematic-copper-pigeontall-indigo-tahrsymbolic-lime-quokkaterrible-aqua-aphidwhole-blue-tarantulawhole-brown-larkwhole-coral-earwigwhole-indigo-cobrawide-brown-miteweekly-indigo-reptileweekly-orange-galliformweekly-plum-skinkweekly-scarlet-krillwittering-olive-lampreywily-amethyst-chinchillawise-emerald-lemmingwonderful-brown-macawwooden-olive-hedgehogwillowy-green-woodpeckerwise-ivory-tarsierwise-moccasin-fireflywispy-moccasin-salamanderwispy-tomato-reptilevulnerable-moccasin-centipedewandering-brown-tickwandering-fuchsia-badgerwell-chocolate-mandrillwell-pink-rhinoceroswet-blue-grasshopperwet-blue-wildfowlwestern-turquoise-ravenwestern-emerald-pumawestern-peach-wallabywee-aqua-galliformweird-emerald-apeworking-indigo-aspworried-tomato-opossumworthwhile-olive-shrewworthy-lime-lionworking-magenta-crawdadwild-tomato-crowwild-peach-mitewilful-brown-heronwilful-plum-chinchillawilful-red-constrictorwilling-lavender-hedgehogwilling-tan-gorillawrong-silver-butterflywrong-coffee-wildebeestxenial-bronze-horsexenial-harlequin-dogxeric-aqua-camelxeric-salmon-fishxenophobic-beige-krillxenophobic-pink-donkeyxenophobic-teal-takinxenacious-copper-sharktechnological-maroon-ptarmigantechnological-orange-fowlteenage-bronze-hummingbirdteenage-sapphire-pigsuperior-crimson-fishsuperb-tan-guineafowlstable-fuchsia-quailstable-ivory-guppystable-maroon-skinkstable-orange-finchstandard-blue-clamsufficient-amber-llamasufficient-indigo-pythonsudden-scarlet-antlionstatic-cyan-apesporting-gray-perchspotless-amber-lynxspotless-magenta-whippetspotless-purple-ptarmiganspotty-peach-oxspontaneous-harlequin-blackbirdspontaneous-orange-carpspontaneous-sapphire-warblerspecial-teal-owlspecial-beige-quokkasplendid-turquoise-peafowlspatial-black-heronspecific-teal-jaguarspecific-amethyst-wildfowlspiritual-magenta-pigspiritual-tomato-vicunasticky-apricot-bandicootsticky-green-guanacostormy-maroon-termitestormy-violet-dingostormy-black-lousesteady-yellow-slugstraightforward-plum-guanacostrange-scarlet-pony
1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago