Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

wordle-cli

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wordle-cli - npm Package Compare versions

Comparing version 1.1.3 to 1.1.4

32

bin/functions.js

@@ -6,15 +6,35 @@ const fs = require('fs')

const formatWord = (word) => word.toUpperCase().split('')
let wordsBuffer = fs.readFileSync(path.join(__dirname, 'words.json'))
let words = JSON.parse(wordsBuffer)
const get = (date = Date.UTC(new Date().getFullYear(), new Date().getMonth(), new Date().getDate()), random) => {
if (random) {
return words[Math.floor(Math.random() * words.length)].toUpperCase().split('')
const get = (options) => {
// Get user specified word
if (options.word) {
return {
wordOfTheDay: formatWord(options.word),
gameId: false,
}
}
// Get random word
if (options.random) {
const gameId = Math.floor(Math.random() * words.length)
return {
wordOfTheDay: formatWord(words[gameId]),
gameId,
}
}
// Get word for specified date
const date = options.date || Date.UTC(new Date().getFullYear(), new Date().getMonth(), new Date().getDate())
const diff = new Date(date) - new Date(Date.UTC(2021, 5, 19))
const index = Math.floor(diff / 864e5)
return words[index].toUpperCase().split('')
const gameId = Math.floor(diff / 864e5)
return {
wordOfTheDay: formatWord(words[gameId]),
gameId,
}
}

@@ -21,0 +41,0 @@

3

bin/getOptions.js

@@ -37,5 +37,2 @@ const getOptions = () => {

// Reformat Word option
if (options.word) options.word = options.word.toUpperCase().split('')
return options

@@ -42,0 +39,0 @@ }

@@ -12,3 +12,3 @@ #! /usr/bin/env node

const options = getOptions()
const wordOfTheDay = options.word || word.get(options.date, options.random)
const { wordOfTheDay, gameId } = word.get(options)
const guessRegex = new RegExp(`^[a-z]{${wordOfTheDay.length}}$`, 'i')

@@ -98,3 +98,3 @@

if (gameWon) {
messages.youWon()
messages.youWon(gameId, {unlimited: options.unlimited, currentRound, rounds})
} else {

@@ -101,0 +101,0 @@ console.log('Game over! The word was ' + wordOfTheDay.join(''))

@@ -17,20 +17,32 @@ module.exports = {

},
youWon() {
console.log(`
youWon(gameId, rounds) {
let stats
if (gameId && !rounds.unlimited) {
stats = `worlde #${gameId} ${rounds.currentRound}/${rounds.rounds}`
} else if (gameId) {
stats = ` worlde #${gameId} `
} else if (!rounds.unlimited) {
stats = ` worlde ${rounds.currentRound}/${rounds.rounds} `
} else {
stats = ` `
}
console.log(`
_____________________________
/ \\ \\
| | |
\\_| |
| CONGRATULATIONS |
\\_| CONGRATULATIONS |
| ${stats} |
| |
| ___________ |
| '._==_==_=_.' |
| .-\\: /-. |
| | (|:. |) | |
| '-|:. |-' |
| \\::. / |
| '::. .' |
| ) ( |
| _.' '._ |
| '"""""""' |
| \x1b[33m ___________ \x1b[0m |
| \x1b[33m '._==_==_=_.' \x1b[0m |
| \x1b[33m .-\\: /-. \x1b[0m |
| \x1b[33m | (|:. |) | \x1b[0m |
| \x1b[33m '-|:. |-' \x1b[0m |
| \x1b[33m \\::. / \x1b[0m |
| \x1b[33m '::. .' \x1b[0m |
| \x1b[33m ) ( \x1b[0m |
| \x1b[33m _.' '._ \x1b[0m |
| \x1b[33m '"""""""' \x1b[0m |
| |

@@ -37,0 +49,0 @@ | ________________________|___

{
"name": "wordle-cli",
"version": "1.1.3",
"version": "1.1.4",
"description": "CLI interpretation of the game Wordle",

@@ -5,0 +5,0 @@ "main": "bin/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc