- Location - The location of the application. Usually just a URL, but the location can contain multiple pieces of information that can be used by an app
- pathname - The "file/directory" portion of the URL, like
invoices/123
- search - The stuff after
?
in a URL like/assignments?showGrades=1
. - query - A parsed version of search, usually an object but not a standard browser feature.
- hash - The
#
portion of the URL. This is not available to servers inrequest.url
so its client only. By default it means which part of the page the user should be scrolled to, but developers use it for various things. - state - Object associated with a location. Think of it like a hidden URL query. It's state you want to keep with a specific location, but you don't want it to be visible in the URL.
- pathname - The "file/directory" portion of the URL, like
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
/** | |
* @flow | |
*/ | |
import * as React from "react"; | |
import { unstable_createResource } from "react-cache"; | |
import * as Scheduler from "scheduler"; | |
import { StorageArea } from "std:kv-storage"; | |
// Creates a ref that tracks the latest value of the argument passed to it |
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
// NOTE: code now moved to https://github.com/tycho01/typical | |
// older revision left here, but it no longer runs well in TS Playground | |
export type Obj<T> = { [k: string]: T }; | |
export type NumObj<T> = { [k: number]: T }; | |
// export type List = ArrayLike; // no unapplied generic types :( | |
export type List<T> = ArrayLike<T>; | |
// progress: https://github.com/Microsoft/TypeScript/issues/16392 | |
export function force<T, V extends T>() {} |
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
interface TypedArray { | |
readonly length : number; | |
readonly [n: number]: number; | |
BYTES_PER_ELEMENT : number; | |
set(n : ArrayLike<number>, offset : number) : void; | |
} | |
interface TypedArrayConstructor<T extends TypedArray> { | |
new (buffer: ArrayBuffer, byteOffset?: number, length?: number): T; | |
} |
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
// Create a Promise that resolves after ms time | |
var timer = function(ms) { | |
return new Promise(resolve => { | |
setTimeout(resolve, ms); | |
}); | |
}; | |
// Repeatedly generate a number starting | |
// from 0 after a random amount of time | |
var source = async function*() { |
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
There is no way to store an empty object/array/null value. | |
There are also no actual arrays. Array values get stored as objects with integer keys. | |
(If all keys are integers, it will be returned as an array.) | |
Basically, it's one giant tree of hashes with string keys. | |
Simply write a value to any location, and the intermediary locations will automatically come into existance. | |
── Classes ── | |
DataSnapshot : Container for a subtree of data at a particular location. |
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
// Here is a function that I use all the time when creating public | |
// async APIs in JavaScript: | |
const resolvePromise = (promise, callback) => { | |
if (callback) | |
promise.then(value => callback(null, value), callback) | |
return promise | |
} | |
// Sometimes I like to use callbacks, but other times a promise is |
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
module Reader where | |
type Reader ctx a = Reader (ctx -> a) | |
unit: a -> Reader any a | |
unit x = | |
Reader (\_ -> x) |
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 I = x => x | |
const K = x => y => x | |
const A = f => x => f (x) | |
const T = x => f => f (x) | |
const W = f => x => f (x) (x) | |
const C = f => y => x => f (x) (y) | |
const B = f => g => x => f (g (x)) | |
const S = f => g => x => f (x) (g (x)) | |
const S_ = f => g => x => f (g (x)) (x) | |
const S2 = f => g => h => x => f (g (x)) (h (x)) |
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
Lesson 1 - Iterations | |
- BinaryGap - https://codility.com/demo/results/trainingU2FQPQ-7Y4/ | |
Lesson 2 - Arrays | |
- OddOccurrencesInArray - https://codility.com/demo/results/trainingFN5RVT-XQ4/ | |
- CyclicRotation - https://codility.com/demo/results/trainingSH2W5R-RP5/ | |
Lesson 3 - Time Complexity | |
- FrogJmp - https://codility.com/demo/results/training6KKWUD-BXJ/ | |
- PermMissingElem - https://codility.com/demo/results/training58W4YJ-VHA/ |
NewerOlder