Skip to content

Commit

Permalink
remove faker dependency, due to huge package
Browse files Browse the repository at this point in the history
  • Loading branch information
jojoee committed Nov 7, 2023
1 parent 2a879eb commit 1b0e34c
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
localStorage.debug = '*'

const debugSocket = require('debug')('main:socket')
const faker = require('faker')
const config = require('./config')
const Action = require('./module/Action')
const util = require('./static/util')
Expand Down Expand Up @@ -52,12 +51,20 @@ $messageForm.submit((e) => {
})

$spam.click((e) => {
const message = faker.lorem.sentence()
const message = generateLoremSentence()
send(eventKey.message, message)
})

// ================================================================ Function

function generateLoremSentence() {
const loremText = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed in justo in leo pretium pulvinar auctor id libero. Maecenas varius volutpat arcu eget egestas. Fusce at dui at risus cursus accumsan. Aenean sagittis pellentesque justo id fringilla.'
const sentences = loremText.match(/[^\.!\?]+[\.!\?]+/g);
const randomIndex = Math.floor(Math.random() * sentences.length)

return sentences[randomIndex].trim()
}

/**
* @param {string} key
* @param {string} data
Expand Down

0 comments on commit 1b0e34c

Please sign in to comment.