generateMemberships.js 683 B

12345678910111213141516171819202122232425
  1. /* eslint-disable @typescript-eslint/no-var-requires */
  2. const faker = require('faker')
  3. const { saveToFile, randomRange } = require('./utils')
  4. const OUTPUT_FILENAME = 'memberships.json'
  5. const MEMBERSHIPS_COUNT = 4
  6. let nextMemberId = 0
  7. const generateMembership = () => {
  8. const handleWordsCount = randomRange(1, 4)
  9. const aboutWordsCount = randomRange(0, 30)
  10. return {
  11. id: (nextMemberId++).toString(),
  12. handle: faker.lorem.words(handleWordsCount),
  13. about: faker.lorem.words(aboutWordsCount),
  14. }
  15. }
  16. const main = async () => {
  17. const memberships = Array.from({ length: MEMBERSHIPS_COUNT }, generateMembership)
  18. await saveToFile(memberships, OUTPUT_FILENAME)
  19. }
  20. main()