/** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. * This code may only be used under the BSD style license found at * http://polymer.github.io/LICENSE.txt * The complete set of authors may be found at * http://polymer.github.io/AUTHORS.txt * The complete set of contributors may be found at * http://polymer.github.io/CONTRIBUTORS.txt * Code distributed by Google as part of the polymer project is also * subject to an additional IP rights grant found at * http://polymer.github.io/PATENTS.txt */ /** * This is a simple pattern to provide a readonly view of a normal javascript * collection. Note that this trades performance for protection. There's nothing * stoping a user from mutating one of these data structures, save a warning * that the typescript compiler may give them. * * Other options to consider are facebook's Immutable.js which provides a * variety of truely immutable data structures. */ /** A zero-overhead immutable view of an array. */ export declare type ImmutableArray = ReadonlyArray; /** A zero-overhead immutable view of a set. */ export declare type ImmutableSet = ReadonlySet; /** A zero-overhead immutable view of a map. */ export declare type ImmutableMap = ReadonlyMap; export declare function asImmutable(array: Array): ImmutableArray; export declare function asImmutable(set: Set): ImmutableSet; export declare function asImmutable(map: Map): ImmutableMap; export declare function asImmutable(object: O): Readonly; /** * Take care, this function is inherently unsafe. * * You're taking a data structure that has been declare as immutable and getting * a mutable reference to it. */ export declare function unsafeAsMutable(array: ImmutableArray): Array; export declare function unsafeAsMutable(set: ImmutableSet): Set; export declare function unsafeAsMutable(map: ImmutableMap): Map; export declare function unsafeAsMutable(object: Readonly): O;