Skip to content

Commit

Permalink
cohernet name
Browse files Browse the repository at this point in the history
  • Loading branch information
aeltorio committed Nov 3, 2024
1 parent c761f1c commit 192c14c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
14 changes: 7 additions & 7 deletions username_generator/src/components/GeneratorCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
</div>
<div class="px-6 pt-4 pb-2">
<button class="m-1 text-sm bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded"
@click="firstName = normalize(randomFirstnamePonderated(firstNames,preComputedTotalFirstnames))">Change first name</button>
@click="firstName = normalize(randomFirstnamePonderated(FirstNames,preComputedTotalFirstnames))">Change first name</button>
<button class="m-1 text-sm bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded"
@click="lastName = normalize(randomLastnamePonderated(lastNames,preComputedTotalLastnames))">Change last name</button>
@click="lastName = normalize(randomLastnamePonderated(LastNames,preComputedTotalLastnames))">Change last name</button>
<button class="m-1 text-sm bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded"
@click="generateUsername">Generate username</button>
</div>
Expand All @@ -20,20 +20,20 @@

<script setup lang="ts">
import { onMounted, ref } from 'vue';
import { firstNames, lastNames, normalize, precomputeCumulativeSums, randomFirstnamePonderated, randomLastnamePonderated } from '../generator';
import { FirstNames, LastNames, normalize, precomputeCumulativeSums, randomFirstnamePonderated, randomLastnamePonderated } from '../generator';
const firstName = ref('');
const lastName = ref('');
const preComputedTotalFirstnames = ref(0);
const preComputedTotalLastnames = ref(0);
function generateUsername() {
preComputedTotalFirstnames.value = precomputeCumulativeSums(firstNames.firstnames);
preComputedTotalLastnames.value = precomputeCumulativeSums(lastNames.lastnames);
preComputedTotalFirstnames.value = precomputeCumulativeSums(FirstNames.firstnames);
preComputedTotalLastnames.value = precomputeCumulativeSums(LastNames.lastnames);
console.log(`preComputedTotalFirstnames: ${preComputedTotalFirstnames.value}`);
console.log(`preComputedTotalLastnames: ${preComputedTotalLastnames.value}`);
firstName.value = normalize(randomFirstnamePonderated(firstNames,preComputedTotalFirstnames.value));
lastName.value = normalize(randomLastnamePonderated(lastNames,preComputedTotalLastnames.value));
firstName.value = normalize(randomFirstnamePonderated(FirstNames,preComputedTotalFirstnames.value));
lastName.value = normalize(randomLastnamePonderated(LastNames,preComputedTotalLastnames.value));
}
onMounted(() => {
generateUsername();
Expand Down
4 changes: 2 additions & 2 deletions username_generator/src/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import _firstNames from './../../firstnames.json';
import _lastNames from './../../lastnames.json';

// Exporting the imported data with explicit typecasting to ensure data integrity
export const firstNames = _firstNames as Firstnames;
export const lastNames = _lastNames as Lastnames;
export const FirstNames = _firstNames as Firstnames;
export const LastNames = _lastNames as Lastnames;

export interface Firstname {
firstname: string;
Expand Down

0 comments on commit 192c14c

Please sign in to comment.