Skip to content

Instantly share code, notes, and snippets.

View gaetanlegac's full-sized avatar

Gaëtan Le Gac gaetanlegac

View GitHub Profile
@gaetanlegac
gaetanlegac / deepContains.ts
Last active October 20, 2021 14:17
Deeply check if a HTML element is contained in one of the provided HTML elements.
type ElementOrSelector = HTMLElement | string;
export const deepContains = (
parents: ElementOrSelector | ElementOrSelector[],
children: HTMLElement
): boolean => {
if (!Array.isArray(parents))
parents = [parents];
let node: HTMLElement | null = children;
@gaetanlegac
gaetanlegac / with.d.ts
Last active September 28, 2021 08:25
Get object type with required and/or additionnal fields
declare type With<
TObject,
TRequired extends (keyof TObject) | {[key in keyof TObject]?: any},
TAdditionnal extends {[key: string]: any} = {}
> = (
Omit<TObject, TRequired extends (keyof TObject) ? TRequired : keyof TRequired>
&
(TRequired extends (keyof TObject) ? Required<Pick<TObject, TRequired>> : TRequired)
&
TAdditionnal
// Quelques déclarations ...
export default {
context: ROOT_DIR,
name: 'server',
target: 'node',
mode: 'development',
import { Model } from 'sequelize';
import { Utilisateur, Contenu, Publicite } from '@/serveur/modeles';
export default class Event extends Model {
public id!: number;
public date!: Date;
public type!: number;
public utilisateur_id!: number;