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 function assertIAsset<T>(item: IAsset | IReference): item is IAsset { | |
return item.type === "typenavn her"; | |
} |
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 everything from this file | |
export * from "C:/Prosjekter/DEMO2/packages/shared/src/index"; | |
// Export the default export from this file | |
export { default } from "C:/Prosjekter/DEMO2/packages/shared/src/index"; | |
// Export the default export from this file as a named export | |
export { default as Named } from "C:/Prosjekter/DEMO2/packages/shared/src/index"; |
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 testObject = { a: 1, b: 2, c: 3, d: 4, e: 5 }; | |
// Object.entries({}) lets you loop through the properties of the object with access to the key and value of each entry | |
for (const [key, value] of Object.entries(testObject)) { | |
console.log(key, value); // a, 1. b, 2... etc... | |
} | |
const customArray = [ | |
{ key: "a", value: 1 }, | |
{ key: "a", value: 1 }, |
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
async function voidWait(timeToDelay: number): Promise<void> { | |
return new Promise((resolve) => setTimeout(resolve, timeToDelay)); | |
} | |
async function returnWait<T>(timeToDelay: number, returnValue: T): Promise<T> { | |
return new Promise((resolve) => setTimeout(() => resolve(returnValue), timeToDelay)); | |
} |
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
let startTime = Date.now(); | |
const prestand = () => { | |
const result = Date.now() - startTime; | |
startTime = Date.now(); | |
return `${result} ms`; | |
}; | |
let startTime = performance.now(); | |
const prestand2 = () => { | |
const result = performance.now() - startTime; |
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
/** | |
* Construct a type with the properties of T and make the properties K optional. | |
*/ | |
type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>; | |
// Example: | |
type Person = { | |
name: string; | |
age: number; | |
gender: "male" | "female"; |
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
type JsonPrimitives = string | number | boolean | String | Number | Boolean | null; | |
type NonJsonPrimitives = undefined | Function | symbol; | |
type SerializeType<T> = T extends JsonPrimitives | |
? T | |
: T extends NonJsonPrimitives | |
? never | |
: T extends { toJSON(): infer U } | |
? U | |
: T extends [] |
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 urlToTest = new URL("AddUrl"); | |
let query = {}; | |
for ([key, value] of urlToTest.searchParams) { | |
query[key] = value; | |
} | |
console.log({ | |
host: urlToTest.host, | |
query: query, | |
path: urlToTest.pathname, |
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
type Prettify<T> = { | |
[K in keyof T]: T[K]; | |
} & {}; |
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 { defineComponent, ref, watch } from "vue"; | |
const Wow = defineComponent({ | |
props: { | |
limit: { | |
type: Number, | |
required: false, | |
default: 12, | |
}, | |
}, |
OlderNewer