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 withType<TElement extends { __type: string }, TType extends TElement["__type"]>( | |
elements: TElement[], | |
type: TType | |
): Extract<TElement, { __type: TType }>[] { | |
return elements?.filter(element => element.__type === type) as Extract<TElement, { __type: TType }>[] | |
} | |
export function withoutType<TElement extends { __type: string }, TType extends TElement["__type"]>( | |
elements: TElement[], | |
type: TType |
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 { CleanupResult, InstallResult, PrecacheController } from "workbox-precaching" | |
export class CustomPrecacheController extends PrecacheController { | |
private _debugPrint = false | |
private _isPrecaching = false | |
get isPrecaching() { return this._isPrecaching } | |
private _installResult: InstallResult = undefined |
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
/** | |
* A spine export produces 3 file types- one JSON file and one atlas.txt that maps | |
* any number of PNGs. We know the JSON and atlas paths ahead of time, but not the PNGs. | |
* This method will return a promise that completes when the files are loaded. If the | |
* path is an atlas.txt file, it will wait for the response and read the file contents | |
* in order to start loading the associated PNGs as well. | |
*/ | |
async function loadSpineFiles(event: ExtendableEvent, strategy: Strategy, path: string) { | |
const pending = Array.of<Promise<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
{ | |
"name": "package-name", | |
"version": "0.9.0", | |
"description": "", | |
"main": "dist/index.cjs.js", | |
"module": "dist/index.esm.js", | |
"browser": "dist/index.umd.js", | |
"types": "dist/index.d.ts", | |
"dependencies": { | |
"ms": "^2.1.3" |
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 { createProxyMiddleware } from "http-proxy-middleware" | |
/** | |
* Usage: | |
* ```js | |
* proxyMiddleware("proxy/path", { | |
* target: "https://target.proxy.io", | |
* changeOrigin: 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
--- | |
export type Props = { | |
id?: string | |
assets: { | |
jsonUri: string | |
atlasUri: string | |
skin?: 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 type Lazy<T, TArgs = void> = { | |
isInitialized(): boolean | |
get(args: TArgs): T | |
update(data: T) | |
clear(): Lazy<T> | |
} | |
export const lazy = <T, TArgs = void>(loader: (args: TArgs) => T) => { | |
let initialized = false |
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 ChildAndParent<TParent, TChild> = TParent extends string | |
? `${TParent}.${TChild extends string ? TChild : never}` | |
: TChild; | |
type DotNotation<T, TParent = false> = T extends object | |
? { [K in keyof T]: TParent | DotNotation<T[K], ChildAndParent<TParent, K>> }[keyof T] | |
: TParent | |
type Foo = DotNotation<{ | |
a: "hello" | |
b: "darkness" |
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 ParamBuilder<TArgs extends Record<string, any>, TReturn> = { | |
[K in keyof TArgs]: (arg: TArgs[K]) => ParamBuilder<Omit<TArgs, K>, TReturn>; | |
} & (keyof TArgs extends never ? { call(): TReturn } : {}) | |
function builderFor<TArgs extends object, TReturn>(fn: (args: TArgs) => TReturn) { | |
const args: TArgs = {} as unknown as TArgs; | |
return new Proxy({}, { | |
get(self, prop) { | |
if (prop === "call") { |
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 androidx.annotation.ColorRes | |
import androidx.appcompat.app.AppCompatActivity | |
import androidx.core.view.WindowCompat | |
import androidx.core.view.WindowInsetsCompat | |
import androidx.core.view.WindowInsetsControllerCompat | |
import com.sample.app.R | |
private val statusAndNavBarType = | |
WindowInsetsCompat.Type.statusBars() or WindowInsetsCompat.Type.navigationBars() |
NewerOlder