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
#! /usr/bin/env node | |
const fs = require('fs'); | |
const slugify = require('slug'); | |
const inquirer = require('inquirer'); | |
const open = require('open'); | |
const pkgDir = require('pkg-dir'); | |
inquirer.registerPrompt('datetime', require('inquirer-datepicker-prompt')); |
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
// See blog post at https://ketuma.com/lessons/typescript-generics | |
// Generics |
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
// See blog post at https://ketuma.com/lessons/typescript-functions | |
// Functions | |
// Fully Typed Function | |
const multiply: (str: string, num: number) => string = function(str: string, num: number): string { | |
return `${str} `.repeat(num).trim() | |
} | |
console.log(multiply('Jake', 3)) // Jake Jake Jake |
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
// See blog post at https://ketuma.com/lessons/typescript-classes | |
//Classes | |
interface IMatrix { | |
width: number | |
height: number | |
content: string[] | |
dimensions: string | |
getElement(x: number, y: number): string | |
setElement(x: number, y: number, value: string): void |
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
// See blog post at https://ketuma.com/lessons/typescript-interfaces | |
//Interfaces | |
interface Account { | |
name: string | |
amount: number | |
accountNumber: 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
// See blog post at https://ketuma.com/lessons/typescript-basic-types | |
//Boolean | |
const isOdd: boolean = true | |
const isEven: boolean = false | |
//Number | |
const fibonacci: number = 34 //decimal | |
const color: number = 0xbada55 //hexadecimal | |
const adder: number = 0b1011 //binary |
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 em($target, $context: $base-font-size) { | |
@if $target == 0 { @return 0 } | |
@return $target / $context + 0em; | |
} | |
$base-font-size: 15px; | |
h1 { | |
font-size: em(21px, 15px); // Outputs 1.4em | |
} |