53 lines
2.3 KiB
TypeScript
53 lines
2.3 KiB
TypeScript
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
|
|
// This file is automatically generated. DO NOT EDIT
|
|
|
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
// @ts-ignore: Unused imports
|
|
import { Create as $Create } from "@wailsio/runtime";
|
|
|
|
/**
|
|
* Map is like a Go map[any]any but is safe for concurrent use
|
|
* by multiple goroutines without additional locking or coordination.
|
|
* Loads, stores, and deletes run in amortized constant time.
|
|
*
|
|
* The Map type is specialized. Most code should use a plain Go map instead,
|
|
* with separate locking or coordination, for better type safety and to make it
|
|
* easier to maintain other invariants along with the map content.
|
|
*
|
|
* The Map type is optimized for two common use cases: (1) when the entry for a given
|
|
* key is only ever written once but read many times, as in caches that only grow,
|
|
* or (2) when multiple goroutines read, write, and overwrite entries for disjoint
|
|
* sets of keys. In these two cases, use of a Map may significantly reduce lock
|
|
* contention compared to a Go map paired with a separate [Mutex] or [RWMutex].
|
|
*
|
|
* The zero Map is empty and ready for use. A Map must not be copied after first use.
|
|
*
|
|
* In the terminology of [the Go memory model], Map arranges that a write operation
|
|
* “synchronizes before” any read operation that observes the effect of the write, where
|
|
* read and write operations are defined as follows.
|
|
* [Map.Load], [Map.LoadAndDelete], [Map.LoadOrStore], [Map.Swap], [Map.CompareAndSwap],
|
|
* and [Map.CompareAndDelete] are read operations;
|
|
* [Map.Delete], [Map.LoadAndDelete], [Map.Store], and [Map.Swap] are write operations;
|
|
* [Map.LoadOrStore] is a write operation when it returns loaded set to false;
|
|
* [Map.CompareAndSwap] is a write operation when it returns swapped set to true;
|
|
* and [Map.CompareAndDelete] is a write operation when it returns deleted set to true.
|
|
*
|
|
* [the Go memory model]: https://go.dev/ref/mem
|
|
*/
|
|
export class Map {
|
|
|
|
/** Creates a new Map instance. */
|
|
constructor($$source: Partial<Map> = {}) {
|
|
|
|
Object.assign(this, $$source);
|
|
}
|
|
|
|
/**
|
|
* Creates a new Map instance from a string or object.
|
|
*/
|
|
static createFrom($$source: any = {}): Map {
|
|
let $$parsedSource = typeof $$source === 'string' ? JSON.parse($$source) : $$source;
|
|
return new Map($$parsedSource as Partial<Map>);
|
|
}
|
|
}
|