title | description | date | categories | published | tags | image | featured | |
---|---|---|---|---|---|---|---|---|
TypeScript For Beginners |
In this post, I want to dive into the basics of TypeScript. We’re going to learn primitives, interfaces, enums, classes and a lot more. Sit back, grab your editor and let's get started with learning TypeScript. |
2020-04-07T03:19:03.683Z |
true |
|
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
function isYouTubeUrl(url: string): boolean { | |
const regex = /^(?:(?:https?:)?\/\/)?(?:www\.)?(?:m\.)?youtu(?:\.be\/|be\.com\/watch\?v=|be\.com\/embed\/|be\.com\/v\/|be\.com\/playlist\?list=|be\.com\/.+\/.+\/.+\/.+\/.+\/.)([A-Za-z0-9_-]{11})(?:\S+)?/; | |
return regex.test(url); | |
} |
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
node_modules/@supabase/functions-js/dist/module/types.d.ts:1:36 - error TS2304: Cannot find name 'fetch'. | |
1 export declare type Fetch = typeof fetch; | |
~~~~~ | |
node_modules/@supabase/functions-js/dist/module/types.d.ts:38:12 - error TS2304: Cannot find name 'File'. | |
38 body?: File | Blob | ArrayBuffer | FormData | ReadableStream<Uint8Array> | Record<string, any> | string; | |
~~~~ |
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
export default { | |
css: [ | |
'node_modules/lite-youtube-embed/src/lite-yt-embed.css' | |
] | |
} |
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
import 'lite-youtube-embed' |
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
export default { | |
plugins: ['@/plugins/youtube.client.js'] | |
} |
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> | |
<div class="youtube"> | |
<lite-youtube | |
:videoid="id" | |
:playlabel="label" | |
/> | |
</div> | |
</template> | |
<script> | |
export default { |
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
<youtube id="5SR_NUdg7t8"></youtube> |
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 form = document.querySelector("#csvForm"); | |
const csvFileInput = document.querySelector("#csvInput"); | |
const textArea = document.querySelector("#csvResult"); | |
form.addEventListener("submit", function (e) { | |
e.preventDefault(); | |
const file = csvFileInput.files[0]; | |
const reader = new FileReader(); | |
reader.onload = function (e) { | |
const csvArray = csvToArr(e.target.result, ","); | |
textArea.value = JSON.stringify(csvArray, null, 4); |
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
function csvToArr(stringValue) { | |
// Add logic | |
const [keys, ...rest] = stringVal | |
.trim() | |
.split("\n") | |
.map((item) => item.split(',')); | |
const formedArr = rest.map((item) => { | |
const object = {}; | |
keys.forEach((key, index) => (object[key] = item.at(index))); |