The gist version has been deprecated. Moved to https://github.com/graficos-net/html-cleanser and fixed some security issues! Please see instalation section for updates!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script setup lang="ts"> | |
enum VariantEnum { | |
PRIMARY = 'primary', | |
SECONDARY = 'secondary', | |
} | |
// Turn enums into string union types! | |
type TypeFromEnum<T> = T extends `${infer U}` ? U : never; | |
type VariantType = TypeFromEnum<VariantEnum>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// vitest.config.mjs | |
import { defineConfigWithNuxtEnv } from 'vitest-environment-nuxt/config' | |
export default defineConfigWithNuxtEnv({ | |
test: { | |
globals: true, | |
}, | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const quiz = { | |
...{ a: { b: 1, c: 3 }}, | |
...{ a: { b: 2 }} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<p id="one" class="hello">hello world</p> | |
</template> | |
<style scoped> | |
#one { | |
color: blue; | |
} | |
.hello.hello.hello.hello.hello.hello.hello.hello.hello.hello.hello.hello.hello { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Takes a generator function that can yeild async functions. | |
* When the wrapped generator is called again, the previous call will cancel ASAP. | |
* Note: it won't cancel in-flight requests made (see: AbortController) | |
* @param {GeneratorFunction} generator | |
* @see https://dev.to/chromiumdev/cancellable-async-functions-in-javascript-5gp7 | |
* @author Sam Thorogood | |
* @returns {(...args: any[]) => Promise<any>} | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <reference types="jest" /> | |
import { mount } from '@vue/test-utils' | |
import IntersectionComponent from './IntersectionComponent.vue' | |
const mountComponent = props => | |
mount(IntersectionComponent, { | |
propsData: { | |
callback: jest.fn().mockImplementation(isVisible => isVisible), | |
...props |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// `.truncate-1-line` and `truncate-2-lines` | |
@each $lines in (1, 2) { | |
:root .truncate-#{$lines}-line#{if($lines > 1, 's', '')} { | |
display: -webkit-box; | |
overflow: hidden; | |
-webkit-line-clamp: $lines; | |
-webkit-box-orient: vertical; | |
} | |
} |
Cheks if a given URL for an image is available over the net. It uses a simple DOM trick to test it. Be careful as <img src>
can be an XSS attack vector: https://owasp.org/www-community/xss-filter-evasion-cheatsheet
npm i -S gist:b2efa76be5314a332cfcfd1d025f4601
NewerOlder