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.0.1 to 1.0.2

bin/validWords.json

19

bin/getWord.js
const fs = require('fs')
const path = require('path')
let buffer = fs.readFileSync(path.join(__dirname, 'words.json'))
let words = JSON.parse(buffer)
let wordsBuffer = fs.readFileSync(path.join(__dirname, 'words.json'))
let words = JSON.parse(wordsBuffer)
const getWord = (date = new Date(),random) => {
let validWordsBuffer = fs.readFileSync(path.join(__dirname, 'validWords.json'))
let validWords = JSON.parse(validWordsBuffer)
if(random) {
const validateWord = (word) => {
if (words.includes(word) || validWords.includes(word)) {
return true
}
}
const getWord = (date = new Date(), random) => {
if (random) {
return words[Math.floor(Math.random() * words.length)].toUpperCase().split('')

@@ -17,5 +25,4 @@ }

return words[index].toUpperCase().split('')
}
module.exports = getWord
module.exports = { getWord, validateWord }
#! /usr/bin/env node
const { createInterface } = require('readline')
const getWord = require('./getWord')
const { getWord, validateWord } = require('./getWord')
const getOptions = require('./getOptions')

@@ -31,2 +31,8 @@ const showWord = require('./showWord')

return
} else if (!validateWord(input.toLowerCase())) {
console.log(`\n${input.toUpperCase()} is not a valid word!\n`)
round()
return
} else if (!options.unlimited) {
currentRound++
}

@@ -82,4 +88,3 @@

// Start new round or end game
if (currentRound < rounds - 1 && !gameWon) {
if (!options.unlimited) currentRound++
if (currentRound < rounds && !gameWon) {
round()

@@ -103,3 +108,3 @@ } else {

// Start game
if(options.help) {
if (options.help) {
messages.title()

@@ -106,0 +111,0 @@ messages.help()

@@ -0,1 +1,12 @@

const formattingCodes = {
green: [30, 42],
yellow: [30, 43],
none: [1, 37, 40],
reset: [0],
}
const format = (color = 'reset') => `\x1b[${formattingCodes[color].join(';')}m`
const endTile = () => format() + ' '
const insertSpaces = (num) => new Array(num + 1).join(' ')
const showWord = (result) => {

@@ -5,26 +16,10 @@ let topBottom = ''

result.forEach((item) => {
switch (item.color) {
case 'green':
topBottom += `\x1b[30;42m \x1b[0m `
middle += `\x1b[30;42m ${item.letter} \x1b[0m `
break
case 'yellow':
topBottom += `\x1b[43;30m \x1b[0m `
middle += `\x1b[43;30m ${item.letter} \x1b[0m `
break
default:
topBottom += `\x1b[1;30;37m \x1b[0m `
middle += `\x1b[1;30;37m ${item.letter} \x1b[0m `
break
}
result.forEach(({ color, letter }) => {
topBottom += format(color) + insertSpaces(7) + endTile()
middle += format(color) + insertSpaces(3) + letter + insertSpaces(3) + endTile()
})
console.log('\n')
console.log(topBottom)
console.log(middle)
console.log(topBottom)
console.log('\n')
console.log(`\n\n${topBottom}\n${middle}\n${topBottom}\n\n`)
}
module.exports = showWord
{
"name": "wordle-cli",
"version": "1.0.1",
"version": "1.0.2",
"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