This file contains hidden or 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
// TS Playground: https://www.typescriptlang.org/play?#code/JYOwLgpgTgZghgYwgAgDIHsDmoBi6oC2OwEANgCYDOyA3gFDLICul0IcBEAXMpWFKEwNkABziVKAd3zkA-Dz4CQmANx0AvnTpgAniJR5CxMlQA8AFQB8yALy1hAaigQ45dCFI7kAbQDWEL1Bkfx10GGRzAF0AWnlggI0tGCYQBDBgd2ZWYwoAOQ4ISgtLAAoASh5DIhIKIqt7RmcwJigQZBAISWQABSh0AA8dEpp1ZHFkKpyzKwAaBsZkTAgwEoB9OZE+-ShdMvmF5CaWts30bd1hRk0rssS6BHc+ZBga8nzOajsWCCn3wtMMNgQJNXpRSrcDsgAPRQ5AAPVkSVef0oADpvq0CpdIYwYfDES8TCjUWIJNIoORsTi8Qi6IS8gU0aSyTIqZCaYj7o90KQIKjSFgSvS3oz0axMZxbnQ8QBZOAifTkCJ6FAy9DkYCEqCULjS2EACzAYBEOphknNqNCTGaACM+Q8CFDJHAwAh9bIAG42AAMAC9MAB1dCrTAgX0ANQAkkA | |
interface LoginFormFields { | |
username: string | |
password?: string; | |
} | |
type FormFields<T> = { | |
// Mapped Type Modifiers: | |
// https://www.youtube.com/watch?v=0zgWo_gnzVI |
This file contains hidden or 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 {placeholderHasQueryParam, processServerUrl, processPlaceholderUrl} from './layout-service-factory'; | |
/** | |
* @jest-environment node | |
*/ | |
jest.mock('@sitecore-jss/sitecore-jss-nextjs', () => ({ | |
getPublicUrl: jest.fn().mockReturnValue('http://dev.url'), | |
})); |
This file contains hidden or 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 React from "react"; | |
import { useImmer } from "use-immer"; | |
function useProviderValue() { | |
const [moved, setMoved] = React.useState(false); | |
const [point, setPoint] = useImmer<{ | |
x: number; | |
y: number; | |
}>({ x: 0, y: 0 }); // using immer to illustrate that you can easily derive setPoint type instead of writing types for Context manually | |
const value = React.useMemo( |
This file contains hidden or 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 const checkPDFEncryption = (file: Blob): Promise<boolean> => { | |
const allTrailerOccurrences = (source: string, search: string) => { | |
const trailers = []; | |
// TODO: Reverse the search as trailers should appear at the end of the file according to the spec. | |
for (let i = 0; i < source.length; ++i) { | |
if (source.substring(i, i + search.length) === search) { | |
trailers.push(i); | |
} | |
} |
This file contains hidden or 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
Suburb | Lat | Lng | |
---|---|---|---|
Alexander Heights | -31.8269026 | 115.8671293 | |
Alfred Cove | -32.0318604 | 115.8181396 | |
Alkimos | -31.6253527 | 115.6899207 | |
Anketell | -32.2179086 | 115.8593099 | |
Applecross | -32.0116062 | 115.8387269 | |
Ardross | -32.0221019 | 115.8353491 | |
Armadale | -32.1473012 | 116.0128764 | |
Ascot | -31.9354582 | 115.9297299 | |
Ashby | -31.7331506 | 115.7993996 |
This file contains hidden or 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
// add to blockContent array | |
{ | |
type: 'faqSection', | |
}, |
This file contains hidden or 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
// Typed object keys | |
export const objectKeys = Object.keys as <T>(o: T) => (Extract<keyof T, string>)[]; |
This file contains hidden or 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 isEqualArray(a, b) { | |
if (a === b) return true | |
if (a == null || b == null) return a !== a && b !== b | |
if (a.length !== b.length) return false | |
const aHasB = a.every(aValue => b.includes(aValue)) | |
const bHasA = b.every(bValue => a.includes(bValue)) | |
return aHasB && bHasA | |
} |
This file contains hidden or 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 fallbackImage(el) { | |
if (el.hasAttribute('data-fallback-url')) { | |
el.onerror = null; // resetting the error so avoid an endless loop | |
el.src = el.getAttribute('data-fallback-url'); // update the src | |
el.alt = el.getAttribute('data-fallback-alt') || '' // update the `alt` attribute for a11y | |
} | |
} |
NewerOlder