I hereby claim:
- I am mhofman on github.
- I am mathieuagoric (https://keybase.io/mathieuagoric) on keybase.
- I have a public key whose fingerprint is 0EFB 233B 5A6C AA0E DE96 972C E07D D96A C72D 83D8
To claim this, I am signing this object:
interface TwoWayWeakMap<K extends object, V> extends WeakMap<K, V> { | |
keysFor(value: V): K[]; | |
} | |
interface TwoWayWeakMapConstructor { | |
new <K extends object = object, V = any>( | |
entries?: readonly [K, V][] | null | |
): TwoWayWeakMap<K, V>; | |
readonly prototype: TwoWayWeakMap<object, any>; | |
} |
export declare class Wrapper<Kind, Value = any> { | |
private kind: Kind; | |
private value: Value; | |
} | |
export interface WrapperRegistry<Kind> extends Function { | |
constructor: WrapperRegistryConstructor; | |
wrap<T>(value: T): Wrapper<Kind, T>; | |
unwrap<T>(wrapped: Wrapper<Kind, T>): T; | |
} |
I hereby claim:
To claim this, I am signing this object:
Promise.allEntries = (entries) => | |
Promise.all(Array.from(entries).map((entry) => Promise.all(entry))); | |
const obj = { | |
foo: Promise.resolve("bar"), | |
}; | |
const resolvedObject = Object.fromEntries( | |
await Promise.allEntries(Object.entries(obj)) | |
); |
All the following has been validated on MacOS Mojave 10.14.6
While there is a command line preference to accept only local VNC connections, that setting still doesn't prevent the daemon from listening to the wildcard address, and advertise the service on Bonjour. I haven't actually tried to see if it restricted anything in modern versions of the operating system, but here it is for reference:
sudo defaults write /Library/Preferences/com.apple.RemoteManagement.plist VNCOnlyLocalConnections -bool yes
const KEYS = 1; | |
const VALUES = 2; | |
const KEYS_VALUES = 3; | |
export default class WeakValueMap { | |
#map = new Map(); | |
#group = new FinalizationGroup((iterator) => { | |
for (const key of iterator) { | |
this.#map.delete(key); | |
} |
function makeObserver(): [Promise<boolean>, FinalizationGroup<any>] { | |
let resolve: (collected: boolean) => void; | |
const collected = new Promise<boolean>(r => (resolve = r)); | |
const finalizationGroup = new FinalizationGroup<any>(items => { | |
// Let's be nice and cleanup | |
[...items]; | |
resolve(true); | |
}); | |
return [collected, finalizationGroup]; | |
} |
let nextId = 0; | |
let weakMap; | |
let savedCallback; | |
function createWeakMap(callback) { | |
weakMap = new WeakMap(); | |
savedCallback = callback; | |
} |
/* Implementation of HTML Timers (setInterval/setTimeout) based on sleep. | |
* | |
* This file is provided under the following terms (MIT License): | |
* Permission is hereby granted, free of charge, to any person obtaining a copy | |
* of this software and associated documentation files (the "Software"), to deal | |
* in the Software without restriction, including without limitation the rights | |
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
* copies of the Software, and to permit persons to whom the Software is | |
* furnished to do so, subject to the following conditions: | |
* |
function taskTurn() { | |
return new Promise(resolve => setTimeout(resolve, 0)); | |
} | |
function makeGcOf(gc, FinalizationGroup) { | |
return async function gcOf(target) { | |
// Avoid creating a closure which may capture target | |
let resolve; | |
const collected = new Promise(r => (resolve = r)); | |
const finalizationGroup = new FinalizationGroup(resolve); | |
finalizationGroup.register(target || {}, 0); |