code

Web Check
All-in-one OSINT and security tool
const store = ({
// Create a state with the reactive function we imported previously, this will manage the reactivity for us
state: reactive({
count: null
// If this is null is for the example,
// of course you can initialize the
// counter with 0 directly
}),
// This section will handle the getters
getters: {
getCount() {
return store.state.count
}
},
// This section will manage the changes into the state
mutations: {
incrementCount() {
store.state.count++
}
},
// This section will manage the actions needed for our store
actions: {
initializeCount() {
store.state.count = 0
}
}
})
Store
const token = `${Math.floor(Math.random() * Number.MAX_SAFE_INTEGER).toString(36)}${Math.floor(Math.random() * Number.MAX_SAFE_INTEGER).toString(36)}${Math.floor(Math.random() * Number.MAX_SAFE_INTEGER).toString(36)}`;
Generate random token
/**
* List of types with different properties
*/
type Animal =
| {
name: "cat";
hair: "long" | "short";
}
| {
name: "dog";
hair: "long" | "short";
}
| {
name: "fish";
scale: "blue" | "grey";
};
/**
* Type of animal name
*/
type AnimalName = Animal["name"];
/**
* Type of animal with the property hair
*/
type AnimalWithHair = Animal extends infer Parent
? // biome-ignore lint/suspicious/noExplicitAny: <explanation>
Parent extends { hair: any }
? Parent
: never
: never;
/**
* Hair type for animal with this name
*/
type AnimalHair<
Name extends AnimalName,
CurrentAnimal = Animal extends infer Parent
? Parent extends { name: Name }
? Parent
: never
: never,
Method = CurrentAnimal extends AnimalWithHair ? CurrentAnimal["hair"] : never,
> = Method;
/**
* Random animal
*/
const animal = [
{ name: "cat", hair: "short" },
{ name: "dog", hair: "short" },
{ name: "fish", scale: "blue" },
][Math.floor(3 * Math.random())];
/**
* Test if the animal has same properties with Typescript arguments autocompletion
*/
function testAnimal<Name extends AnimalName>(
name: Name,
hair?: AnimalHair<Name>,
) {
return (
name === animal.name &&
(hair ? hair === (animal as AnimalWithHair).hair : true)
);
}
testAnimal("fish");
testAnimal("cat", "long");
Deep property inference

monitors