1.0.1 • Published 1 year ago

two-truths v1.0.1

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

I built this app for my website so that visitors can get to know me, and it can easily be tailored to yours

just import it and pass your own data through props:

<script>
	import TwoTruths from 'two-truths'
	const promise = async () => await fetch('/some/data').then(res => res.json()) 
</script>


<TwoTruths getTruths={promise}/>

###props:

getTruths - an asynchronous function that returns an array of objects in the following data structure:

{
	"id": "string",
	"sentence": "string",
	"is_true": "string" // this value should be 1 if the sentence is true and 0 if it's a lie
	{/* is_true is setup this way for easy integration with MySql databases like postgresql
		a BIT value in a postgres table will be returned by the Node.js pg module as "1" or "0" */} 
}

this function runs when the app is mounted and the returned values are used as the game data there are no constraints on the length of the array, so be sure that you are returning 3 values (two truths and one lie), so that the rules programmed into the UI are properly implemented

the function is simply run again to reset the game when the replay button is clicked here is an example of a Node.js endpoint that returns three random values from a postgres table of truths and lies

1.0.1

1 year ago

1.0.0

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago

0.0.0

1 year ago